winepulse: Move pulse_get_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:00 +02:00 committed by Alexandre Julliard
parent 42d826bc8c
commit 459e911b65
3 changed files with 48 additions and 32 deletions

View File

@ -1200,48 +1200,19 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
UINT64 *qpcpos)
{
ACImpl *This = impl_from_IAudioCaptureClient(iface);
HRESULT hr;
ACPacket *packet;
TRACE("(%p)->(%p, %p, %p, %p, %p)\n", This, data, frames, flags,
devpos, qpcpos);
if (!data)
return E_POINTER;
*data = NULL;
if (!frames || !flags)
return E_POINTER;
if (!This->pulse_stream)
return AUDCLNT_E_NOT_INITIALIZED;
pulse->lock();
hr = pulse_stream_valid(This);
if (FAILED(hr) || This->pulse_stream->locked) {
pulse->unlock();
return FAILED(hr) ? hr : AUDCLNT_E_OUT_OF_ORDER;
}
ACImpl_GetCapturePad(This, NULL);
if ((packet = This->pulse_stream->locked_ptr)) {
*frames = This->pulse_stream->period_bytes / pa_frame_size(&This->pulse_stream->ss);
*flags = 0;
if (packet->discont)
*flags |= AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY;
if (devpos) {
if (packet->discont)
*devpos = (This->pulse_stream->clock_written + This->pulse_stream->period_bytes) / pa_frame_size(&This->pulse_stream->ss);
else
*devpos = This->pulse_stream->clock_written / pa_frame_size(&This->pulse_stream->ss);
}
if (qpcpos)
*qpcpos = packet->qpcpos;
*data = packet->data;
}
else
*frames = 0;
This->pulse_stream->locked = *frames;
pulse->unlock();
return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY;
return pulse->get_capture_buffer(This->pulse_stream, data, frames, flags, devpos, qpcpos);
}
static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(

View File

@ -1549,6 +1549,48 @@ static HRESULT WINAPI pulse_release_render_buffer(struct pulse_stream *stream, U
return S_OK;
}
static HRESULT WINAPI pulse_get_capture_buffer(struct pulse_stream *stream, BYTE **data,
UINT32 *frames, DWORD *flags, UINT64 *devpos, UINT64 *qpcpos)
{
ACPacket *packet;
pulse_lock();
if (!pulse_stream_valid(stream))
{
pulse_unlock();
return AUDCLNT_E_DEVICE_INVALIDATED;
}
if (stream->locked)
{
pulse_unlock();
return AUDCLNT_E_OUT_OF_ORDER;
}
pulse_capture_padding(stream);
if ((packet = stream->locked_ptr))
{
*frames = stream->period_bytes / pa_frame_size(&stream->ss);
*flags = 0;
if (packet->discont)
*flags |= AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY;
if (devpos)
{
if (packet->discont)
*devpos = (stream->clock_written + stream->period_bytes) / pa_frame_size(&stream->ss);
else
*devpos = stream->clock_written / pa_frame_size(&stream->ss);
}
if (qpcpos)
*qpcpos = packet->qpcpos;
*data = packet->data;
}
else
*frames = 0;
stream->locked = *frames;
pulse_unlock();
return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY;
}
static HRESULT WINAPI pulse_get_buffer_size(struct pulse_stream *stream, UINT32 *out)
{
HRESULT hr = S_OK;
@ -1644,6 +1686,7 @@ static const struct unix_funcs unix_funcs =
pulse_timer_loop,
pulse_get_render_buffer,
pulse_release_render_buffer,
pulse_get_capture_buffer,
pulse_get_buffer_size,
pulse_get_latency,
pulse_get_current_padding,

View File

@ -84,6 +84,8 @@ struct unix_funcs
HRESULT (WINAPI *get_render_buffer)(struct pulse_stream *stream, UINT32 frames, BYTE **data);
HRESULT (WINAPI *release_render_buffer)(struct pulse_stream *stream, UINT32 written_frames,
DWORD flags);
HRESULT (WINAPI *get_capture_buffer)(struct pulse_stream *stream, BYTE **data, UINT32 *frames,
DWORD *flags, UINT64 *devpos, UINT64 *qpcpos);
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);