Commit 75276f01 authored by Davide Beatrici's avatar Davide Beatrici Committed by Alexandre Julliard

winepulse: Move create_session into mmdevapi.

parent b61e02f7
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi); WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
static struct list g_sessions = LIST_INIT(g_sessions);
static CRITICAL_SECTION g_sessions_lock; static CRITICAL_SECTION g_sessions_lock;
static CRITICAL_SECTION_DEBUG g_sessions_lock_debug = static CRITICAL_SECTION_DEBUG g_sessions_lock_debug =
{ {
......
...@@ -40,6 +40,8 @@ extern void sessions_unlock(void) DECLSPEC_HIDDEN; ...@@ -40,6 +40,8 @@ extern void sessions_unlock(void) DECLSPEC_HIDDEN;
extern void set_stream_volumes(struct audio_client *This) DECLSPEC_HIDDEN; extern void set_stream_volumes(struct audio_client *This) DECLSPEC_HIDDEN;
struct list sessions = LIST_INIT(sessions);
static inline struct audio_session_wrapper *impl_from_IAudioSessionControl2(IAudioSessionControl2 *iface) static inline struct audio_session_wrapper *impl_from_IAudioSessionControl2(IAudioSessionControl2 *iface)
{ {
return CONTAINING_RECORD(iface, struct audio_session_wrapper, IAudioSessionControl2_iface); return CONTAINING_RECORD(iface, struct audio_session_wrapper, IAudioSessionControl2_iface);
...@@ -572,6 +574,28 @@ void session_init_vols(struct audio_session *session, UINT channels) ...@@ -572,6 +574,28 @@ void session_init_vols(struct audio_session *session, UINT channels)
} }
} }
struct audio_session *session_create(const GUID *guid, IMMDevice *device, UINT channels)
{
struct audio_session *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(struct audio_session));
if (!ret)
return NULL;
memcpy(&ret->guid, guid, sizeof(GUID));
ret->device = device;
list_init(&ret->clients);
list_add_head(&sessions, &ret->entry);
session_init_vols(ret, channels);
ret->master_vol = 1.f;
return ret;
}
struct audio_session_wrapper *session_wrapper_create(struct audio_client *client) struct audio_session_wrapper *session_wrapper_create(struct audio_client *client)
{ {
struct audio_session_wrapper *ret; struct audio_session_wrapper *ret;
......
...@@ -56,7 +56,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(pulse); ...@@ -56,7 +56,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(pulse);
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER) #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
static struct list g_sessions = LIST_INIT(g_sessions); extern struct list sessions;
static struct list g_devices_cache = LIST_INIT(g_devices_cache); static struct list g_devices_cache = LIST_INIT(g_devices_cache);
struct device_cache { struct device_cache {
...@@ -401,30 +401,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -401,30 +401,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
extern void session_init_vols(AudioSession *session, UINT channels); extern void session_init_vols(AudioSession *session, UINT channels);
static AudioSession *create_session(const GUID *guid, IMMDevice *device, extern AudioSession *session_create(const GUID *guid, IMMDevice *device,
UINT num_channels) UINT num_channels);
{
AudioSession *ret;
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(AudioSession));
if (!ret)
return NULL;
memcpy(&ret->guid, guid, sizeof(GUID));
ret->device = device;
list_init(&ret->clients);
list_add_head(&g_sessions, &ret->entry);
session_init_vols(ret, num_channels);
ret->master_vol = 1.f;
return ret;
}
/* if channels == 0, then this will return or create a session with /* if channels == 0, then this will return or create a session with
* matching dataflow and GUID. otherwise, channels must also match */ * matching dataflow and GUID. otherwise, channels must also match */
HRESULT get_audio_session(const GUID *sessionguid, HRESULT get_audio_session(const GUID *sessionguid,
...@@ -433,7 +411,7 @@ HRESULT get_audio_session(const GUID *sessionguid, ...@@ -433,7 +411,7 @@ HRESULT get_audio_session(const GUID *sessionguid,
AudioSession *session; AudioSession *session;
if (!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)) { if (!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)) {
*out = create_session(&GUID_NULL, device, channels); *out = session_create(&GUID_NULL, device, channels);
if (!*out) if (!*out)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -441,7 +419,7 @@ HRESULT get_audio_session(const GUID *sessionguid, ...@@ -441,7 +419,7 @@ HRESULT get_audio_session(const GUID *sessionguid,
} }
*out = NULL; *out = NULL;
LIST_FOR_EACH_ENTRY(session, &g_sessions, AudioSession, entry) { LIST_FOR_EACH_ENTRY(session, &sessions, AudioSession, entry) {
if (session->device == device && if (session->device == device &&
IsEqualGUID(sessionguid, &session->guid)) { IsEqualGUID(sessionguid, &session->guid)) {
session_init_vols(session, channels); session_init_vols(session, channels);
...@@ -451,7 +429,7 @@ HRESULT get_audio_session(const GUID *sessionguid, ...@@ -451,7 +429,7 @@ HRESULT get_audio_session(const GUID *sessionguid,
} }
if (!*out) { if (!*out) {
*out = create_session(sessionguid, device, channels); *out = session_create(sessionguid, device, channels);
if (!*out) if (!*out)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment