winepulse: Move pulse_get_position 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-24 18:21:49 +02:00 committed by Alexandre Julliard
parent 2b03b2873e
commit 1518e73b23
3 changed files with 47 additions and 34 deletions

View File

@ -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 =

View File

@ -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,

View File

@ -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);