diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index 0ed4fcb02fe..d7390c5a677 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -1503,6 +1503,30 @@ static NTSTATUS get_next_packet_size(void *args) return STATUS_SUCCESS; } +static NTSTATUS get_position(void *args) +{ + struct get_position_params *params = args; + struct coreaudio_stream *stream = params->stream; + LARGE_INTEGER stamp, freq; + + OSSpinLockLock(&stream->lock); + + *params->pos = stream->written_frames - stream->held_frames; + + if(stream->share == AUDCLNT_SHAREMODE_SHARED) + *params->pos *= stream->fmt->nBlockAlign; + + if(params->qpctime){ + NtQueryPerformanceCounter(&stamp, &freq); + *params->qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart; + } + + OSSpinLockUnlock(&stream->lock); + + params->result = S_OK; + return STATUS_SUCCESS; +} + unixlib_entry_t __wine_unix_call_funcs[] = { get_endpoint_ids, @@ -1521,4 +1545,5 @@ unixlib_entry_t __wine_unix_call_funcs[] = get_latency, get_current_padding, get_next_packet_size, + get_position, }; diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index b0208ce0a44..ebfc0543af8 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -1469,42 +1469,22 @@ static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq) return S_OK; } -static HRESULT AudioClock_GetPosition_nolock(ACImpl *This, - UINT64 *pos, UINT64 *qpctime) -{ - *pos = This->stream->written_frames - This->stream->held_frames; - - if(This->stream->share == AUDCLNT_SHAREMODE_SHARED) - *pos *= This->stream->fmt->nBlockAlign; - - if(qpctime){ - LARGE_INTEGER stamp, freq; - QueryPerformanceCounter(&stamp); - QueryPerformanceFrequency(&freq); - *qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart; - } - - return S_OK; -} - static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos, UINT64 *qpctime) { ACImpl *This = impl_from_IAudioClock(iface); - HRESULT hr; + struct get_position_params params; TRACE("(%p)->(%p, %p)\n", This, pos, qpctime); if(!pos) return E_POINTER; - OSSpinLockLock(&This->stream->lock); - - hr = AudioClock_GetPosition_nolock(This, pos, qpctime); - - OSSpinLockUnlock(&This->stream->lock); - - return hr; + params.stream = This->stream; + params.pos = pos; + params.qpctime = qpctime; + UNIX_CALL(get_position, ¶ms); + return params.result; } static HRESULT WINAPI AudioClock_GetCharacteristics(IAudioClock *iface, diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h index 32eb57a866a..e9edaf82973 100644 --- a/dlls/winecoreaudio.drv/unixlib.h +++ b/dlls/winecoreaudio.drv/unixlib.h @@ -173,6 +173,14 @@ struct get_next_packet_size_params UINT32 *frames; }; +struct get_position_params +{ + struct coreaudio_stream *stream; + HRESULT result; + UINT64 *pos; + UINT64 *qpctime; +}; + enum unix_funcs { unix_get_endpoint_ids, @@ -191,6 +199,7 @@ enum unix_funcs unix_get_latency, unix_get_current_padding, unix_get_next_packet_size, + unix_get_position, }; extern unixlib_handle_t coreaudio_handle;