Commit d67a211c authored by Davide Beatrici's avatar Davide Beatrici Committed by Alexandre Julliard

winealsa: Move common mmdevdrv structs into mmdevapi.

parent 061dc3a4
/*
* 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 audio_client ACImpl;
typedef struct audio_session {
GUID guid;
struct list clients;
IMMDevice *device;
float master_vol;
UINT32 channel_count;
float *channel_vols;
BOOL mute;
struct list entry;
} AudioSession;
typedef struct audio_session_wrapper {
IAudioSessionControl2 IAudioSessionControl2_iface;
IChannelAudioVolume IChannelAudioVolume_iface;
ISimpleAudioVolume ISimpleAudioVolume_iface;
LONG ref;
struct audio_client *client;
struct audio_session *session;
} AudioSessionWrapper;
typedef struct session_mgr {
IAudioSessionManager2 IAudioSessionManager2_iface;
LONG ref;
IMMDevice *device;
} SessionMgr;
struct audio_client {
IAudioClient3 IAudioClient3_iface;
IAudioRenderClient IAudioRenderClient_iface;
IAudioCaptureClient IAudioCaptureClient_iface;
IAudioClock IAudioClock_iface;
IAudioClock2 IAudioClock2_iface;
IAudioStreamVolume IAudioStreamVolume_iface;
LONG ref;
IMMDevice *parent;
IUnknown *marshal;
EDataFlow dataflow;
float *vols;
UINT32 channel_count;
stream_handle stream;
HANDLE timer_thread;
struct audio_session *session;
struct audio_session_wrapper *session_wrapper;
struct list entry;
/* Keep at end */
char device_name[0];
};
......@@ -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 =
{
......@@ -239,7 +176,7 @@ static HRESULT alsa_stream_release(stream_handle stream, HANDLE timer_thread)
static DWORD WINAPI alsa_timer_thread(void *user)
{
struct timer_loop_params params;
struct ACImpl *This = user;
ACImpl *This = user;
SetThreadDescription(GetCurrentThread(), L"winealsa_timer");
......@@ -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;
......@@ -485,14 +422,14 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
This->IAudioClock2_iface.lpVtbl = &AudioClock2_Vtbl;
This->IAudioStreamVolume_iface.lpVtbl = &AudioStreamVolume_Vtbl;
hr = CoCreateFreeThreadedMarshaler((IUnknown *)&This->IAudioClient3_iface, &This->pUnkFTMarshal);
hr = CoCreateFreeThreadedMarshaler((IUnknown *)&This->IAudioClient3_iface, &This->marshal);
if (FAILED(hr)) {
HeapFree(GetProcessHeap(), 0, This);
return hr;
}
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);
......@@ -518,7 +455,7 @@ static HRESULT WINAPI AudioClient_QueryInterface(IAudioClient3 *iface,
IsEqualIID(riid, &IID_IAudioClient3))
*ppv = iface;
else if(IsEqualIID(riid, &IID_IMarshal))
return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
return IUnknown_QueryInterface(This->marshal, riid, ppv);
if(*ppv){
IUnknown_AddRef((IUnknown*)*ppv);
......@@ -547,7 +484,7 @@ static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface)
if(!ref){
IAudioClient3_Stop(iface);
IMMDevice_Release(This->parent);
IUnknown_Release(This->pUnkFTMarshal);
IUnknown_Release(This->marshal);
if(This->session){
EnterCriticalSection(&g_sessions_lock);
list_remove(&This->entry);
......@@ -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)
......@@ -1236,7 +1173,7 @@ static HRESULT WINAPI AudioRenderClient_QueryInterface(
IsEqualIID(riid, &IID_IAudioRenderClient))
*ppv = iface;
else if(IsEqualIID(riid, &IID_IMarshal))
return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
return IUnknown_QueryInterface(This->marshal, riid, ppv);
if(*ppv){
IUnknown_AddRef((IUnknown*)*ppv);
......@@ -1319,7 +1256,7 @@ static HRESULT WINAPI AudioCaptureClient_QueryInterface(
IsEqualIID(riid, &IID_IAudioCaptureClient))
*ppv = iface;
else if(IsEqualIID(riid, &IID_IMarshal))
return IUnknown_QueryInterface(This->pUnkFTMarshal, riid, ppv);
return IUnknown_QueryInterface(This->marshal, riid, ppv);
if(*ppv){
IUnknown_AddRef((IUnknown*)*ppv);
......
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