DMUSIC: some dmloader/dsound fixes

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

 I'm back again :)
 And trying again to get Unreal2 demo working, this time with that patch the 
dmusic part only fail on a the CreateFile (on ILoaderStream::Attach) because 
we not use the specified IDirectMusicLoader8Impl::wzSearchPath. 

Rok, any idea how to get a proper solution for that ?

dmusic log:
trace:dmloader:DMLOADER_DllGetClassObject (0x4024b00f,0x4024afe8,0x408fd804)
trace:dmloader:LoaderCF_CreateInstance (0x49b08458)->((nil),
{19e7c08c-0a44-4e6a-a116-595a7cd5de8c},0x53c98ff4)
trace:dmloader:DMUSIC_CreateDirectMusicLoader (0x1053ffb0,0x53c98ff4,(nil))
trace:dmime:DMIME_DllGetClassObject (0x4024b084,0x4024b05d,0x408fd800)
trace:dmime:PerformanceCF_CreateInstance (0x49f86a18)->((nil),
{679c4137-c62e-4147-b2b4-9d569acb254c},0x53c98ff8)
trace:dmime:DMUSIC_CreateDirectMusicPerformance (0x1053ffa0,0x53c98ff8,(nil))
fixme:dmime:IDirectMusicPerformance8ImplInitAudio (0x403c2f90, (nil), 
0x53c98ffc, (nil), 8, 128, 3f, (nil)): to check
fixme:wave:IDsDriverBufferImpl_SetVolumePan (0x4e690850,0x4e690424): stub!
fixme:dmime:IDirectMusicPerformance8Impl_Init (iface = 0x403c2f90, dmusic = 
(nil), dsound = 0x4e690020, hwnd = (nil))
trace:dmusic:DMUSIC_DllGetClassObject (0x4024b0f9,0x4024b0d2,0x408fd790)
trace:dmusic:DirectMusicCF_CreateInstance (0x49b344ec)->((nil),
{2d3629f7-813d-4939-8508-f05c6b75fd97},0x403c2f98)
trace:dmusic:DMUSIC_CreateDirectMusic (0x49f823a4,0x403c2f98,(nil))
fixme:dmime:IDirectMusicPerformance8ImplCreateStandardAudioPath 
(0x403c2f90)->(8, 128, 0, 0x403c2fe8): semi-stub
trace:dmime:IDirectMusicPerformance8ImplCreateStandardAudioPath  returning 
IDirectMusicPerformance interface at 0x4e695f70.
trace:dmloader:IDirectMusicLoader8Impl_SetSearchDirectory (0x403c3140, 
{d2ac2893-b39b-11d1-8704-00600893b1bd}, L"..\\music\\", 0)
fixme:dmime:IDirectMusicPerformance8ImplGetDefaultAudioPath (0x403c2f90, 
0x408fd804): semi-stub
trace:dmime:IDirectMusicAudioPathImpl_AddRef (0x4e695f70) : AddRef from 1
fixme:dmime:IDirectMusicAudioPathImpl_GetObjectInPath (0x4e695f70, 0, 12800, 
0, {00000000-0000-0000-0000-000000000000}, 0, 
{2befc277-5497-11d2-bccb-00a0c922e6eb}, 0x408fd824): stub
fixme:dmime:IDirectMusicPerformance8Impl_GetGraph (0x403c2f90, 0x408fd7d0): to 
check
fixme:dmime:IDirectMusicPerformance8Impl_SetGraph (0x403c2f90, 0x4e6963e8): to 
check
trace:dmime:IDirectMusicGraphImpl_AddRef (0x4e6963e8) : AddRef from 1
trace:dmime:IDirectMusicGraphImpl_Release (0x4e6963e8) : ReleaseRef to 1
fixme:dmime:IDirectMusicGraphImpl_InsertTool (0x4e6963e8, 0x48691a40, (nil), 
0, 0): use of pdwPChannels
trace:dmime:IDirectMusicGraphImpl_Release (0x4e6963e8) : ReleaseRef to 0
trace:dmloader:IDirectMusicLoader8Impl_LoadObjectFromFile (0x403c3140, 
{9301e380-1f22-11d3-8226-d2fa76255d47}, 
{9301e386-1f22-11d3-8226-d2fa76255d47}, L"M08.con", 0x408fd2c4): wrapping to 
IDirectMusicLoader8Impl_GetObject
trace:dmloader:IDirectMusicLoader8Impl_GetObject (0x403c3140, 0x408fcf44, 
{9301e386-1f22-11d3-8226-d2fa76255d47}, 0x408fd2c4)
trace:dmloader:IDirectMusicLoader8Impl_GetObject looking up cache...
trace:dmloader:IDirectMusicLoader8Impl_GetObject : object does not exist in 
cache
trace:dmloader:DMLOADER_DllGetClassObject (0x4024b272,0x4024b24b,0x408fcaa0)
trace:dmloader:ContainerCF_CreateInstance (0x49b08474)->((nil),
{d2ac28b5-b39b-11d1-8704-00600893b1bd},0x408fcf18)
trace:dmloader:DMUSIC_CreateDirectMusicContainerObject (0x49b04154,0x408fcf18,
(nil))
trace:dmloader:IDirectMusicLoader8Impl_GetObject : loading from file 
(L"M08.con")
trace:dmloader:DMUSIC_CreateLoaderStream (0x408fcefc)
trace:dmloader:ILoaderStream_Attach (0x4e696490, L"M08.con", 0x403c3140)
trace:dmloader:ILoaderStream_Attach : failed
trace:dmime:IDirectMusicPerformance8Impl_SetGlobalParam (0x403c2f90, 
{d2ac28b1-b39b-11d1-8704-00600893b1bd}, 0x408fd878, 4)
trace:dmime:IDirectMusicPerformance8Impl_SetGlobalParam => MasterVolume set to 
- -10000
fixme:seh:EXC_RtlRaiseException call to unimplemented function 
ntdll.dll.RtlCreateQueryDebugBuffer


Changelog:
 - some fixes on DirectSound init (need SetCooperativeLevel as seen in msdn) 
on IDirectMusicPerformance8::InitAudio
 - some logic fixes on IDirectMusicPerformance8ImplCreateStandardAudioPath 
(not perfect yet, need to understand/fix the channel init/use)
 - fix typo on CreateDirectMusicContainer 
 - add missing define on dsound.h
 - better traces on IDirectMusicLoader8::SetSearchDirectory

Best Regards,
Raphael

 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/nGOcp7NA3AmQTU4RAphDAJ94meGfa5FK6hO0F5cBaChRZH9PjwCgi7m3
Q7VsDoxbAzA0pog7e2KH0T0=
=2OfH
-----END PGP SIGNATURE-----
Index: dlls/dmime/performance.c
===================================================================
RCS file: /home/wine/wine/dlls/dmime/performance.c,v
retrieving revision 1.3
diff -u -r1.3 performance.c
--- dlls/dmime/performance.c	5 Sep 2003 23:08:39 -0000	1.3
+++ dlls/dmime/performance.c	26 Oct 2003 23:10:25 -0000
@@ -78,6 +78,17 @@
 	  IDirectSound_AddRef((LPDIRECTSOUND) This->pDirectSound);
 	} else {
 	  DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
+	  /** 
+	   * as seen in msdn
+	   * 
+	   *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/idirectmusicperformance8initaudio.asp
+	   */
+	  if (NULL != hWnd) {
+	    IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
+	  } else {
+	    /* how to get the ForeGround window handle ? */
+            /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
+	  }
 	  if (!This->pDirectSound)
 	    return DSERR_NODRIVER;
 	}
@@ -88,7 +99,7 @@
 	  IDirectMusic8_AddRef((LPDIRECTMUSIC8) This->pDirectMusic);
 	} else {
 	  /* app allows the performance to initialise itfself and needs a pointer to object*/
-		CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
+          CoCreateInstance (&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
 	  if (ppDirectMusic) {
 	    *ppDirectMusic = (LPDIRECTMUSIC) This->pDirectMusic;
 	    IDirectMusic8_AddRef((LPDIRECTMUSIC8) *ppDirectMusic);
@@ -523,8 +534,9 @@
 						      DMUS_AUDIOPARAMS* pParams)
 {
 	IDirectSound* dsound;
+	HRESULT hr = S_OK;
 	
-    ICOM_THIS(IDirectMusicPerformance8Impl,iface);
+        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->pDirectMusic || This->pDirectSound)
@@ -550,11 +562,21 @@
 	if (NULL != pParams) {
 	  memcpy(&This->pParams, pParams, sizeof(DMUS_AUDIOPARAMS));
 	} else {
-	  /* TODO, how can i fill the struct */
+	  /**
+	   * TODO, how can i fill the struct 
+	   * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp
+	   */
+	  This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS);
+	  This->pParams.fInitNow = FALSE;
+	  This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH;
+	  This->pParams.dwVoices = 64;
+	  This->pParams.dwSampleRate = (DWORD) 22.050; 
+	  This->pParams.dwFeatures = dwFlags;
+	  This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink;
 	}
-	IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
+	hr = IDirectMusicPerformance8ImplCreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, (IDirectMusicAudioPath**) &This->pDefaultPath);
 
-	return S_OK;
+	return hr;
 }
 
 HRESULT WINAPI IDirectMusicPerformance8ImplPlaySegmentEx (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSource, WCHAR* pwzSegmentName, IUnknown* pTransition, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState, IUnknown* pFrom, IUnknown* pAudioPath)
@@ -593,17 +615,24 @@
 	return S_OK;
 }
 
+/**
+ * see  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/standardaudiopaths.asp
+ */
 HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
 {
 	IDirectMusicAudioPathImpl *default_path;
 	DSBUFFERDESC desc;
 	WAVEFORMATEX format;
 	LPDIRECTSOUNDBUFFER8 buffer;
+	HRESULT hr = S_OK;
 
 	ICOM_THIS(IDirectMusicPerformance8Impl,iface);
 	
 	FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
 
+	if (NULL == ppNewPath) {
+	  return E_POINTER;
+	}
 	default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
 	if (NULL == default_path) {
 		*ppNewPath = (LPDIRECTMUSICAUDIOPATH) NULL;
@@ -623,7 +652,7 @@
 	format.cbSize = 0;
 	
 	desc.dwSize = sizeof(desc);
-	desc.dwFlags = 0;
+	desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
 	desc.dwBufferBytes = DSBSIZE_MIN;
 	desc.dwReserved = 0;
 	desc.lpwfxFormat = &format;
@@ -631,22 +660,35 @@
 	
 	switch(dwType) {
 	case DMUS_APATH_DYNAMIC_3D:
-		desc.dwFlags |= DSBCAPS_CTRL3D;
+                desc.dwFlags |= DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_MUTE3DATMAXDISTANCE;
 		break;
 	case DMUS_APATH_DYNAMIC_MONO:
+	        desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
 		break;
-	case DMUS_APATH_SHARED_STEREOPLUSREVERB:	
+	case DMUS_APATH_SHARED_STEREOPLUSREVERB:
+	        /* normally we havet to create 2 buffers (one for music other for reverb) 
+		 * in this case. See msdn
+                 */
 	case DMUS_APATH_DYNAMIC_STEREO:
+		desc.dwFlags |= DSBCAPS_CTRLFREQUENCY;
 		format.nChannels = 2;
 		format.nBlockAlign *= 2;
 		format.nAvgBytesPerSec *=2;
 		break;
 	default:
-		break;
+	        HeapFree(GetProcessHeap(), 0, default_path); 
+	        *ppNewPath = NULL;
+	        return E_INVALIDARG;
+	        break;
 	}
 
 	/* FIXME: Should we create one secondary buffer for each PChannel? */
-	IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
+	hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
+	if (FAILED(hr)) {
+	        HeapFree(GetProcessHeap(), 0, default_path); 
+	        *ppNewPath = NULL;
+	        return DSERR_BUFFERLOST;
+	}
 	default_path->pDSBuffer = (IDirectSoundBuffer*) buffer;
 
 	/* Update description for creating primary buffer */
@@ -654,8 +696,13 @@
 	desc.dwBufferBytes = 0;
 	desc.lpwfxFormat = NULL;
 
-	IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
-
+	hr = IDirectSound8_CreateSoundBuffer ((LPDIRECTSOUND8) This->pDirectSound, &desc, &buffer, NULL);
+	if (FAILED(hr)) {
+                IDirectSoundBuffer_Release(default_path->pDSBuffer);
+	        HeapFree(GetProcessHeap(), 0, default_path); 
+	        *ppNewPath = NULL;
+	        return DSERR_BUFFERLOST;
+	}
 	default_path->pPrimary = (IDirectSoundBuffer*) buffer;
 
 	*ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
Index: dlls/dmloader/container.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/container.c,v
retrieving revision 1.3
diff -u -r1.3 container.c
--- dlls/dmloader/container.c	5 Sep 2003 23:08:39 -0000	1.3
+++ dlls/dmloader/container.c	26 Oct 2003 23:10:26 -0000
@@ -86,7 +86,7 @@
 {
 	IDirectMusicContainerImpl* dmcon;
 	
-	if (IsEqualIID (lpcGUID, &IID_IDirectMusicBand)) {
+	if (IsEqualIID (lpcGUID, &IID_IDirectMusicContainer)) {
 		dmcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl));
 		if (NULL == dmcon) {
 			*ppDMCon = (LPDIRECTMUSICCONTAINER) NULL;
Index: dlls/dmloader/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loader.c,v
retrieving revision 1.5
diff -u -r1.5 loader.c
--- dlls/dmloader/loader.c	22 Sep 2003 19:37:33 -0000	1.5
+++ dlls/dmloader/loader.c	26 Oct 2003 23:10:26 -0000
@@ -224,7 +224,7 @@
 {
 	ICOM_THIS(IDirectMusicLoader8Impl,iface);
 
-	TRACE("(%p, %s, %p, %d)\n", This, debugstr_guid(rguidClass), pwzPath, fClear);
+	TRACE("(%p, %s, %s, %d)\n", This, debugstr_guid(rguidClass), debugstr_w(pwzPath), fClear);
 	if (0 == strncmpW(This->wzSearchPath, pwzPath, MAX_PATH)) {
 	  return S_FALSE;
 	} 
Index: dlls/dmloader/loaderstream.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loaderstream.c,v
retrieving revision 1.4
diff -u -r1.4 loaderstream.c
--- dlls/dmloader/loaderstream.c	16 Oct 2003 19:31:11 -0000	1.4
+++ dlls/dmloader/loaderstream.c	26 Oct 2003 23:10:27 -0000
@@ -37,18 +37,17 @@
  */
 HRESULT WINAPI ILoaderStream_Attach (ILoaderStream* This, LPCWSTR wzFile, IDirectMusicLoader *pLoader)
 {
-	TRACE("(%p, %s, %p)\n", This, debugstr_w(wzFile), pLoader);
-	ILoaderStream_Detach (This);
-	This->hFile = CreateFileW (wzFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+    TRACE("(%p, %s, %p)\n", This, debugstr_w(wzFile), pLoader);
+    ILoaderStream_Detach (This);
+    This->hFile = CreateFileW (wzFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if (This->hFile == INVALID_HANDLE_VALUE) {
-		TRACE(": failed\n");
+        TRACE(": failed\n");
         return E_FAIL;
     }
-	/* create IDirectMusicGetLoader */
-    (LPDIRECTMUSICLOADER)This->pLoader = pLoader;
+    /* create IDirectMusicGetLoader */
+    (LPDIRECTMUSICLOADER) This->pLoader = pLoader;
     strncpyW (This->wzFileName, wzFile, MAX_PATH);
-	TRACE(": succeeded\n");
-	
+    TRACE(": succeeded\n");
     return S_OK;
 }
 
Index: dlls/ntdll/path.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/path.c,v
retrieving revision 1.10
diff -u -r1.10 path.c
--- dlls/ntdll/path.c	8 Oct 2003 03:51:31 -0000	1.10
+++ dlls/ntdll/path.c	26 Oct 2003 23:10:30 -0000
@@ -321,6 +321,7 @@
     LPWSTR              ptr;
     UNICODE_STRING*     cd;
 
+    TRACE("name %s size %lu\n",debugstr_w(name),size);
     reqsize = sizeof(WCHAR); /* '\0' at the end */
 
     RtlAcquirePebLock();
@@ -499,7 +500,7 @@
                         /* either collapse \foo\.. into \ or \.. into \ */
                         if (prev < buffer + mark) prev = p - 1;
                         reqsize -= (p + 2 - prev) * sizeof(WCHAR);
-                        memmove(prev, p + 2, buffer + reqsize - prev + sizeof(WCHAR));
+                        memmove(prev, p + 2, (ULONG)buffer + reqsize - (ULONG)prev + sizeof(WCHAR));
                         p = prev;
                     }
                     break;
@@ -511,7 +512,7 @@
                 break;
             case '\\':
                 reqsize -= 2 * sizeof(WCHAR);
-                memmove(ptr, ptr + 2, buffer + reqsize - ptr + sizeof(WCHAR));
+                memmove(p, p + 2, (ULONG)buffer + reqsize - (ULONG)p + sizeof(WCHAR));
                 break;
             }
         }
Index: include/dsound.h
===================================================================
RCS file: /home/wine/wine/include/dsound.h,v
retrieving revision 1.40
diff -u -r1.40 dsound.h
--- include/dsound.h	5 Sep 2003 23:15:44 -0000	1.40
+++ include/dsound.h	26 Oct 2003 23:10:36 -0000
@@ -189,6 +189,7 @@
 #define DSBCAPS_CTRLPAN             0x00000040
 #define DSBCAPS_CTRLVOLUME          0x00000080
 #define DSBCAPS_CTRLPOSITIONNOTIFY  0x00000100
+#define DSBCAPS_CTRLFX              0x00000200
 #define DSBCAPS_CTRLDEFAULT         0x000000E0  /* Pan + volume + frequency. */
 #define DSBCAPS_CTRLALL             0x000001F0  /* All control capabilities */
 #define DSBCAPS_STICKYFOCUS         0x00004000

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

  Powered by Linux