[DMUSIC] Some implementations, fixes and stubs improvements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch makes the farscape demo launch and display the main menu.

Bye,
Christian

Changelog :
Allocate necessary dsound buffers for standard audio paths and enable retrieval
of their interfaces via GetObjectInPath.
Fix and clean dsound and dmusics objects allocation when initializing the performance object.
Some stubs improvements.


Christian Costa titan.costa@wanadoo.fr

Index: dmusic_loader.c
===================================================================
RCS file: /home/wine/wine/dlls/dmusic/dmusic_loader.c,v
retrieving revision 1.4
diff -u -r1.4 dmusic_loader.c
--- dmusic_loader.c	13 Jun 2003 18:59:51 -0000	1.4
+++ dmusic_loader.c	15 Jun 2003 18:06:37 -0000
@@ -303,6 +303,9 @@
 	return S_OK;
 }
 
+extern ICOM_VTABLE(IDirectMusicSegment) DirectMusicSegment_Vtbl;
+extern ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl;
+
 HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, 
 							   REFGUID rguidClassID, 
 							   REFIID iidInterfaceID, 
@@ -319,6 +322,24 @@
 	  FIXME("wanted 'spt'\n");
 	} else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicContainer)) {
 	  FIXME("wanted 'con'\n");
+	}
+
+	if (IsEqualGUID(iidInterfaceID,&IID_IDirectMusicSegment)) {
+	  IDirectMusicSegmentImpl* segment;
+	  segment = (IDirectMusicSegmentImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectMusicImpl));
+	  segment->lpVtbl = &DirectMusicSegment_Vtbl;
+	  segment->ref = 1;
+	  *ppObject = segment;
+	  return S_OK;
+	} else if (IsEqualGUID(iidInterfaceID,&IID_IDirectMusicSegment8)) {
+	  IDirectMusicSegmentImpl* segment;
+	  segment = (IDirectMusicSegmentImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectMusicImpl));
+	  segment->lpVtbl = &DirectMusicSegment8_Vtbl;
+	  segment->ref = 1;
+	  *ppObject = segment;
+	  return S_OK;
+	} else {
+	  FIXME("bad iid\n");
 	}
 	
 	/** for now alway return not supported for avoiding futur crash */
Index: dmusic_misc.c
===================================================================
RCS file: /home/wine/wine/dlls/dmusic/dmusic_misc.c,v
retrieving revision 1.3
diff -u -r1.3 dmusic_misc.c
--- dmusic_misc.c	13 Jun 2003 18:59:51 -0000	1.3
+++ dmusic_misc.c	15 Jun 2003 18:06:39 -0000
@@ -216,6 +216,32 @@
 	FIXME("(%p, %ld, %ld, %ld, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
 
 	switch (dwStage) {
+	case DMUS_PATH_BUFFER:
+	  {
+	    if (IsEqualGUID(iidInterface,&IID_IDirectSoundBuffer8)) {
+	      IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSoundBuffer8, ppObject);
+	      TRACE("returning %p\n",*ppObject);
+	      return S_OK;
+	    } else if (IsEqualGUID(iidInterface,&IID_IDirectSound3DBuffer)) {
+	      IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSound3DBuffer, ppObject);
+	      TRACE("returning %p\n",*ppObject);
+	      return S_OK;
+	    } else {
+	      FIXME("Bad iid\n");
+	    }
+	  }
+	  break;
+
+	case DMUS_PATH_PRIMARY_BUFFER: {
+	  if (IsEqualGUID(iidInterface,&IID_IDirectSound3DListener)) {
+	    IDirectSoundBuffer8_QueryInterface(This->primary, &IID_IDirectSound3DListener, ppObject);
+	    return S_OK;
+	  }else {
+	    FIXME("bad iid...\n");
+	  }
+	}
+	break;
+
 	case DMUS_PATH_AUDIOPATH_GRAPH:
 	  {
 	    if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) {
Index: dmusic_performance.c
===================================================================
RCS file: /home/wine/wine/dlls/dmusic/dmusic_performance.c,v
retrieving revision 1.6
diff -u -r1.6 dmusic_performance.c
--- dmusic_performance.c	13 Jun 2003 18:59:51 -0000	1.6
+++ dmusic_performance.c	15 Jun 2003 18:06:42 -0000
@@ -557,37 +557,31 @@
 
 	FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p): forward to IDirectMusicPerformanceImpl::Init\n", This, ppDirectMusic, pDirectSound, hWnd);
 
-	if (NULL != ppDirectMusic) {
+        if (This->dmusic || This->dsound)
+	  return DMUS_E_ALREADY_INITED;
+	
+	if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
 	  /* app creates it's own dmusic object and gives it to performance */
-	  if (NULL != *ppDirectMusic) {
-	    if (NULL != This->dmusic) {
-	    }
-	    This->dmusic = (IDirectMusic*) *ppDirectMusic;
-	    IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic);
-	  } else { /* app allows the performance to initialise itfself and needs a pointer to object*/
-	    /* maybe IID_IDirectMusic8 must be used here */
-	    DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
+	  This->dmusic = (IDirectMusic*) *ppDirectMusic;
+	  IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic);
+	} else {
+	  /* app allows the performance to initialise itfself and needs a pointer to object*/
+	  /* maybe IID_IDirectMusic8 must be used here */
+	  DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
+	  if (ppDirectMusic) {
 	    *ppDirectMusic = (LPDIRECTMUSIC) This->dmusic;
-	    if (NULL != *ppDirectMusic) {
-	      IDirectMusic_AddRef(*ppDirectMusic);
-	    }
+	    IDirectMusic_AddRef(*ppDirectMusic);
 	  }
-	} else {
-	  TRACE("DirectMusic to be created; not needed\n");
 	}
 
 	if (NULL != pDirectSound) {
-	  if (NULL != This->dsound) {
-	  }
 	  This->dsound = (IDirectSound*) pDirectSound;
 	  IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
 	} else {
-	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) This->dsound, NULL);
+	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
 	}
 	
 	return S_OK;
-
-
 }
 
 HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState)
@@ -1021,18 +1015,23 @@
         ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 	FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
 
+        if (This->dmusic || This->dsound)
+	  return DMUS_E_ALREADY_INITED;
+
 	if (NULL != ppDirectSound && NULL != *ppDirectSound) {
 	  This->dsound = *ppDirectSound;
 	} else {
-	  This->dsound = NULL;
+	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
+	  if (ppDirectSound)
+	    *ppDirectSound = This->dsound;  
 	}
+	
 	IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd);
-	if (NULL != ppDirectSound && NULL == *ppDirectSound) {
-	  *ppDirectSound = (IDirectSound*) This->dsound;
-	  if (NULL != *ppDirectSound) {
-	    IDirectSound_AddRef(*ppDirectSound);
-	  }
-	}
+
+	/* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
+        if (!ppDirectSound)
+	  IDirectSound_Release(*ppDirectSound);
+	
 	/* as seen in msdn we need params init before audio path creation */
 	if (NULL != pParams) {
 	  memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS));
@@ -1082,27 +1081,74 @@
 
 HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
 {
-        IDirectMusicAudioPathImpl* default_path;
-        ICOM_THIS(IDirectMusicPerformance8Impl,iface);
+	IDirectMusicAudioPathImpl *default_path;
+	DSBUFFERDESC desc;
+	WAVEFORMATEX format;
+	LPDIRECTSOUNDBUFFER8 buffer;
 
-	FIXME("(%p, %ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
+	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
+	
+	FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
+
+	default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
+	if (NULL == default_path)
+	{
+		*ppNewPath = (LPDIRECTMUSICAUDIOPATH)NULL;
+		return E_OUTOFMEMORY;
+	}
+	default_path->lpVtbl = &DirectMusicAudioPath_Vtbl;
+	default_path->ref = 1;
+	default_path->perfo = (IDirectMusicPerformance*) This;
 
-	switch (dwType) {
+	/* Secondary buffer description */
+	format.wFormatTag = WAVE_FORMAT_PCM;
+	format.nChannels = 1;
+	format.nSamplesPerSec = 44000;
+	format.nAvgBytesPerSec = 44000*2;
+	format.nBlockAlign = 2;
+	format.wBitsPerSample = 16;
+	format.cbSize = 0;
+	
+	desc.dwSize = sizeof(desc);
+	desc.dwFlags = 0;
+	desc.dwBufferBytes = DSBSIZE_MIN;
+	desc.dwReserved = 0;
+	desc.lpwfxFormat = &format;
+	desc.guid3DAlgorithm = GUID_NULL;
+	
+	switch(dwType) {
 	case DMUS_APATH_DYNAMIC_3D:
+		desc.dwFlags |= DSBCAPS_CTRL3D;
+		break;
 	case DMUS_APATH_DYNAMIC_MONO:
+		break;
+	case DMUS_APATH_SHARED_STEREOPLUSREVERB:	
 	case DMUS_APATH_DYNAMIC_STEREO:
-	case DMUS_APATH_SHARED_STEREOPLUSREVERB:
-	  break;
+		format.nChannels = 2;
+		format.nBlockAlign *= 2;
+		format.nAvgBytesPerSec *=2;
+		break;
 	default:
-	  break;
+		break;
 	}
+	
+	/* FIXME: Should we create one secondary buffer for each PChannel? */
+	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8)This->dsound, &desc, &buffer, NULL);
+	default_path->buffer = (IDirectSoundBuffer*) buffer;
 
-	default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
-	default_path->lpVtbl = &DirectMusicAudioPath_Vtbl;
-	default_path->ref = 1;
-	default_path->perfo = (IDirectMusicPerformance*) This;
+	/* Update description for creating primary buffer */
+	desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
+	desc.dwBufferBytes = 0;
+	desc.lpwfxFormat = NULL;
+
+	IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8)This->dsound, &desc, &buffer, NULL);
+
+	default_path->primary = (IDirectSoundBuffer*) buffer;
+
+	*ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
+	
+	TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
 
-	*ppNewPath = (IDirectMusicAudioPath*) default_path;
 	return DS_OK;
 }
 
@@ -1234,3 +1280,4 @@
 	
 	return E_NOINTERFACE;
 }
+
Index: dmusic_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dmusic/dmusic_private.h,v
retrieving revision 1.8
diff -u -r1.8 dmusic_private.h
--- dmusic_private.h	13 Jun 2003 18:59:51 -0000	1.8
+++ dmusic_private.h	15 Jun 2003 18:06:47 -0000
@@ -923,6 +923,8 @@
   /* IDirectMusicAudioPathImpl fields */
   IDirectMusicPerformance* perfo;
   IDirectMusicGraph*       toolGraph;
+  IDirectSoundBuffer*      buffer;
+  IDirectSoundBuffer*      primary;
 };
 
 /* IUnknown: */

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux