Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, May 19, 2021 at 10:24:13PM +0200, Jacek Caban wrote:
Signed-off-by: Jacek Caban jacek@codeweavers.com
dlls/winepulse.drv/mmdevdrv.c | 24 +++--------------------- dlls/winepulse.drv/pulse.c | 22 ++++++++++++++++++++++ dlls/winepulse.drv/unixlib.h | 1 + 3 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 751f272c4b4..8938eac011c 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -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) diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 0b8c187c254..711d9874818 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -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,
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h index 22bcf9c4bc2..8be3ba67264 100644 --- a/dlls/winepulse.drv/unixlib.h +++ b/dlls/winepulse.drv/unixlib.h @@ -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);