Commit 024189ae authored by Davide Beatrici's avatar Davide Beatrici Committed by Alexandre Julliard

mmdevapi: Implement get_audio_session.

parent ebd3fa86
...@@ -45,12 +45,6 @@ void sessions_unlock(void) ...@@ -45,12 +45,6 @@ void sessions_unlock(void)
LeaveCriticalSection(&g_sessions_lock); LeaveCriticalSection(&g_sessions_lock);
} }
HRESULT get_audio_session(const GUID *sessionguid, IMMDevice *device, UINT channels,
struct audio_session **out)
{
return E_NOTIMPL;
}
static inline struct session_mgr *impl_from_IAudioSessionManager2(IAudioSessionManager2 *iface) static inline struct session_mgr *impl_from_IAudioSessionManager2(IAudioSessionManager2 *iface)
{ {
return CONTAINING_RECORD(iface, struct session_mgr, IAudioSessionManager2_iface); return CONTAINING_RECORD(iface, struct session_mgr, IAudioSessionManager2_iface);
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi); WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static HKEY key_render; static HKEY key_render;
static HKEY key_capture; static HKEY key_capture;
......
...@@ -40,7 +40,7 @@ extern void sessions_unlock(void) DECLSPEC_HIDDEN; ...@@ -40,7 +40,7 @@ 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 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)
{ {
...@@ -245,7 +245,7 @@ static HRESULT WINAPI control_SetDuckingPreference(IAudioSessionControl2 *iface, ...@@ -245,7 +245,7 @@ static HRESULT WINAPI control_SetDuckingPreference(IAudioSessionControl2 *iface,
return S_OK; return S_OK;
} }
const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl = static const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl =
{ {
control_QueryInterface, control_QueryInterface,
control_AddRef, control_AddRef,
...@@ -416,7 +416,7 @@ static HRESULT WINAPI channelvolume_GetAllVolumes(IChannelAudioVolume *iface, UI ...@@ -416,7 +416,7 @@ static HRESULT WINAPI channelvolume_GetAllVolumes(IChannelAudioVolume *iface, UI
return S_OK; return S_OK;
} }
const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl = static const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl =
{ {
channelvolume_QueryInterface, channelvolume_QueryInterface,
channelvolume_AddRef, channelvolume_AddRef,
...@@ -542,7 +542,7 @@ static HRESULT WINAPI simplevolume_GetMute(ISimpleAudioVolume *iface, BOOL *mute ...@@ -542,7 +542,7 @@ static HRESULT WINAPI simplevolume_GetMute(ISimpleAudioVolume *iface, BOOL *mute
return S_OK; return S_OK;
} }
const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl = static const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl =
{ {
simplevolume_QueryInterface, simplevolume_QueryInterface,
simplevolume_AddRef, simplevolume_AddRef,
...@@ -553,7 +553,7 @@ const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl = ...@@ -553,7 +553,7 @@ const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl =
simplevolume_GetMute simplevolume_GetMute
}; };
void session_init_vols(struct audio_session *session, UINT channels) static void session_init_vols(struct audio_session *session, UINT channels)
{ {
if (session->channel_count < channels) { if (session->channel_count < channels) {
UINT i; UINT i;
...@@ -574,7 +574,7 @@ void session_init_vols(struct audio_session *session, UINT channels) ...@@ -574,7 +574,7 @@ void session_init_vols(struct audio_session *session, UINT channels)
} }
} }
struct audio_session *session_create(const GUID *guid, IMMDevice *device, UINT channels) static struct audio_session *session_create(const GUID *guid, IMMDevice *device, UINT channels)
{ {
struct audio_session *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, struct audio_session *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(struct audio_session)); sizeof(struct audio_session));
...@@ -618,3 +618,38 @@ struct audio_session_wrapper *session_wrapper_create(struct audio_client *client ...@@ -618,3 +618,38 @@ struct audio_session_wrapper *session_wrapper_create(struct audio_client *client
return ret; return ret;
} }
/* If channels == 0, then this will return or create a session with
* matching dataflow and GUID. Otherwise, channels must also match. */
HRESULT get_audio_session(const GUID *guid, IMMDevice *device, UINT channels,
struct audio_session **out)
{
struct audio_session *session;
TRACE("(%s, %p, %u, %p)\n", debugstr_guid(guid), device, channels, out);
if (!guid || IsEqualGUID(guid, &GUID_NULL)) {
*out = session_create(&GUID_NULL, device, channels);
if (!*out)
return E_OUTOFMEMORY;
return S_OK;
}
*out = NULL;
LIST_FOR_EACH_ENTRY(session, &sessions, struct audio_session, entry) {
if (session->device == device && IsEqualGUID(guid, &session->guid)) {
session_init_vols(session, channels);
*out = session;
break;
}
}
if (!*out) {
*out = session_create(guid, device, channels);
if (!*out)
return E_OUTOFMEMORY;
}
return S_OK;
}
...@@ -61,7 +61,6 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug = ...@@ -61,7 +61,6 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug =
0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") } 0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") }
}; };
static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 };
extern struct list sessions;
static WCHAR drv_key_devicesW[256]; static WCHAR drv_key_devicesW[256];
static const WCHAR guidW[] = {'g','u','i','d',0}; static const WCHAR guidW[] = {'g','u','i','d',0};
...@@ -69,12 +68,9 @@ static const WCHAR guidW[] = {'g','u','i','d',0}; ...@@ -69,12 +68,9 @@ static const WCHAR guidW[] = {'g','u','i','d',0};
extern const IAudioClient3Vtbl AudioClient3_Vtbl; extern const IAudioClient3Vtbl AudioClient3_Vtbl;
extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl; extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
extern const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl;
extern const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
extern const IAudioClockVtbl AudioClock_Vtbl; extern const IAudioClockVtbl AudioClock_Vtbl;
extern const IAudioClock2Vtbl AudioClock2_Vtbl; extern const IAudioClock2Vtbl AudioClock2_Vtbl;
extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
extern const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl;
extern struct audio_session_wrapper *session_wrapper_create( extern struct audio_session_wrapper *session_wrapper_create(
struct audio_client *client) DECLSPEC_HIDDEN; struct audio_client *client) DECLSPEC_HIDDEN;
...@@ -375,44 +371,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -375,44 +371,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
return S_OK; return S_OK;
} }
extern void session_init_vols(AudioSession *session, UINT channels);
extern AudioSession *session_create(const GUID *guid, IMMDevice *device,
UINT num_channels);
/* 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, extern HRESULT get_audio_session(const GUID *sessionguid,
IMMDevice *device, UINT channels, AudioSession **out) IMMDevice *device, UINT channels, AudioSession **out);
{
AudioSession *session;
if(!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)){
*out = session_create(&GUID_NULL, device, channels);
if(!*out)
return E_OUTOFMEMORY;
return S_OK;
}
*out = NULL;
LIST_FOR_EACH_ENTRY(session, &sessions, AudioSession, entry){
if(session->device == device &&
IsEqualGUID(sessionguid, &session->guid)){
session_init_vols(session, channels);
*out = session;
break;
}
}
if(!*out){
*out = session_create(sessionguid, device, channels);
if(!*out)
return E_OUTOFMEMORY;
}
return S_OK;
}
HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device, HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device,
AudioSessionWrapper **out) AudioSessionWrapper **out)
......
...@@ -51,12 +51,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(coreaudio); ...@@ -51,12 +51,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(coreaudio);
extern const IAudioClient3Vtbl AudioClient3_Vtbl; extern const IAudioClient3Vtbl AudioClient3_Vtbl;
extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl; extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
extern const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl;
extern const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
extern const IAudioClockVtbl AudioClock_Vtbl; extern const IAudioClockVtbl AudioClock_Vtbl;
extern const IAudioClock2Vtbl AudioClock2_Vtbl; extern const IAudioClock2Vtbl AudioClock2_Vtbl;
extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
extern const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl;
static WCHAR drv_key_devicesW[256]; static WCHAR drv_key_devicesW[256];
...@@ -68,7 +65,6 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug = ...@@ -68,7 +65,6 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug =
0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") } 0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") }
}; };
static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 };
extern struct list sessions;
extern struct audio_session_wrapper *session_wrapper_create( extern struct audio_session_wrapper *session_wrapper_create(
struct audio_client *client) DECLSPEC_HIDDEN; struct audio_client *client) DECLSPEC_HIDDEN;
...@@ -369,43 +365,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -369,43 +365,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
return S_OK; return S_OK;
} }
extern void session_init_vols(AudioSession *session, UINT channels);
extern AudioSession *session_create(const GUID *guid, IMMDevice *device,
UINT num_channels);
/* 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, extern HRESULT get_audio_session(const GUID *sessionguid,
IMMDevice *device, UINT channels, AudioSession **out) IMMDevice *device, UINT channels, AudioSession **out);
{
AudioSession *session;
if(!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)){
*out = session_create(&GUID_NULL, device, channels);
if(!*out)
return E_OUTOFMEMORY;
return S_OK;
}
*out = NULL;
LIST_FOR_EACH_ENTRY(session, &sessions, AudioSession, entry){
if(session->device == device &&
IsEqualGUID(sessionguid, &session->guid)){
session_init_vols(session, channels);
*out = session;
break;
}
}
if(!*out){
*out = session_create(sessionguid, device, channels);
if(!*out)
return E_OUTOFMEMORY;
}
return S_OK;
}
HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device, HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device,
AudioSessionWrapper **out) AudioSessionWrapper **out)
......
...@@ -70,17 +70,13 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug = ...@@ -70,17 +70,13 @@ static CRITICAL_SECTION_DEBUG g_sessions_lock_debug =
0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") } 0, 0, { (DWORD_PTR)(__FILE__ ": g_sessions_lock") }
}; };
static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION g_sessions_lock = { &g_sessions_lock_debug, -1, 0, 0, 0, 0 };
extern struct list sessions;
extern const IAudioClient3Vtbl AudioClient3_Vtbl; extern const IAudioClient3Vtbl AudioClient3_Vtbl;
extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl; extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
extern const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl;
extern const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
extern const IAudioClockVtbl AudioClock_Vtbl; extern const IAudioClockVtbl AudioClock_Vtbl;
extern const IAudioClock2Vtbl AudioClock2_Vtbl; extern const IAudioClock2Vtbl AudioClock2_Vtbl;
extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
extern const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl;
extern struct audio_session_wrapper *session_wrapper_create( extern struct audio_session_wrapper *session_wrapper_create(
struct audio_client *client) DECLSPEC_HIDDEN; struct audio_client *client) DECLSPEC_HIDDEN;
...@@ -359,43 +355,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, ...@@ -359,43 +355,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev,
return S_OK; return S_OK;
} }
extern void session_init_vols(AudioSession *session, UINT channels);
extern AudioSession *session_create(const GUID *guid, IMMDevice *device,
UINT num_channels);
/* 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, extern HRESULT get_audio_session(const GUID *sessionguid,
IMMDevice *device, UINT channels, AudioSession **out) IMMDevice *device, UINT channels, AudioSession **out);
{
AudioSession *session;
if(!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)){
*out = session_create(&GUID_NULL, device, channels);
if(!*out)
return E_OUTOFMEMORY;
return S_OK;
}
*out = NULL;
LIST_FOR_EACH_ENTRY(session, &sessions, AudioSession, entry){
if(session->device == device &&
IsEqualGUID(sessionguid, &session->guid)){
session_init_vols(session, channels);
*out = session;
break;
}
}
if(!*out){
*out = session_create(sessionguid, device, channels);
if(!*out)
return E_OUTOFMEMORY;
}
return S_OK;
}
HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device, HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device,
AudioSessionWrapper **out) AudioSessionWrapper **out)
......
...@@ -56,7 +56,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(pulse); ...@@ -56,7 +56,6 @@ 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)
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 {
...@@ -121,9 +120,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) ...@@ -121,9 +120,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
extern const IAudioClient3Vtbl AudioClient3_Vtbl; extern const IAudioClient3Vtbl AudioClient3_Vtbl;
extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl; extern const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; extern const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
extern const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl;
extern const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
extern const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl;
extern const IAudioClockVtbl AudioClock_Vtbl; extern const IAudioClockVtbl AudioClock_Vtbl;
extern const IAudioClock2Vtbl AudioClock2_Vtbl; extern const IAudioClock2Vtbl AudioClock2_Vtbl;
extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
...@@ -399,43 +395,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -399,43 +395,10 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
return S_OK; return S_OK;
} }
extern void session_init_vols(AudioSession *session, UINT channels);
extern AudioSession *session_create(const GUID *guid, IMMDevice *device,
UINT num_channels);
/* 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, extern HRESULT get_audio_session(const GUID *sessionguid,
IMMDevice *device, UINT channels, AudioSession **out) IMMDevice *device, UINT channels, AudioSession **out);
{
AudioSession *session;
if (!sessionguid || IsEqualGUID(sessionguid, &GUID_NULL)) {
*out = session_create(&GUID_NULL, device, channels);
if (!*out)
return E_OUTOFMEMORY;
return S_OK;
}
*out = NULL;
LIST_FOR_EACH_ENTRY(session, &sessions, AudioSession, entry) {
if (session->device == device &&
IsEqualGUID(sessionguid, &session->guid)) {
session_init_vols(session, channels);
*out = session;
break;
}
}
if (!*out) {
*out = session_create(sessionguid, device, channels);
if (!*out)
return E_OUTOFMEMORY;
}
return S_OK;
}
HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device, HRESULT WINAPI AUDDRV_GetAudioSessionWrapper(const GUID *guid, IMMDevice *device,
AudioSessionWrapper **out) AudioSessionWrapper **out)
......
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