winepulse: Move pulse_release_capture_buffer to unix lib.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-05-19 22:27:08 +02:00 committed by Alexandre Julliard
parent 459e911b65
commit 80b996c53c
3 changed files with 35 additions and 22 deletions

View File

@ -1222,28 +1222,10 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
TRACE("(%p)->(%u)\n", This, done); TRACE("(%p)->(%u)\n", This, done);
pulse->lock(); if (!This->pulse_stream)
if (!This->pulse_stream->locked && done) { return AUDCLNT_E_NOT_INITIALIZED;
pulse->unlock();
return AUDCLNT_E_OUT_OF_ORDER; return pulse->release_capture_buffer(This->pulse_stream, done);
}
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;
} }
static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize( static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(

View File

@ -1591,6 +1591,35 @@ static HRESULT WINAPI pulse_get_capture_buffer(struct pulse_stream *stream, BYTE
return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY; 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) static HRESULT WINAPI pulse_get_buffer_size(struct pulse_stream *stream, UINT32 *out)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
@ -1687,6 +1716,7 @@ static const struct unix_funcs unix_funcs =
pulse_get_render_buffer, pulse_get_render_buffer,
pulse_release_render_buffer, pulse_release_render_buffer,
pulse_get_capture_buffer, pulse_get_capture_buffer,
pulse_release_capture_buffer,
pulse_get_buffer_size, pulse_get_buffer_size,
pulse_get_latency, pulse_get_latency,
pulse_get_current_padding, pulse_get_current_padding,

View File

@ -86,6 +86,7 @@ struct unix_funcs
DWORD flags); DWORD flags);
HRESULT (WINAPI *get_capture_buffer)(struct pulse_stream *stream, BYTE **data, UINT32 *frames, HRESULT (WINAPI *get_capture_buffer)(struct pulse_stream *stream, BYTE **data, UINT32 *frames,
DWORD *flags, UINT64 *devpos, UINT64 *qpcpos); 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_buffer_size)(struct pulse_stream *stream, UINT32 *out);
HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency); HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency);
HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out); HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out);