Commit 30c17619 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winepulse: Move pulse_get_latency to unix lib.

parent af84907c
......@@ -627,33 +627,15 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
REFERENCE_TIME *latency)
{
ACImpl *This = impl_from_IAudioClient3(iface);
const pa_buffer_attr *attr;
REFERENCE_TIME lat;
HRESULT hr;
TRACE("(%p)->(%p)\n", This, latency);
if (!latency)
return E_POINTER;
if (!This->pulse_stream)
return AUDCLNT_E_NOT_INITIALIZED;
pulse->lock();
hr = pulse_stream_valid(This);
if (FAILED(hr)) {
pulse->unlock();
return hr;
}
attr = pa_stream_get_buffer_attr(This->pulse_stream->stream);
if (This->dataflow == eRender){
lat = attr->minreq / pa_frame_size(&This->pulse_stream->ss);
}else
lat = attr->fragsize / pa_frame_size(&This->pulse_stream->ss);
*latency = 10000000;
*latency *= lat;
*latency /= This->pulse_stream->ss.rate;
*latency += pulse_config.modes[0].def_period;
pulse->unlock();
TRACE("Latency: %u ms\n", (DWORD)(*latency / 10000));
return S_OK;
return pulse->get_latency(This->pulse_stream, latency);
}
static void ACImpl_GetRenderPad(ACImpl *This, UINT32 *out)
......
......@@ -1546,6 +1546,27 @@ static HRESULT WINAPI pulse_get_buffer_size(struct pulse_stream *stream, UINT32
return hr;
}
static HRESULT WINAPI pulse_get_latency(struct pulse_stream *stream, REFERENCE_TIME *latency)
{
const pa_buffer_attr *attr;
REFERENCE_TIME lat;
pulse_lock();
if (!pulse_stream_valid(stream)) {
pulse_unlock();
return AUDCLNT_E_DEVICE_INVALIDATED;
}
attr = pa_stream_get_buffer_attr(stream->stream);
if (stream->dataflow == eRender)
lat = attr->minreq / pa_frame_size(&stream->ss);
else
lat = attr->fragsize / pa_frame_size(&stream->ss);
*latency = (lat * 10000000) / stream->ss.rate + pulse_def_period[0];
pulse_unlock();
TRACE("Latency: %u ms\n", (DWORD)(*latency / 10000));
return S_OK;
}
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume,
const float *volumes, const float *session_volumes)
{
......@@ -1588,6 +1609,7 @@ static const struct unix_funcs unix_funcs =
pulse_get_render_buffer,
pulse_release_render_buffer,
pulse_get_buffer_size,
pulse_get_latency,
pulse_set_volumes,
pulse_set_event_handle,
pulse_test_connect,
......
......@@ -85,6 +85,7 @@ struct unix_funcs
HRESULT (WINAPI *release_render_buffer)(struct pulse_stream *stream, UINT32 written_frames,
DWORD flags);
HRESULT (WINAPI *get_buffer_size)(struct pulse_stream *stream, UINT32 *out);
HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency);
void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume,
const float *volumes, const float *session_volumes);
HRESULT (WINAPI *set_event_handle)(struct pulse_stream *stream, HANDLE event);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment