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)
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winecoreaudio.drv/mmdevdrv.c | 74 +++---------------------------- 1 file changed, 6 insertions(+), 68 deletions(-)
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 97492440535..a0d20f704ca 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -42,6 +42,8 @@ #include "audiopolicy.h" #include "unixlib.h"
+#include "../mmdevapi/mmdevdrv.h" + WINE_DEFAULT_DEBUG_CHANNEL(coreaudio);
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER) @@ -49,62 +51,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(coreaudio); 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; - UINT32 channel_count; - float *vols; - - HANDLE timer; - - AudioSession *session; - AudioSessionWrapper *session_wrapper; - - stream_handle stream; - struct list entry; - - char device_name[1]; -}; - static const IAudioClient3Vtbl AudioClient3_Vtbl; static const IAudioRenderClientVtbl AudioRenderClient_Vtbl; static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; @@ -116,14 +62,6 @@ static const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; static const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl; static const IAudioSessionManager2Vtbl AudioSessionManager2_Vtbl;
-typedef struct _SessionMgr { - IAudioSessionManager2 IAudioSessionManager2_iface; - - LONG ref; - - IMMDevice *device; -} SessionMgr; - static WCHAR drv_key_devicesW[256];
static CRITICAL_SECTION g_sessions_lock; @@ -516,7 +454,7 @@ static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface) if(This->stream){ struct release_stream_params params; params.stream = This->stream; - params.timer_thread = This->timer; + params.timer_thread = This->timer_thread; UNIX_CALL(release_stream, ¶ms); This->stream = 0;
@@ -929,9 +867,9 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface) if(FAILED(hr = params.result)) return hr;
- if(!This->timer) { - This->timer = CreateThread(NULL, 0, ca_timer_thread, This, 0, NULL); - SetThreadPriority(This->timer, THREAD_PRIORITY_TIME_CRITICAL); + if(!This->timer_thread) { + This->timer_thread = CreateThread(NULL, 0, ca_timer_thread, This, 0, NULL); + SetThreadPriority(This->timer_thread, THREAD_PRIORITY_TIME_CRITICAL); }
return S_OK;
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/wineoss.drv/mmdevdrv.c | 77 ++++--------------------------------- 1 file changed, 7 insertions(+), 70 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 166f9408416..e22554b1ba0 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -44,6 +44,8 @@
#include "unixlib.h"
+#include "../mmdevapi/mmdevdrv.h" + WINE_DEFAULT_DEBUG_CHANNEL(oss);
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER) @@ -51,71 +53,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(oss); 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 devnode[0]; -}; - -typedef struct _SessionMgr { - IAudioSessionManager2 IAudioSessionManager2_iface; - - LONG ref; - - IMMDevice *device; -} SessionMgr; - typedef struct _OSSDevice { struct list entry; EDataFlow flow; @@ -447,7 +384,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, return AUDCLNT_E_DEVICE_INVALIDATED; } len = strlen(oss_dev->devnode); - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, offsetof(ACImpl, devnode[len + 1])); + This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, offsetof(ACImpl, device_name[len + 1])); if(!This) return E_OUTOFMEMORY;
@@ -458,7 +395,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, }
This->dataflow = oss_dev->flow; - strcpy(This->devnode, oss_dev->devnode); + strcpy(This->device_name, oss_dev->devnode);
This->IAudioClient3_iface.lpVtbl = &AudioClient3_Vtbl; This->IAudioRenderClient_iface.lpVtbl = &AudioRenderClient_Vtbl; @@ -711,7 +648,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, }
params.name = NULL; - params.device = This->devnode; + params.device = This->device_name; params.flow = This->dataflow; params.share = mode; params.flags = flags; @@ -831,7 +768,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->devnode; + params.device = This->device_name; params.flow = This->dataflow; params.share = mode; params.fmt_in = fmt; @@ -864,7 +801,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient3 *iface, return E_POINTER; *pwfx = NULL;
- params.device = This->devnode; + params.device = This->device_name; params.flow = This->dataflow; params.fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE)); if(!params.fmt)
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winepulse.drv/mmdevdrv.c | 197 ++++++++++++---------------------- 1 file changed, 69 insertions(+), 128 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 0ad17edf2ef..05239e7ed49 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -48,6 +48,7 @@ #include "audiopolicy.h"
#include "../mmdevapi/unixlib.h" +#include "../mmdevapi/mmdevdrv.h"
WINE_DEFAULT_DEBUG_CHANNEL(pulse);
@@ -113,58 +114,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-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; - IUnknown *marshal; - IMMDevice *parent; - struct list entry; - float *vol; - - LONG ref; - EDataFlow dataflow; - UINT32 channel_count; - HANDLE timer; - - stream_handle pulse_stream; - - AudioSession *session; - AudioSessionWrapper *session_wrapper; - - char pulse_name[0]; -}; - static const IAudioClient3Vtbl AudioClient3_Vtbl; static const IAudioRenderClientVtbl AudioRenderClient_Vtbl; static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl; @@ -354,7 +303,7 @@ static DWORD WINAPI pulse_timer_cb(void *user) { struct timer_loop_params params; ACImpl *This = user; - params.stream = This->pulse_stream; + params.stream = This->stream; SetThreadDescription(GetCurrentThread(), L"winepulse_timer_loop"); pulse_call(timer_loop, ¶ms); return 0; @@ -363,9 +312,9 @@ static DWORD WINAPI pulse_timer_cb(void *user) static void set_stream_volumes(ACImpl *This) { struct set_volumes_params params; - params.stream = This->pulse_stream; + params.stream = This->stream; params.master_volume = This->session->mute ? 0.0f : This->session->master_vol; - params.volumes = This->vol; + params.volumes = This->vols; params.session_volumes = This->session->channel_vols; params.channel = 0; pulse_call(set_volumes, ¶ms); @@ -578,7 +527,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient *out = NULL;
len = strlen(pulse_name) + 1; - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(ACImpl, pulse_name[len])); + This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(ACImpl, device_name[len])); if (!This) return E_OUTOFMEMORY;
@@ -590,9 +539,9 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient This->IAudioStreamVolume_iface.lpVtbl = &AudioStreamVolume_Vtbl; This->dataflow = dataflow; This->parent = dev; - memcpy(This->pulse_name, pulse_name, len); + memcpy(This->device_name, pulse_name, len);
- hr = CoCreateFreeThreadedMarshaler((IUnknown*)&This->IAudioClient3_iface, &This->marshal); + hr = CoCreateFreeThreadedMarshaler((IUnknown*)&This->IAudioClient3_iface, &This->pUnkFTMarshal); if (FAILED(hr)) { HeapFree(GetProcessHeap(), 0, This); return hr; @@ -627,7 +576,7 @@ static HRESULT WINAPI AudioClient_QueryInterface(IAudioClient3 *iface, }
if (IsEqualIID(riid, &IID_IMarshal)) - return IUnknown_QueryInterface(This->marshal, riid, ppv); + return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
WARN("Unknown interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -649,14 +598,14 @@ static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface) ref = InterlockedDecrement(&This->ref); TRACE("(%p) Refcount now %lu\n", This, ref); if (!ref) { - if (This->pulse_stream) { - pulse_release_stream(This->pulse_stream, This->timer); - This->pulse_stream = 0; + if (This->stream) { + pulse_release_stream(This->stream, This->timer_thread); + This->stream = 0; EnterCriticalSection(&session_cs); list_remove(&This->entry); LeaveCriticalSection(&session_cs); } - IUnknown_Release(This->marshal); + IUnknown_Release(This->pUnkFTMarshal); IMMDevice_Release(This->parent); HeapFree(GetProcessHeap(), 0, This); } @@ -837,7 +786,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
EnterCriticalSection(&session_cs);
- if (This->pulse_stream) { + if (This->stream) { LeaveCriticalSection(&session_cs); return AUDCLNT_E_ALREADY_INITIALIZED; } @@ -858,7 +807,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, }
params.name = name = get_application_name(TRUE); - params.device = This->pulse_name; + params.device = This->device_name; params.flow = This->dataflow; params.share = mode; params.flags = flags; @@ -875,26 +824,26 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, return hr; }
- if (!(This->vol = malloc(channel_count * sizeof(*This->vol)))) + if (!(This->vols= malloc(channel_count * sizeof(*This->vols)))) { pulse_release_stream(stream, NULL); LeaveCriticalSection(&session_cs); return E_OUTOFMEMORY; } for (i = 0; i < channel_count; i++) - This->vol[i] = 1.f; + This->vols[i] = 1.f;
hr = get_audio_session(sessionguid, This->parent, channel_count, &This->session); if (FAILED(hr)) { - free(This->vol); - This->vol = NULL; + free(This->vols); + This->vols= NULL; LeaveCriticalSection(&session_cs); pulse_release_stream(stream, NULL); return E_OUTOFMEMORY; }
- This->pulse_stream = stream; + This->stream = stream; This->channel_count = channel_count; list_add_tail(&This->session->clients, &This->entry); set_stream_volumes(This); @@ -913,10 +862,10 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
if (!out) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.frames = out; pulse_call(get_buffer_size, ¶ms); return params.result; @@ -932,10 +881,10 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
if (!latency) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.latency = latency; pulse_call(get_latency, ¶ms); return params.result; @@ -951,10 +900,10 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface,
if (!out) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.padding = out; pulse_call(get_current_padding, ¶ms); return params.result; @@ -1125,7 +1074,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient3 *iface, return E_POINTER; *pwfx = NULL;
- params.device = This->pulse_name; + params.device = This->device_name; params.flow = This->dataflow; params.fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE)); if (!params.fmt) @@ -1155,7 +1104,7 @@ static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface, return E_POINTER;
params.flow = This->dataflow; - params.device = This->pulse_name; + params.device = This->device_name; params.def_period = defperiod; params.min_period = minperiod;
@@ -1172,17 +1121,17 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; pulse_call(start, ¶ms); if (FAILED(hr = params.result)) return hr;
- if (!This->timer) { - This->timer = CreateThread(NULL, 0, pulse_timer_cb, This, 0, NULL); - SetThreadPriority(This->timer, THREAD_PRIORITY_TIME_CRITICAL); + if (!This->timer_thread) { + This->timer_thread = CreateThread(NULL, 0, pulse_timer_cb, This, 0, NULL); + SetThreadPriority(This->timer_thread, THREAD_PRIORITY_TIME_CRITICAL); }
return S_OK; @@ -1195,10 +1144,10 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; pulse_call(stop, ¶ms); return params.result; } @@ -1210,10 +1159,10 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; pulse_call(reset, ¶ms); return params.result; } @@ -1228,10 +1177,10 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface,
if (!event) return E_INVALIDARG; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.event = event; pulse_call(set_event_handle, ¶ms); return params.result; @@ -1248,7 +1197,7 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid, return E_POINTER; *ppv = NULL;
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
if (IsEqualIID(riid, &IID_IAudioRenderClient)) { @@ -1423,7 +1372,7 @@ static HRESULT WINAPI AudioRenderClient_QueryInterface( }
if (IsEqualIID(riid, &IID_IMarshal)) - return IUnknown_QueryInterface(This->marshal, riid, ppv); + return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
WARN("Unknown interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -1451,11 +1400,11 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
if (!data) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED; *data = NULL;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.frames = frames; params.data = data; pulse_call(get_render_buffer, ¶ms); @@ -1470,10 +1419,10 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
TRACE("(%p)->(%u, %lx)\n", This, written_frames, flags);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.written_frames = written_frames; params.flags = flags; pulse_call(release_render_buffer, ¶ms); @@ -1507,7 +1456,7 @@ static HRESULT WINAPI AudioCaptureClient_QueryInterface( }
if (IsEqualIID(riid, &IID_IMarshal)) - return IUnknown_QueryInterface(This->marshal, riid, ppv); + return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
WARN("Unknown interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -1540,10 +1489,10 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, *data = NULL; if (!frames || !flags) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.data = data; params.frames = frames; params.flags = (UINT*)flags; @@ -1561,10 +1510,10 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
TRACE("(%p)->(%u)\n", This, done);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.done = done; pulse_call(release_capture_buffer, ¶ms); return params.result; @@ -1580,10 +1529,10 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
if (!frames) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.frames = frames; pulse_call(get_next_packet_size, ¶ms); return params.result; @@ -1620,7 +1569,7 @@ static HRESULT WINAPI AudioClock_QueryInterface(IAudioClock *iface, }
if (IsEqualIID(riid, &IID_IMarshal)) - return IUnknown_QueryInterface(This->marshal, riid, ppv); + return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
WARN("Unknown interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -1645,10 +1594,10 @@ static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq)
TRACE("(%p)->(%p)\n", This, freq);
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.freq = freq; pulse_call(get_frequency, ¶ms); return params.result; @@ -1664,10 +1613,10 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
if (!pos) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.device = FALSE; params.pos = pos; params.qpctime = qpctime; @@ -1729,10 +1678,10 @@ static HRESULT WINAPI AudioClock2_GetDevicePosition(IAudioClock2 *iface,
if (!pos) return E_POINTER; - if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- params.stream = This->pulse_stream; + params.stream = This->stream; params.device = TRUE; params.pos = pos; params.qpctime = qpctime; @@ -1768,7 +1717,7 @@ static HRESULT WINAPI AudioStreamVolume_QueryInterface( }
if (IsEqualIID(riid, &IID_IMarshal)) - return IUnknown_QueryInterface(This->marshal, riid, ppv); + return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
WARN("Unknown interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -1817,14 +1766,14 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes( if (!levels) return E_POINTER;
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED; if (count != This->channel_count) return E_INVALIDARG;
EnterCriticalSection(&session_cs); for (i = 0; i < count; ++i) - This->vol[i] = levels[i]; + This->vols[i] = levels[i];
set_stream_volumes(This); LeaveCriticalSection(&session_cs); @@ -1842,14 +1791,14 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes( if (!levels) return E_POINTER;
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED; if (count != This->channel_count) return E_INVALIDARG;
EnterCriticalSection(&session_cs); for (i = 0; i < count; ++i) - levels[i] = This->vol[i]; + levels[i] = This->vols[i]; LeaveCriticalSection(&session_cs); return S_OK; } @@ -1864,13 +1813,13 @@ static HRESULT WINAPI AudioStreamVolume_SetChannelVolume( if (level < 0.f || level > 1.f) return E_INVALIDARG;
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED; if (index >= This->channel_count) return E_INVALIDARG;
EnterCriticalSection(&session_cs); - This->vol[index] = level; + This->vols[index] = level; set_stream_volumes(This); LeaveCriticalSection(&session_cs); return S_OK; @@ -1886,13 +1835,13 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume( if (!level) return E_POINTER;
- if (!This->pulse_stream) + if (!This->stream) return AUDCLNT_E_NOT_INITIALIZED; if (index >= This->channel_count) return E_INVALIDARG;
EnterCriticalSection(&session_cs); - *level = This->vol[index]; + *level = This->vols[index]; LeaveCriticalSection(&session_cs); return S_OK; } @@ -1999,10 +1948,10 @@ static HRESULT WINAPI AudioSessionControl_GetState(IAudioSessionControl2 *iface, LIST_FOR_EACH_ENTRY(client, &This->session->clients, ACImpl, entry) { struct is_started_params params;
- if (!client->pulse_stream) + if (!client->stream) continue;
- params.stream = client->pulse_stream; + params.stream = client->stream; pulse_call(is_started, ¶ms); if (params.result == S_OK) { *state = AudioSessionStateActive; @@ -2173,14 +2122,6 @@ static const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl = AudioSessionControl_SetDuckingPreference };
-typedef struct _SessionMgr { - IAudioSessionManager2 IAudioSessionManager2_iface; - - LONG ref; - - IMMDevice *device; -} SessionMgr; - static HRESULT WINAPI AudioSessionManager_QueryInterface(IAudioSessionManager2 *iface, REFIID riid, void **ppv) {
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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;
It would nice to start using structure tags that aren't CamelCase and eventually ditch the typedefs.
```suggestion:-0+0 typedef struct audio_client ACImpl; ``` This will allow existing code to use `ACImpl`, but as you move code to mmdevapi it could transistion to `struct audio_client`.
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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 {
```suggestion:-0+0 typedef struct audio_session { ```
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
+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 {
```suggestion:-0+0 typedef struct audio_session_wrapper { ```
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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;
```suggestion:-1+0 struct audio_client *client; struct audio_session *session; ```
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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 {
```suggestion:-0+0 typedef struct session_mgr { ```
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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;
```suggestion:-0+0 IUnknown *marshal; ``` Let's call this one `marshal` like it is in the pulse driver.
Huw Davies (@huw) commented about dlls/mmdevapi/mmdevdrv.h:
- 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;
```suggestion:-1+0 struct audio_session *session; struct audio_session_wrapper *session_wrapper; ```