Commit afdaf649 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Store the channel count and period_ms directly in the audio client.

parent 8e90b256
...@@ -124,6 +124,7 @@ struct ACImpl { ...@@ -124,6 +124,7 @@ struct ACImpl {
IUnknown *pUnkFTMarshal; IUnknown *pUnkFTMarshal;
EDataFlow dataflow; EDataFlow dataflow;
UINT32 channel_count, period_ms;
DWORD flags; DWORD flags;
HANDLE event; HANDLE event;
float *vols; float *vols;
...@@ -1179,7 +1180,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, ...@@ -1179,7 +1180,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
ACImpl *This = impl_from_IAudioClient3(iface); ACImpl *This = impl_from_IAudioClient3(iface);
HRESULT hr; HRESULT hr;
OSStatus sc; OSStatus sc;
int i; UINT32 i;
TRACE("(%p)->(%x, %x, %s, %s, %p, %s)\n", This, mode, flags, TRACE("(%p)->(%x, %x, %s, %s, %p, %s)\n", This, mode, flags,
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(period), fmt, debugstr_guid(sessionguid)); wine_dbgstr_longlong(duration), wine_dbgstr_longlong(period), fmt, debugstr_guid(sessionguid));
...@@ -1342,7 +1343,12 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, ...@@ -1342,7 +1343,12 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
This->stream->cap_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->cap_bufsize_frames * This->stream->fmt->nBlockAlign); This->stream->cap_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->cap_bufsize_frames * This->stream->fmt->nBlockAlign);
} }
This->vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float)); This->stream->share = mode;
This->flags = flags;
This->channel_count = fmt->nChannels;
This->period_ms = period / 10000;
This->vols = HeapAlloc(GetProcessHeap(), 0, This->channel_count * sizeof(float));
if(!This->vols){ if(!This->vols){
CoTaskMemFree(This->stream->fmt); CoTaskMemFree(This->stream->fmt);
This->stream->fmt = NULL; This->stream->fmt = NULL;
...@@ -1351,12 +1357,9 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, ...@@ -1351,12 +1357,9 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
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->stream->share = mode;
This->flags = flags;
hr = get_audio_session(sessionguid, This->parent, fmt->nChannels, hr = get_audio_session(sessionguid, This->parent, fmt->nChannels,
&This->session); &This->session);
if(FAILED(hr)){ if(FAILED(hr)){
...@@ -1906,7 +1909,7 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface) ...@@ -1906,7 +1909,7 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
if(This->event && !This->timer) if(This->event && !This->timer)
if(!CreateTimerQueueTimer(&This->timer, g_timer_q, ca_period_cb, if(!CreateTimerQueueTimer(&This->timer, g_timer_q, ca_period_cb,
This, 0, This->stream->period_ms, WT_EXECUTEINTIMERTHREAD)){ This, 0, This->period_ms, WT_EXECUTEINTIMERTHREAD)){
This->timer = NULL; This->timer = NULL;
OSSpinLockUnlock(&This->stream->lock); OSSpinLockUnlock(&This->stream->lock);
WARN("Unable to create timer: %u\n", GetLastError()); WARN("Unable to create timer: %u\n", GetLastError());
...@@ -3173,7 +3176,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelCount( ...@@ -3173,7 +3176,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelCount(
if(!out) if(!out)
return E_POINTER; return E_POINTER;
*out = This->stream->fmt->nChannels; *out = This->channel_count;
return S_OK; return S_OK;
} }
...@@ -3189,7 +3192,7 @@ static HRESULT WINAPI AudioStreamVolume_SetChannelVolume( ...@@ -3189,7 +3192,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->stream->fmt->nChannels) if(index >= This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&g_sessions_lock); EnterCriticalSection(&g_sessions_lock);
...@@ -3214,7 +3217,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume( ...@@ -3214,7 +3217,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume(
if(!level) if(!level)
return E_POINTER; return E_POINTER;
if(index >= This->stream->fmt->nChannels) if(index >= This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
*level = This->vols[index]; *level = This->vols[index];
...@@ -3234,7 +3237,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes( ...@@ -3234,7 +3237,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
if(!levels) if(!levels)
return E_POINTER; return E_POINTER;
if(count != This->stream->fmt->nChannels) if(count != This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&g_sessions_lock); EnterCriticalSection(&g_sessions_lock);
...@@ -3260,7 +3263,7 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes( ...@@ -3260,7 +3263,7 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes(
if(!levels) if(!levels)
return E_POINTER; return E_POINTER;
if(count != This->stream->fmt->nChannels) if(count != This->channel_count)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&g_sessions_lock); EnterCriticalSection(&g_sessions_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