diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 7e2877f184e..b85d9b5e80b 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -1222,28 +1222,10 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer( TRACE("(%p)->(%u)\n", This, done); - pulse->lock(); - if (!This->pulse_stream->locked && done) { - pulse->unlock(); - return AUDCLNT_E_OUT_OF_ORDER; - } - if (done && This->pulse_stream->locked != done) { - pulse->unlock(); - return AUDCLNT_E_INVALID_SIZE; - } - if (done) { - ACPacket *packet = This->pulse_stream->locked_ptr; - This->pulse_stream->locked_ptr = NULL; - This->pulse_stream->held_bytes -= This->pulse_stream->period_bytes; - if (packet->discont) - This->pulse_stream->clock_written += 2 * This->pulse_stream->period_bytes; - else - This->pulse_stream->clock_written += This->pulse_stream->period_bytes; - list_add_tail(&This->pulse_stream->packet_free_head, &packet->entry); - } - This->pulse_stream->locked = 0; - pulse->unlock(); - return S_OK; + if (!This->pulse_stream) + return AUDCLNT_E_NOT_INITIALIZED; + + return pulse->release_capture_buffer(This->pulse_stream, done); } static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize( diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 15173647836..4ff3753c189 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -1591,6 +1591,35 @@ static HRESULT WINAPI pulse_get_capture_buffer(struct pulse_stream *stream, BYTE return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY; } +static HRESULT WINAPI pulse_release_capture_buffer(struct pulse_stream *stream, BOOL done) +{ + pulse_lock(); + if (!stream->locked && done) + { + pulse_unlock(); + return AUDCLNT_E_OUT_OF_ORDER; + } + if (done && stream->locked != done) + { + pulse_unlock(); + return AUDCLNT_E_INVALID_SIZE; + } + if (done) + { + ACPacket *packet = stream->locked_ptr; + stream->locked_ptr = NULL; + stream->held_bytes -= stream->period_bytes; + if (packet->discont) + stream->clock_written += 2 * stream->period_bytes; + else + stream->clock_written += stream->period_bytes; + list_add_tail(&stream->packet_free_head, &packet->entry); + } + stream->locked = 0; + pulse_unlock(); + return S_OK; +} + static HRESULT WINAPI pulse_get_buffer_size(struct pulse_stream *stream, UINT32 *out) { HRESULT hr = S_OK; @@ -1687,6 +1716,7 @@ static const struct unix_funcs unix_funcs = pulse_get_render_buffer, pulse_release_render_buffer, pulse_get_capture_buffer, + pulse_release_capture_buffer, pulse_get_buffer_size, pulse_get_latency, pulse_get_current_padding, diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h index ad6dd2da1f5..e3471607d26 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_capture_buffer)(struct pulse_stream *stream, BYTE **data, UINT32 *frames, DWORD *flags, UINT64 *devpos, UINT64 *qpcpos); + HRESULT (WINAPI *release_capture_buffer)(struct pulse_stream *stream, BOOL done); 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);