[PATCH 4/5] winealsa: Move is_started to the unixlib.
Huw Davies
huw at codeweavers.com
Thu Mar 10 02:20:05 CST 2022
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/winealsa.drv/alsa.c | 11 +++++++++++
dlls/winealsa.drv/mmdevdrv.c | 19 ++++---------------
dlls/winealsa.drv/unixlib.h | 7 +++++++
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c
index 870ec4db151..365f5637b20 100644
--- a/dlls/winealsa.drv/alsa.c
+++ b/dlls/winealsa.drv/alsa.c
@@ -2182,6 +2182,16 @@ static NTSTATUS set_event_handle(void *args)
return alsa_unlock_result(stream, ¶ms->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, ¶ms->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,
};
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c
index 6dfa3ad013f..0f6a30e0f45 100644
--- a/dlls/winealsa.drv/mmdevdrv.c
+++ b/dlls/winealsa.drv/mmdevdrv.c
@@ -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, ¶ms);
+ 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);
diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h
index 89b53fbcb9a..b73f40c8282 100644
--- a/dlls/winealsa.drv/unixlib.h
+++ b/dlls/winealsa.drv/unixlib.h
@@ -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;
--
2.25.1
More information about the wine-devel
mailing list