winecoreaudio: Move get_current_padding to the unixlib.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-11-23 07:55:02 +00:00 committed by Alexandre Julliard
parent 881e0f18fb
commit 2dd83eed7b
3 changed files with 41 additions and 14 deletions

View File

@ -1219,6 +1219,24 @@ static NTSTATUS get_latency(void *args)
return STATUS_SUCCESS;
}
static UINT32 get_current_padding_nolock(struct coreaudio_stream *stream)
{
if(stream->flow == eCapture) capture_resample(stream);
return stream->held_frames;
}
static NTSTATUS get_current_padding(void *args)
{
struct get_current_padding_params *params = args;
struct coreaudio_stream *stream = params->stream;
if(params->lock) OSSpinLockLock(&stream->lock);
*params->padding = get_current_padding_nolock(stream);
if(params->lock) OSSpinLockUnlock(&stream->lock);
params->result = S_OK;
return STATUS_SUCCESS;
}
unixlib_entry_t __wine_unix_call_funcs[] =
{
get_endpoint_ids,
@ -1228,6 +1246,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
is_format_supported,
get_buffer_size,
get_latency,
get_current_padding,
capture_resample /* temporary */
};

View File

@ -874,22 +874,23 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
static HRESULT AudioClient_GetCurrentPadding_nolock(ACImpl *This,
UINT32 *numpad)
{
struct get_current_padding_params params;
if(!This->stream)
return AUDCLNT_E_NOT_INITIALIZED;
if(This->dataflow == eCapture)
capture_resample(This);
*numpad = This->stream->held_frames;
return S_OK;
params.stream = This->stream;
params.padding = numpad;
params.lock = FALSE;
UNIX_CALL(get_current_padding, &params);
return params.result;
}
static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface,
UINT32 *numpad)
{
ACImpl *This = impl_from_IAudioClient3(iface);
HRESULT hr;
struct get_current_padding_params params;
TRACE("(%p)->(%p)\n", This, numpad);
@ -899,13 +900,11 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface,
if(!This->stream)
return AUDCLNT_E_NOT_INITIALIZED;
OSSpinLockLock(&This->stream->lock);
hr = AudioClient_GetCurrentPadding_nolock(This, numpad);
OSSpinLockUnlock(&This->stream->lock);
return hr;
params.stream = This->stream;
params.padding = numpad;
params.lock = TRUE;
UNIX_CALL(get_current_padding, &params);
return params.result;
}
static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient3 *iface,

View File

@ -107,6 +107,14 @@ struct get_latency_params
REFERENCE_TIME *latency;
};
struct get_current_padding_params
{
struct coreaudio_stream *stream;
BOOL lock; /* temporary */
HRESULT result;
UINT32 *padding;
};
enum unix_funcs
{
unix_get_endpoint_ids,
@ -116,6 +124,7 @@ enum unix_funcs
unix_is_format_supported,
unix_get_buffer_size,
unix_get_latency,
unix_get_current_padding,
unix_capture_resample /* temporary */
};