Commit 8e13b4bd authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winealsa: Explicitly store the name and channel count in the audio client.

parent 4f54f459
...@@ -119,6 +119,7 @@ struct ACImpl { ...@@ -119,6 +119,7 @@ struct ACImpl {
AUDCLNT_SHAREMODE share; AUDCLNT_SHAREMODE share;
HANDLE event; HANDLE event;
float *vols; float *vols;
UINT32 channel_count;
BOOL need_remapping; BOOL need_remapping;
int alsa_channels; int alsa_channels;
...@@ -145,6 +146,9 @@ struct ACImpl { ...@@ -145,6 +146,9 @@ struct ACImpl {
AudioSessionWrapper *session_wrapper; AudioSessionWrapper *session_wrapper;
struct list entry; struct list entry;
/* Keep at end */
char alsa_name[1];
}; };
typedef struct _SessionMgr { typedef struct _SessionMgr {
...@@ -472,6 +476,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -472,6 +476,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
char alsa_name[256]; char alsa_name[256];
EDataFlow dataflow; EDataFlow dataflow;
HRESULT hr; HRESULT hr;
int len;
TRACE("%s %p %p\n", debugstr_guid(guid), dev, out); TRACE("%s %p %p\n", debugstr_guid(guid), dev, out);
...@@ -481,7 +486,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -481,7 +486,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
if(dataflow != eRender && dataflow != eCapture) if(dataflow != eRender && dataflow != eCapture)
return E_UNEXPECTED; return E_UNEXPECTED;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ACImpl)); len = strlen(alsa_name);
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, offsetof(ACImpl, alsa_name[len + 1]));
if(!This) if(!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -499,6 +505,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient ...@@ -499,6 +505,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
} }
This->dataflow = dataflow; This->dataflow = dataflow;
memcpy(This->alsa_name, alsa_name, len + 1);
err = snd_pcm_open(&This->pcm_handle, alsa_name, alsa_get_direction(dataflow), SND_PCM_NONBLOCK); err = snd_pcm_open(&This->pcm_handle, alsa_name, alsa_get_direction(dataflow), SND_PCM_NONBLOCK);
if(err < 0){ if(err < 0){
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
...@@ -1159,19 +1167,20 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, ...@@ -1159,19 +1167,20 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
} }
silence_buffer(This, This->silence_buf, This->alsa_period_frames); silence_buffer(This, This->silence_buf, This->alsa_period_frames);
This->vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float)); This->channel_count = fmt->nChannels;
This->vols = HeapAlloc(GetProcessHeap(), 0, This->channel_count * sizeof(float));
if(!This->vols){ if(!This->vols){
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
goto exit; goto exit;
} }
for(i = 0; i < fmt->nChannels; ++i) for(i = 0; i < This->channel_count; ++i)
This->vols[i] = 1.f; This->vols[i] = 1.f;
This->share = mode; This->share = mode;
This->flags = flags; This->flags = flags;
hr = get_audio_session(sessionguid, This->parent, fmt->nChannels, hr = get_audio_session(sessionguid, This->parent, This->channel_count,
&This->session); &This->session);
if(FAILED(hr)) if(FAILED(hr))
goto exit; goto exit;
...@@ -3385,7 +3394,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelCount( ...@@ -3385,7 +3394,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelCount(
if(!out) if(!out)
return E_POINTER; return E_POINTER;
*out = This->fmt->nChannels; *out = This->channel_count;
return S_OK; return S_OK;
} }
...@@ -3400,7 +3409,7 @@ static HRESULT WINAPI AudioStreamVolume_SetChannelVolume( ...@@ -3400,7 +3409,7 @@ static HRESULT WINAPI AudioStreamVolume_SetChannelVolume(
if(level < 0.f || level > 1.f) if(level < 0.f || level > 1.f)
return E_INVALIDARG; return E_INVALIDARG;
if(index >= This->fmt->nChannels) if(index >= This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
TRACE("ALSA does not support volume control\n"); TRACE("ALSA does not support volume control\n");
...@@ -3424,7 +3433,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume( ...@@ -3424,7 +3433,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume(
if(!level) if(!level)
return E_POINTER; return E_POINTER;
if(index >= This->fmt->nChannels) if(index >= This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
*level = This->vols[index]; *level = This->vols[index];
...@@ -3443,7 +3452,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes( ...@@ -3443,7 +3452,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
if(!levels) if(!levels)
return E_POINTER; return E_POINTER;
if(count != This->fmt->nChannels) if(count != This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
TRACE("ALSA does not support volume control\n"); TRACE("ALSA does not support volume control\n");
...@@ -3469,7 +3478,7 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes( ...@@ -3469,7 +3478,7 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes(
if(!levels) if(!levels)
return E_POINTER; return E_POINTER;
if(count != This->fmt->nChannels) if(count != This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
......
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