Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, May 19, 2021 at 10:24:23PM +0200, Jacek Caban wrote:
Signed-off-by: Jacek Caban jacek@codeweavers.com
dlls/winepulse.drv/mmdevdrv.c | 24 +++-------------------- dlls/winepulse.drv/pulse.c | 37 +++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/unixlib.h | 1 + 3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 8938eac011c..654126e6dfe 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -638,11 +638,6 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface, return pulse->get_latency(This->pulse_stream, latency); }
-static void ACImpl_GetRenderPad(ACImpl *This, UINT32 *out) -{
- *out = This->pulse_stream->held_bytes / pa_frame_size(&This->pulse_stream->ss);
-}
static void ACImpl_GetCapturePad(ACImpl *This, UINT32 *out) { ACPacket *packet = This->pulse_stream->locked_ptr; @@ -659,28 +654,15 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface, UINT32 *out) { ACImpl *This = impl_from_IAudioClient3(iface);
HRESULT hr;
TRACE("(%p)->(%p)\n", This, out);
if (!out) 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;
- }
- if (This->dataflow == eRender)
ACImpl_GetRenderPad(This, out);
- else
ACImpl_GetCapturePad(This, out);
- pulse->unlock();
- TRACE("%p Pad: %u ms (%u)\n", This, MulDiv(*out, 1000, This->pulse_stream->ss.rate), *out);
- return S_OK;
- return pulse->get_current_padding(This->pulse_stream, out);
}
static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient3 *iface, diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 711d9874818..a17bce283f6 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -1416,6 +1416,23 @@ static void alloc_tmp_buffer(struct pulse_stream *stream, UINT32 bytes) stream->tmp_buffer_bytes = bytes; }
+static UINT32 pulse_render_padding(struct pulse_stream *stream) +{
- return stream->held_bytes / pa_frame_size(&stream->ss);
+}
+static UINT32 pulse_capture_padding(struct pulse_stream *stream) +{
- ACPacket *packet = stream->locked_ptr;
- if (!packet && !list_empty(&stream->packet_filled_head))
- {
packet = (ACPacket*)list_head(&stream->packet_filled_head);
stream->locked_ptr = packet;
list_remove(&packet->entry);
- }
- return stream->held_bytes / pa_frame_size(&stream->ss);
+}
static HRESULT WINAPI pulse_get_render_buffer(struct pulse_stream *stream, UINT32 frames, BYTE **data) { size_t bytes; @@ -1567,6 +1584,25 @@ static HRESULT WINAPI pulse_get_latency(struct pulse_stream *stream, REFERENCE_T return S_OK; }
+static HRESULT WINAPI pulse_get_current_padding(struct pulse_stream *stream, UINT32 *out) +{
- pulse_lock();
- if (!pulse_stream_valid(stream))
- {
pulse_unlock();
return AUDCLNT_E_DEVICE_INVALIDATED;
- }
- if (stream->dataflow == eRender)
*out = pulse_render_padding(stream);
- else
*out = pulse_capture_padding(stream);
- pulse_unlock();
- TRACE("%p Pad: %u ms (%u)\n", stream, muldiv(*out, 1000, stream->ss.rate), *out);
- return S_OK;
+}
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume, const float *volumes, const float *session_volumes) { @@ -1610,6 +1646,7 @@ static const struct unix_funcs unix_funcs = pulse_release_render_buffer, pulse_get_buffer_size, pulse_get_latency,
- pulse_get_current_padding, 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 8be3ba67264..6017d8052e8 100644 --- a/dlls/winepulse.drv/unixlib.h +++ b/dlls/winepulse.drv/unixlib.h @@ -86,6 +86,7 @@ struct unix_funcs DWORD flags); HRESULT (WINAPI *get_buffer_size)(struct pulse_stream *stream, UINT32 *out); HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency);
- HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out); 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);