winealsa: Move is_started 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-03-10 08:20:05 +00:00 committed by Alexandre Julliard
parent 3ddb038513
commit 7977f53219
3 changed files with 22 additions and 15 deletions

View File

@ -2182,6 +2182,16 @@ static NTSTATUS set_event_handle(void *args)
return alsa_unlock_result(stream, &params->result, S_OK);
}
static NTSTATUS is_started(void *args)
{
struct is_started_params *params = args;
struct alsa_stream *stream = params->stream;
alsa_lock(stream);
return alsa_unlock_result(stream, &params->result, stream->started ? S_OK : S_FALSE);
}
unixlib_entry_t __wine_unix_call_funcs[] =
{
get_endpoint_ids,
@ -2204,4 +2214,5 @@ unixlib_entry_t __wine_unix_call_funcs[] =
get_frequency,
get_position,
set_event_handle,
is_started,
};

View File

@ -25,7 +25,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <pthread.h>
#include "windef.h"
#include "winbase.h"
@ -237,16 +236,6 @@ int WINAPI AUDDRV_GetPriority(void)
return Priority_Neutral;
}
static void alsa_lock(struct alsa_stream *stream)
{
pthread_mutex_lock(&stream->lock);
}
static void alsa_unlock(struct alsa_stream *stream)
{
pthread_mutex_unlock(&stream->lock);
}
static HRESULT alsa_stream_release(struct alsa_stream *stream, HANDLE timer_thread)
{
struct release_stream_params params;
@ -1640,6 +1629,7 @@ static HRESULT WINAPI AudioSessionControl_GetState(IAudioSessionControl2 *iface,
AudioSessionState *state)
{
AudioSessionWrapper *This = impl_from_IAudioSessionControl2(iface);
struct is_started_params params;
ACImpl *client;
TRACE("(%p)->(%p)\n", This, state);
@ -1656,14 +1646,13 @@ static HRESULT WINAPI AudioSessionControl_GetState(IAudioSessionControl2 *iface,
}
LIST_FOR_EACH_ENTRY(client, &This->session->clients, ACImpl, entry){
alsa_lock(client->stream);
if(client->stream->started){
params.stream = client->stream;
ALSA_CALL(is_started, &params);
if(params.result == S_OK){
*state = AudioSessionStateActive;
alsa_unlock(client->stream);
LeaveCriticalSection(&g_sessions_lock);
return S_OK;
}
alsa_unlock(client->stream);
}
LeaveCriticalSection(&g_sessions_lock);

View File

@ -216,6 +216,12 @@ struct set_event_handle_params
HRESULT result;
};
struct is_started_params
{
struct alsa_stream *stream;
HRESULT result;
};
enum alsa_funcs
{
alsa_get_endpoint_ids,
@ -238,6 +244,7 @@ enum alsa_funcs
alsa_get_frequency,
alsa_get_position,
alsa_set_event_handle,
alsa_is_started,
};
extern unixlib_handle_t alsa_handle;