[PATCH v2 1/7] winepulse: Move pulse_get_position to unix lib.
Andrew Eikum
aeikum at codeweavers.com
Tue May 25 11:52:58 CDT 2021
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Mon, May 24, 2021 at 06:21:49PM +0200, Jacek Caban wrote:
>
> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
> ---
> dlls/winepulse.drv/mmdevdrv.c | 46 +++++++++--------------------------
> dlls/winepulse.drv/pulse.c | 34 ++++++++++++++++++++++++++
> dlls/winepulse.drv/unixlib.h | 1 +
> 3 files changed, 47 insertions(+), 34 deletions(-)
>
>
> diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
> index 1fe0d0bd50e..0178cdb9e7b 100644
> --- a/dlls/winepulse.drv/mmdevdrv.c
> +++ b/dlls/winepulse.drv/mmdevdrv.c
> @@ -1296,42 +1296,15 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
> UINT64 *qpctime)
> {
> ACImpl *This = impl_from_IAudioClock(iface);
> - HRESULT hr;
>
> TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
>
> if (!pos)
> 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;
> - }
> -
> - *pos = This->pulse_stream->clock_written - This->pulse_stream->held_bytes;
> -
> - if (This->pulse_stream->share == AUDCLNT_SHAREMODE_EXCLUSIVE)
> - *pos /= pa_frame_size(&This->pulse_stream->ss);
> -
> - /* Make time never go backwards */
> - if (*pos < This->pulse_stream->clock_lastpos)
> - *pos = This->pulse_stream->clock_lastpos;
> - else
> - This->pulse_stream->clock_lastpos = *pos;
> - pulse->unlock();
> -
> - TRACE("%p Position: %u\n", This, (unsigned)*pos);
> -
> - if (qpctime) {
> - LARGE_INTEGER stamp, freq;
> - QueryPerformanceCounter(&stamp);
> - QueryPerformanceFrequency(&freq);
> - *qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
> - }
> -
> - return S_OK;
> + return pulse->get_position(This->pulse_stream, FALSE, pos, qpctime);
> }
>
> static HRESULT WINAPI AudioClock_GetCharacteristics(IAudioClock *iface,
> @@ -1382,10 +1355,15 @@ static HRESULT WINAPI AudioClock2_GetDevicePosition(IAudioClock2 *iface,
> UINT64 *pos, UINT64 *qpctime)
> {
> ACImpl *This = impl_from_IAudioClock2(iface);
> - HRESULT hr = AudioClock_GetPosition(&This->IAudioClock_iface, pos, qpctime);
> - if (SUCCEEDED(hr) && This->pulse_stream->share == AUDCLNT_SHAREMODE_SHARED)
> - *pos /= pa_frame_size(&This->pulse_stream->ss);
> - return hr;
> +
> + TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
> +
> + if (!pos)
> + return E_POINTER;
> + if (!This->pulse_stream)
> + return AUDCLNT_E_NOT_INITIALIZED;
> +
> + return pulse->get_position(This->pulse_stream, TRUE, pos, qpctime);
> }
>
> static const IAudioClock2Vtbl AudioClock2_Vtbl =
> diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
> index b9dceb911d0..063c92605b6 100644
> --- a/dlls/winepulse.drv/pulse.c
> +++ b/dlls/winepulse.drv/pulse.c
> @@ -1710,6 +1710,39 @@ static HRESULT WINAPI pulse_get_frequency(struct pulse_stream *stream, UINT64 *f
> return S_OK;
> }
>
> +static HRESULT WINAPI pulse_get_position(struct pulse_stream *stream, BOOL device, UINT64 *pos, UINT64 *qpctime)
> +{
> + pulse_lock();
> + if (!pulse_stream_valid(stream))
> + {
> + pulse_unlock();
> + return AUDCLNT_E_DEVICE_INVALIDATED;
> + }
> +
> + *pos = stream->clock_written - stream->held_bytes;
> +
> + if (stream->share == AUDCLNT_SHAREMODE_EXCLUSIVE || device)
> + *pos /= pa_frame_size(&stream->ss);
> +
> + /* Make time never go backwards */
> + if (*pos < stream->clock_lastpos)
> + *pos = stream->clock_lastpos;
> + else
> + stream->clock_lastpos = *pos;
> + pulse_unlock();
> +
> + TRACE("%p Position: %u\n", stream, (unsigned)*pos);
> +
> + if (qpctime)
> + {
> + LARGE_INTEGER stamp, freq;
> + NtQueryPerformanceCounter(&stamp, &freq);
> + *qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
> + }
> +
> + return S_OK;
> +}
> +
> static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume,
> const float *volumes, const float *session_volumes)
> {
> @@ -1758,6 +1791,7 @@ static const struct unix_funcs unix_funcs =
> pulse_get_current_padding,
> pulse_get_next_packet_size,
> pulse_get_frequency,
> + pulse_get_position,
> 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 d9c6ef057bb..f1546d42d76 100644
> --- a/dlls/winepulse.drv/unixlib.h
> +++ b/dlls/winepulse.drv/unixlib.h
> @@ -84,6 +84,7 @@ struct unix_funcs
> HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out);
> HRESULT (WINAPI *get_next_packet_size)(struct pulse_stream *stream, UINT32 *frames);
> HRESULT (WINAPI *get_frequency)(struct pulse_stream *stream, UINT64 *freq);
> + HRESULT (WINAPI *get_position)(struct pulse_stream *stream, BOOL device, UINT64 *pos, UINT64 *qpctime);
> 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);
>
More information about the wine-devel
mailing list