[DMUSIC] Some fixes

Christian Costa titan.costa at wanadoo.fr
Tue Jul 1 17:12:24 CDT 2003


Hi,

This patch will fix crash when no audio driver is available (reported by 
Raphael)
and fix crash in InitAudio when releasing the dsound object in InitAudio 
(reported by Rok).

Bye,
Christian


Changelog :
Make Init and InitAudio return an error when no audio driver is available.
Fix crash in InitAudio when releasing the dsound object.

Christian Costa   titan.costa at wanadoo.fr

-------------- next part --------------
Index: dmusic_performance.c
===================================================================
RCS file: /home/wine/wine/dlls/dmusic/dmusic_performance.c,v
retrieving revision 1.11
diff -u -r1.11 dmusic_performance.c
--- dmusic_performance.c	30 Jun 2003 18:28:52 -0000	1.11
+++ dmusic_performance.c	1 Jul 2003 21:43:21 -0000
@@ -80,6 +80,15 @@
         if (This->dmusic || This->dsound)
 	  return DMUS_E_ALREADY_INITED;
 	
+	if (NULL != pDirectSound) {
+	  This->dsound = (IDirectSound*) pDirectSound;
+	  IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
+	} else {
+	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
+	  if (!This->dsound)
+	    return DSERR_NODRIVER;
+	}
+
 	if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
 	  /* app creates it's own dmusic object and gives it to performance */
 	  This->dmusic = (IDirectMusic8*) *ppDirectMusic;
@@ -94,12 +103,6 @@
 	  }
 	}
 
-	if (NULL != pDirectSound) {
-	  This->dsound = (IDirectSound*) pDirectSound;
-	  IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
-	} else {
-	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
-	}
 	
 	return S_OK;
 }
@@ -532,6 +535,8 @@
 						      DWORD dwFlags, 
 						      DMUS_AUDIOPARAMS* pParams)
 {
+	IDirectSound* dsound;
+	
         ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 	FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
 
@@ -539,14 +544,16 @@
 	  return DMUS_E_ALREADY_INITED;
 
 	if (NULL != ppDirectSound && NULL != *ppDirectSound) {
-	  This->dsound = *ppDirectSound;
+	  dsound = *ppDirectSound;
 	} else {
-	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
+	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &dsound, NULL);
+	  if (!dsound)
+	    return DSERR_NODRIVER;
 	  if (ppDirectSound)
-	    *ppDirectSound = This->dsound;  
+	    *ppDirectSound = dsound;  
 	}
 	
-	IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd);
+	IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd);
 
 	/* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
 	if (!ppDirectSound)


More information about the wine-patches mailing list