Commit 9572b5f6 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmime: Avoid a temporary variable in IDirectMusicPerformance8Impl_InitAudio().

parent a2685a8b
...@@ -26,7 +26,7 @@ typedef struct IDirectMusicPerformance8Impl { ...@@ -26,7 +26,7 @@ typedef struct IDirectMusicPerformance8Impl {
IDirectMusicPerformance8 IDirectMusicPerformance8_iface; IDirectMusicPerformance8 IDirectMusicPerformance8_iface;
LONG ref; LONG ref;
IDirectMusic8 *dmusic; IDirectMusic8 *dmusic;
IDirectSound *pDirectSound; IDirectSound *dsound;
IDirectMusicGraph *pToolGraph; IDirectMusicGraph *pToolGraph;
DMUS_AUDIOPARAMS pParams; DMUS_AUDIOPARAMS pParams;
/* global parameters */ /* global parameters */
...@@ -257,15 +257,15 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_Init(IDirectMusicPerformance8 ...@@ -257,15 +257,15 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_Init(IDirectMusicPerformance8
return DMUS_E_ALREADY_INITED; return DMUS_E_ALREADY_INITED;
if (NULL != pDirectSound) { if (NULL != pDirectSound) {
This->pDirectSound = pDirectSound; This->dsound = pDirectSound;
IDirectSound_AddRef(This->pDirectSound); IDirectSound_AddRef(This->dsound);
} else { } else {
DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL); DirectSoundCreate8(NULL, (IDirectSound8 **) &This->dsound, NULL);
if (!This->pDirectSound) return DSERR_NODRIVER; if (!This->dsound) return DSERR_NODRIVER;
if (!hWnd) if (!hWnd)
hWnd = GetForegroundWindow(); hWnd = GetForegroundWindow();
IDirectSound_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY); IDirectSound_SetCooperativeLevel(This->dsound, hWnd, DSSCL_PRIORITY);
} }
if (NULL != ppDirectMusic && NULL != *ppDirectMusic) { if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
...@@ -828,10 +828,10 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown(IDirectMusicPerform ...@@ -828,10 +828,10 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CloseDown(IDirectMusicPerform
This->procThreadTicStarted = FALSE; This->procThreadTicStarted = FALSE;
CloseHandle(This->procThread); CloseHandle(This->procThread);
} }
if (NULL != This->pDirectSound) { if (This->dsound) {
IDirectSound_Release(This->pDirectSound); IDirectSound_Release(This->dsound);
This->pDirectSound = NULL; This->dsound = NULL;
} }
if (This->dmusic) { if (This->dmusic) {
IDirectMusic8_Release(This->dmusic); IDirectMusic8_Release(This->dmusic);
This->dmusic = NULL; This->dmusic = NULL;
...@@ -891,38 +891,33 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime(IDirectMusicPerf ...@@ -891,38 +891,33 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_RhythmToTime(IDirectMusicPerf
/* IDirectMusicPerformance8 Interface part follow: */ /* IDirectMusicPerformance8 Interface part follow: */
static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerformance8 *iface, static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio(IDirectMusicPerformance8 *iface,
IDirectMusic **ppDirectMusic, IDirectSound **ppDirectSound, HWND hWnd, IDirectMusic **ppDirectMusic, IDirectSound **dsound, HWND hwnd,
DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams) DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams)
{ {
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface); IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
IDirectSound* dsound = NULL; HRESULT hr = S_OK;
HRESULT hr = S_OK;
FIXME("(%p, %p, %p, %p, %x, %u, %x, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams); TRACE("(%p, %p, %p, %p, %x, %u, %x, %p)\n", This, ppDirectMusic, dsound, hwnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
if (This->dmusic) if (This->dmusic)
return DMUS_E_ALREADY_INITED; return DMUS_E_ALREADY_INITED;
if (NULL != ppDirectSound && NULL != *ppDirectSound) { if (!dsound || !*dsound) {
dsound = *ppDirectSound; hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL);
} else { if (FAILED(hr))
hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL); return hr;
FIXME("return dsound(%p,%d)\n", dsound, hr); IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(),
if (FAILED(hr) || !dsound) DSSCL_PRIORITY);
return DSERR_NODRIVER; if (dsound)
if (!hWnd) *dsound = This->dsound;
hWnd = GetForegroundWindow(); } else
IDirectSound_SetCooperativeLevel(dsound, hWnd, DSSCL_PRIORITY); This->dsound = *dsound;
if (ppDirectSound)
*ppDirectSound = dsound;
}
IDirectMusicPerformance8_Init(iface, ppDirectMusic, dsound, hWnd); IDirectMusicPerformance8_Init(iface, ppDirectMusic, This->dsound, hwnd);
/* Init increases the ref count of the dsound object. Decrement it if the app doesn't want a pointer to the object. */ /* Init increases the ref count of the dsound object. Decrement it if the app doesn't want a pointer to the object. */
if (NULL == ppDirectSound) { if (!dsound)
IDirectSound_Release(This->pDirectSound); IDirectSound_Release(This->dsound);
}
/* as seen in msdn we need params init before audio path creation */ /* as seen in msdn we need params init before audio path creation */
if (NULL != pParams) { if (NULL != pParams) {
...@@ -1059,7 +1054,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire ...@@ -1059,7 +1054,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire
} }
/* FIXME: Should we create one secondary buffer for each PChannel? */ /* FIXME: Should we create one secondary buffer for each PChannel? */
hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL); hr = IDirectSound_CreateSoundBuffer(This->dsound, &desc, &buffer, NULL);
if (FAILED(hr)) if (FAILED(hr))
return DSERR_BUFFERLOST; return DSERR_BUFFERLOST;
...@@ -1068,7 +1063,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire ...@@ -1068,7 +1063,7 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath(IDire
desc.dwBufferBytes = 0; desc.dwBufferBytes = 0;
desc.lpwfxFormat = NULL; desc.lpwfxFormat = NULL;
hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &primary_buffer, NULL); hr = IDirectSound_CreateSoundBuffer(This->dsound, &desc, &primary_buffer, NULL);
if (FAILED(hr)) { if (FAILED(hr)) {
IDirectSoundBuffer_Release(buffer); IDirectSoundBuffer_Release(buffer);
return DSERR_BUFFERLOST; return DSERR_BUFFERLOST;
...@@ -1203,7 +1198,6 @@ HRESULT WINAPI create_dmperformance(REFIID lpcGUID, void **ppobj) ...@@ -1203,7 +1198,6 @@ HRESULT WINAPI create_dmperformance(REFIID lpcGUID, void **ppobj)
} }
obj->IDirectMusicPerformance8_iface.lpVtbl = &DirectMusicPerformance8_Vtbl; obj->IDirectMusicPerformance8_iface.lpVtbl = &DirectMusicPerformance8_Vtbl;
obj->ref = 0; /* will be inited by QueryInterface */ obj->ref = 0; /* will be inited by QueryInterface */
obj->pDirectSound = NULL;
obj->pDefaultPath = NULL; obj->pDefaultPath = NULL;
InitializeCriticalSection(&obj->safe); InitializeCriticalSection(&obj->safe);
obj->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectMusicPerformance8Impl*->safe"); obj->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectMusicPerformance8Impl*->safe");
......
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