[PATCH 4/7] winepulse: Move pulse_get_capture_buffer to unix lib.
Andrew Eikum
aeikum at codeweavers.com
Thu May 20 10:46:10 CDT 2021
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Wed, May 19, 2021 at 10:27:00PM +0200, Jacek Caban wrote:
> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
> ---
> dlls/winepulse.drv/mmdevdrv.c | 35 +++-------------------------
> dlls/winepulse.drv/pulse.c | 43 +++++++++++++++++++++++++++++++++++
> dlls/winepulse.drv/unixlib.h | 2 ++
> 3 files changed, 48 insertions(+), 32 deletions(-)
>
>
> diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
> index 654126e6dfe..7e2877f184e 100644
> --- a/dlls/winepulse.drv/mmdevdrv.c
> +++ b/dlls/winepulse.drv/mmdevdrv.c
> @@ -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(
> diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
> index a17bce283f6..15173647836 100644
> --- a/dlls/winepulse.drv/pulse.c
> +++ b/dlls/winepulse.drv/pulse.c
> @@ -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,
> diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
> index 6017d8052e8..ad6dd2da1f5 100644
> --- a/dlls/winepulse.drv/unixlib.h
> +++ b/dlls/winepulse.drv/unixlib.h
> @@ -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);
>
More information about the wine-devel
mailing list