From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/mmdevdrv.h | 79 ++++++++++++++++++++++++++++++++++++ dlls/winealsa.drv/mmdevdrv.c | 77 ++++------------------------------- 2 files changed, 86 insertions(+), 70 deletions(-) create mode 100644 dlls/mmdevapi/mmdevdrv.h
diff --git a/dlls/mmdevapi/mmdevdrv.h b/dlls/mmdevapi/mmdevdrv.h new file mode 100644 index 00000000000..27b6e9d9abf --- /dev/null +++ b/dlls/mmdevapi/mmdevdrv.h @@ -0,0 +1,79 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +typedef struct ACImpl ACImpl; + +typedef struct AudioSession { + GUID guid; + struct list clients; + + IMMDevice *device; + + float master_vol; + UINT32 channel_count; + float *channel_vols; + BOOL mute; + + struct list entry; +} AudioSession; + +typedef struct AudioSessionWrapper { + IAudioSessionControl2 IAudioSessionControl2_iface; + IChannelAudioVolume IChannelAudioVolume_iface; + ISimpleAudioVolume ISimpleAudioVolume_iface; + + LONG ref; + + ACImpl *client; + AudioSession *session; +} AudioSessionWrapper; + +typedef struct SessionMgr { + IAudioSessionManager2 IAudioSessionManager2_iface; + + LONG ref; + + IMMDevice *device; +} SessionMgr; + +struct ACImpl { + IAudioClient3 IAudioClient3_iface; + IAudioRenderClient IAudioRenderClient_iface; + IAudioCaptureClient IAudioCaptureClient_iface; + IAudioClock IAudioClock_iface; + IAudioClock2 IAudioClock2_iface; + IAudioStreamVolume IAudioStreamVolume_iface; + + LONG ref; + + IMMDevice *parent; + IUnknown *pUnkFTMarshal; + + EDataFlow dataflow; + float *vols; + UINT32 channel_count; + stream_handle stream; + + HANDLE timer_thread; + + AudioSession *session; + AudioSessionWrapper *session_wrapper; + + struct list entry; + + /* Keep at end */ + char device_name[0]; +}; diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 96a0a62d72e..de0886b6f0b 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -47,6 +47,8 @@
#include "unixlib.h"
+#include "../mmdevapi/mmdevdrv.h" + WINE_DEFAULT_DEBUG_CHANNEL(alsa);
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER) @@ -54,71 +56,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(alsa); static const REFERENCE_TIME DefaultPeriod = 100000; static const REFERENCE_TIME MinimumPeriod = 50000;
-struct ACImpl; -typedef struct ACImpl ACImpl; - -typedef struct _AudioSession { - GUID guid; - struct list clients; - - IMMDevice *device; - - float master_vol; - UINT32 channel_count; - float *channel_vols; - BOOL mute; - - struct list entry; -} AudioSession; - -typedef struct _AudioSessionWrapper { - IAudioSessionControl2 IAudioSessionControl2_iface; - IChannelAudioVolume IChannelAudioVolume_iface; - ISimpleAudioVolume ISimpleAudioVolume_iface; - - LONG ref; - - ACImpl *client; - AudioSession *session; -} AudioSessionWrapper; - -struct ACImpl { - IAudioClient3 IAudioClient3_iface; - IAudioRenderClient IAudioRenderClient_iface; - IAudioCaptureClient IAudioCaptureClient_iface; - IAudioClock IAudioClock_iface; - IAudioClock2 IAudioClock2_iface; - IAudioStreamVolume IAudioStreamVolume_iface; - - LONG ref; - - IMMDevice *parent; - IUnknown *pUnkFTMarshal; - - EDataFlow dataflow; - float *vols; - UINT32 channel_count; - stream_handle stream; - - HANDLE timer_thread; - - AudioSession *session; - AudioSessionWrapper *session_wrapper; - - struct list entry; - - /* Keep at end */ - char alsa_name[1]; -}; - -typedef struct _SessionMgr { - IAudioSessionManager2 IAudioSessionManager2_iface; - - LONG ref; - - IMMDevice *device; -} SessionMgr; - static CRITICAL_SECTION g_sessions_lock; static CRITICAL_SECTION_DEBUG g_sessions_lock_debug = { @@ -474,7 +411,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient return E_UNEXPECTED;
len = strlen(alsa_name); - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, offsetof(ACImpl, alsa_name[len + 1])); + This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, offsetof(ACImpl, device_name[len + 1])); if(!This) return E_OUTOFMEMORY;
@@ -492,7 +429,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient }
This->dataflow = dataflow; - memcpy(This->alsa_name, alsa_name, len + 1); + memcpy(This->device_name, alsa_name, len + 1);
This->parent = dev; IMMDevice_AddRef(This->parent); @@ -745,7 +682,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, dump_fmt(fmt);
params.name = NULL; - params.device = This->alsa_name; + params.device = This->device_name; params.flow = This->dataflow; params.share = mode; params.flags = flags; @@ -870,7 +807,7 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient3 *iface, TRACE("(%p)->(%x, %p, %p)\n", This, mode, fmt, out); if(fmt) dump_fmt(fmt);
- params.device = This->alsa_name; + params.device = This->device_name; params.flow = This->dataflow; params.share = mode; params.fmt_in = fmt; @@ -903,7 +840,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient3 *iface, return E_POINTER; *pwfx = NULL;
- params.device = This->alsa_name; + params.device = This->device_name; params.flow = This->dataflow; params.fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE)); if(!params.fmt)