wineoss: Move get_buffer_size 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 2022-04-13 07:38:44 +01:00 committed by Alexandre Julliard
parent 07f22e20d7
commit aa9d07e630
3 changed files with 44 additions and 7 deletions

View File

@ -783,7 +783,7 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
UINT32 *frames) UINT32 *frames)
{ {
ACImpl *This = impl_from_IAudioClient3(iface); ACImpl *This = impl_from_IAudioClient3(iface);
struct oss_stream *stream = This->stream; struct get_buffer_size_params params;
TRACE("(%p)->(%p)\n", This, frames); TRACE("(%p)->(%p)\n", This, frames);
@ -793,15 +793,13 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
if(!This->stream) if(!This->stream)
return AUDCLNT_E_NOT_INITIALIZED; return AUDCLNT_E_NOT_INITIALIZED;
oss_lock(stream); params.stream = This->stream;
params.size = frames;
*frames = stream->bufsize_frames;
OSS_CALL(get_buffer_size, &params);
TRACE("buffer size: %u\n", *frames); TRACE("buffer size: %u\n", *frames);
oss_unlock(stream); return params.result;
return S_OK;
} }
static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface, static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,

View File

@ -70,6 +70,24 @@ static int muldiv( int a, int b, int c )
return ret; return ret;
} }
static void oss_lock(struct oss_stream *stream)
{
pthread_mutex_lock(&stream->lock);
}
static void oss_unlock(struct oss_stream *stream)
{
pthread_mutex_unlock(&stream->lock);
}
static NTSTATUS oss_unlock_result(struct oss_stream *stream,
HRESULT *result, HRESULT value)
{
*result = value;
oss_unlock(stream);
return STATUS_SUCCESS;
}
static NTSTATUS test_connect(void *args) static NTSTATUS test_connect(void *args)
{ {
struct test_connect_params *params = args; struct test_connect_params *params = args;
@ -732,6 +750,18 @@ static NTSTATUS get_mix_format(void *args)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS get_buffer_size(void *args)
{
struct get_buffer_size_params *params = args;
struct oss_stream *stream = params->stream;
oss_lock(stream);
*params->size = stream->bufsize_frames;
return oss_unlock_result(stream, &params->result, S_OK);
}
unixlib_entry_t __wine_unix_call_funcs[] = unixlib_entry_t __wine_unix_call_funcs[] =
{ {
test_connect, test_connect,
@ -740,4 +770,5 @@ unixlib_entry_t __wine_unix_call_funcs[] =
release_stream, release_stream,
is_format_supported, is_format_supported,
get_mix_format, get_mix_format,
get_buffer_size,
}; };

View File

@ -106,6 +106,13 @@ struct get_mix_format_params
HRESULT result; HRESULT result;
}; };
struct get_buffer_size_params
{
struct oss_stream *stream;
HRESULT result;
UINT32 *size;
};
enum oss_funcs enum oss_funcs
{ {
oss_test_connect, oss_test_connect,
@ -114,6 +121,7 @@ enum oss_funcs
oss_release_stream, oss_release_stream,
oss_is_format_supported, oss_is_format_supported,
oss_get_mix_format, oss_get_mix_format,
oss_get_buffer_size,
}; };
extern unixlib_handle_t oss_handle; extern unixlib_handle_t oss_handle;