DMUSIC: dmband loading improvements

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

 



I finally got some time to finish this. Loading of band/bandtrack now
uses linked list and is pretty much complete. Unfortunately I haven't
been able to figure out performance messages for bandtrack, so it is
still useless. So if anyone has any ideas, please go ahead...

ChangeLog:
 - some fixes in dmband loading

-- 
Rok Mandeljc <rok.mandeljc@gimb.org>

"Hold your position! Leave doubt for the dying!"
-- Tahngarth of the Weatherlight
diff -Nru Original/wine/dlls/dmband/band.c wine/dlls/dmband/band.c
--- Original/wine/dlls/dmband/band.c	2003-09-11 18:03:30.000000000 +0200
+++ wine/dlls/dmband/band.c	2003-10-25 21:25:18.000000000 +0200
@@ -39,8 +39,7 @@
 	ICOM_THIS(IDirectMusicBandImpl,iface);
 
 	if (IsEqualGUID(riid, &IID_IUnknown) || 
-	    IsEqualGUID(riid, &IID_IDirectMusicBand))
-	{
+	    IsEqualGUID(riid, &IID_IDirectMusicBand)) {
 		IDirectMusicBandImpl_AddRef(iface);
 		*ppobj = This;
 		return S_OK;
@@ -61,8 +60,7 @@
 	ICOM_THIS(IDirectMusicBandImpl,iface);
 	ULONG ref = --This->ref;
 	TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
-	if (ref == 0)
-	{
+	if (ref == 0) {
 		HeapFree(GetProcessHeap(), 0, This);
 	}
 	return ref;
@@ -112,8 +110,7 @@
 {
 	IDirectMusicBandImpl* dmband;
 	
-	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBand))
-	{
+	if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBand)) {
 		dmband = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
 		if (NULL == dmband) {
 			*ppDMBand = (LPDIRECTMUSICBAND) NULL;
@@ -121,6 +118,7 @@
 		}
 		dmband->lpVtbl = &DirectMusicBand_Vtbl;
 		dmband->ref = 1;
+		list_init (&dmband->Instruments);
 		*ppDMBand = (LPDIRECTMUSICBAND) dmband;
 		return S_OK;
 	}
@@ -325,12 +323,12 @@
 						switch (chunkID) {
 							case DMUS_FOURCC_GUID_CHUNK: {
 								TRACE_(dmfile)(": GUID chunk\n");
-								IStream_Read (pStm, &pBand->vVersion, chunkSize, NULL);
+								IStream_Read (pStm, pBand->guidID, chunkSize, NULL);
 								break;
 							}
 							case DMUS_FOURCC_VERSION_CHUNK: {
 								TRACE_(dmfile)(": version chunk\n");
-								IStream_Read (pStm, &pBand->guidID, chunkSize, NULL);
+								IStream_Read (pStm, pBand->vVersion, chunkSize, NULL);
 								break;
 							}
 							case FOURCC_LIST: {
@@ -347,34 +345,41 @@
 											ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
 											TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
 											switch (chunkID) {
+												/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
+                                              (though strings seem to be valid unicode) */
+												case mmioFOURCC('I','N','A','M'):
 												case DMUS_FOURCC_UNAM_CHUNK: {
 													TRACE_(dmfile)(": name chunk\n");
-													pBand->wszName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wszName, chunkSize, NULL);
+													pBand->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pBand->wzName, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','A','R','T'):
 												case DMUS_FOURCC_UART_CHUNK: {
 													TRACE_(dmfile)(": artist chunk\n");
-													pBand->wszArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wszArtist, chunkSize, NULL);
+													pBand->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pBand->wzArtist, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','C','O','P'):
 												case DMUS_FOURCC_UCOP_CHUNK: {
 													TRACE_(dmfile)(": copyright chunk\n");
-													pBand->wszCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wszCopyright, chunkSize, NULL);
+													pBand->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pBand->wzCopyright, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','S','B','J'):
 												case DMUS_FOURCC_USBJ_CHUNK: {
 													TRACE_(dmfile)(": subject chunk\n");
-													pBand->wszSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wszSubject, chunkSize, NULL);
+													pBand->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pBand->wzSubject, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','C','M','T'):
 												case DMUS_FOURCC_UCMT_CHUNK: {
 													TRACE_(dmfile)(": comment chunk\n");
-													pBand->wszComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pBand->wszComment, chunkSize, NULL);
+													pBand->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pBand->wzComment, chunkSize, NULL);
 													break;
 												}
 												default: {
@@ -403,6 +408,8 @@
 													ListCount[1] = 0;
 													switch (chunkID) {
 														case DMUS_FOURCC_INSTRUMENT_LIST: {
+															/* init new instrument list entry */
+															LPDMUS_PRIVATE_INSTRUMENT pNewInstrument = (LPDMUS_PRIVATE_INSTRUMENT) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
 															TRACE_(dmfile)(": instrument list\n");
 															do {
 																IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
@@ -412,7 +419,7 @@
 																switch (chunkID) {
 																	case DMUS_FOURCC_INSTRUMENT_CHUNK: {
 																		TRACE_(dmfile)(": band instrument header\n");
-																		IStream_Read (pStm, &pBand->pInstruments[pBand->dwInstruments], chunkSize, NULL);
+																		IStream_Read (pStm, &pNewInstrument->pInstrument, chunkSize, NULL);
 																		break;
 																	}
 																	case FOURCC_LIST: {
@@ -489,8 +496,8 @@
 																						IDirectMusicObject* pObject;
 																						if(FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject)))
 																						/* acquire collection from loaded referenced object */
-																						if(FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pBand->ppReferenceCollection[pBand->dwInstruments])))
-																						IDirectMusicLoader_Release (pLoader);
+																						if(FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection)))
+																							IDirectMusicLoader_Release (pLoader);
 																					}
 																					IDirectMusicGetLoader_Release (pGetLoader);											
 																				} else {
@@ -506,45 +513,42 @@
 																	}
 																	break;
 																}
-																default: {
-																	TRACE_(dmfile)(": unknown chunk (skipping)\n");
-																	liMove.QuadPart = chunkSize;
-																	IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
-																	break;					
-																}	
-															}
-															TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
-														} while (ListCount[1] < ListSize[1]);
-/* causes crash :( */
-#if 0
-														/* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
-														   loads default collection... does that mean that if there is no reference, use default?
-														*/
-														if (!pBand->ppReferenceCollection[pBand->dwInstruments]) {
-															TRACE(": (READ): loading default collection (as no specific reference was made)\n");
-															ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
-															ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
-        													ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
-															ObjDesc.guidObject = GUID_DefaultGMCollection;
-															ObjDesc.guidClass = CLSID_DirectMusicCollection;
-															if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
-																if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
-																	IDirectMusicObject* pObject;
-																	if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
-																		IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pBand->ppReferenceCollection[pBand->dwInstruments]);
-																		IDirectMusicLoader_Release (pLoader);
+																	default: {
+																		TRACE_(dmfile)(": unknown chunk (skipping)\n");
+																		liMove.QuadPart = chunkSize;
+																		IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
+																		break;					
+																	}	
+																}
+																TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
+															} while (ListCount[1] < ListSize[1]);
+															/* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
+														       loads default collection... does that mean that if there is no reference, use default?
+														    */
+															if (!pNewInstrument->ppReferenceCollection) {
+																TRACE_(dmfile)(": (READ): loading default collection (as no specific reference was made)\n");
+																ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
+																ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
+        														ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
+																ObjDesc.guidObject = GUID_DefaultGMCollection;
+																ObjDesc.guidClass = CLSID_DirectMusicCollection;
+																if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
+																	if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
+																		IDirectMusicObject* pObject;
+																		if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
+																			IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection);
+																			IDirectMusicLoader_Release (pLoader);
+																		}
 																	}
+																	IDirectMusicGetLoader_Release (pGetLoader);											
+																} else {
+																	ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
+																	/* E_FAIL */
 																}
-																IDirectMusicGetLoader_Release (pGetLoader);											
-															} else {
-																ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
-																/* E_FAIL */
 															}
+															list_add_tail (&This->pParentObject->pBand->Instruments, &pNewInstrument->entry);
+															break;
 														}
-#endif
-														pBand->dwInstruments++; /* add count */
-														break;
-													}
 														default: {
 															TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
 															return E_FAIL;
@@ -601,6 +605,50 @@
 		}
 	}
 	
+	/* DEBUG: dumps whole band object tree: */
+	if (TRACE_ON(dmband)) {
+		TRACE("*** IDirectMusicBand (%p) ***\n", pBand);
+		if (pBand->guidID)
+			TRACE(" - GUID = %s\n", debugstr_guid(pBand->guidID));
+		if (pBand->vVersion)
+			TRACE(" - Version = %i,%i,%i,%i\n", (pBand->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionMS && 0x0000FFFF, \
+				(pBand->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionLS && 0x0000FFFF);
+		if (pBand->wzName)
+			TRACE(" - Name = %s\n", debugstr_w(pBand->wzName));
+		if (pBand->wzArtist)		
+			TRACE(" - Artist = %s\n", debugstr_w(pBand->wzArtist));
+		if (pBand->wzCopyright)
+			TRACE(" - Copyright = %s\n", debugstr_w(pBand->wzCopyright));
+		if (pBand->wzSubject)
+			TRACE(" - Subject = %s\n", debugstr_w(pBand->wzSubject));
+		if (pBand->wzComment)
+			TRACE(" - Comment = %s\n", debugstr_w(pBand->wzComment));
+		
+		TRACE(" - Instruments:\n");
+		
+		int r = 0;
+		DMUS_PRIVATE_INSTRUMENT *tmpEntry;
+		struct list *listEntry;
+			
+		LIST_FOR_EACH (listEntry, &This->pParentObject->pBand->Instruments) {
+			tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENT, entry );
+			TRACE("    - Instrument[%i]:\n", r);
+			TRACE("       - Instrument header:\n");
+			TRACE("          - dwPatch = %ld\n", tmpEntry->pInstrument.dwPatch);
+			TRACE("          - dwAssignPatch = %ld\n", tmpEntry->pInstrument.dwAssignPatch);
+			TRACE("          - dwNoteRanges[4] = %ln\n", tmpEntry->pInstrument.dwNoteRanges);
+			TRACE("          - dwPChannel = %ld\n", tmpEntry->pInstrument.dwPChannel);
+			TRACE("          - dwFlags = %ld\n", tmpEntry->pInstrument.dwFlags);
+			TRACE("          - bPan = %i\n", tmpEntry->pInstrument.bPan);
+			TRACE("          - bVolume = %i\n", tmpEntry->pInstrument.bVolume);
+			TRACE("          - nTranspose = %i\n", tmpEntry->pInstrument.nTranspose);
+			TRACE("          - dwChannelPriority = %ld\n", tmpEntry->pInstrument.dwChannelPriority);
+			TRACE("          - nPitchBendRange = %i\n", tmpEntry->pInstrument.nPitchBendRange);
+			TRACE("       - Reference collection: %p\n", tmpEntry->ppReferenceCollection);
+			r++;
+		}
+	}
+
 	return S_OK;
 }
 
diff -Nru Original/wine/dlls/dmband/bandtrack.c wine/dlls/dmband/bandtrack.c
--- Original/wine/dlls/dmband/bandtrack.c	2003-09-11 18:03:30.000000000 +0200
+++ wine/dlls/dmband/bandtrack.c	2003-10-25 21:25:18.000000000 +0200
@@ -30,6 +30,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
 
+
 /*****************************************************************************
  * IDirectMusicBandTrack implementation
  */
@@ -77,7 +78,7 @@
 	ICOM_THIS(IDirectMusicBandTrack,iface);
 
 	FIXME("(%p, %p): stub\n", This, pSegment);
-
+	
 	return S_OK;
 }
 
@@ -86,7 +87,7 @@
 	ICOM_THIS(IDirectMusicBandTrack,iface);
 
 	FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
-
+	
 	return S_OK;
 }
 
@@ -103,8 +104,75 @@
 {
 	ICOM_THIS(IDirectMusicBandTrack,iface);
 
-	FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
+	FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): semi-stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
+	/* Sends following pMSG:
+		 - DMUS_PATCH_PMSG
+		 - DMUS_TRANSPOSE_PMSG
+		 - DMUS_CHANNEL_PRIORITY_PMSG
+		 - DMUS_MIDI_PMSG
+	*/
+	
+#if 0
+	/* get the graph and segment */
+	IDirectMusicSegment* pSegment; /* needed for getting track group */
+	IDirectMusicGraph* pGraph; /* needed for PMsg stamping */
+	DWORD dwGroup;
+	if (FAILED(IDirectMusicSegmentState_GetSegment (pSegSt, &pSegment))) {
+		ERR("failed to get segment\n");
+		return E_FAIL;
+	}
+	/* HINT: M$ lies when saying that we can query segment for graph; one can obtain graph only
+              by querying segment state or performance */
+	if (FAILED(IDirectMusicSegmentState_QueryInterface (pSegSt, &IID_IDirectMusicGraph, (LPVOID*)&pGraph))) {
+		ERR("failed to get graph on segment\n");
+		return E_FAIL;
+	}
+	IDirectMusicSegment_GetTrackGroup (pSegment, (LPDIRECTMUSICTRACK)iface, &dwGroup);
 
+	
+	/* iterate through band list to get appropriate band */
+	DMUS_PRIVATE_BAND *tmpBandEntry;
+	struct list *listEntry;
+	IDirectMusicBandImpl* pBand = NULL;
+	LIST_FOR_EACH (listEntry, &This->Bands) {
+		tmpBandEntry = LIST_ENTRY (listEntry, DMUS_PRIVATE_BAND, entry);
+		/* FIXME: time checking is far from perfect: i don't know if times are properly compared and
+		          in case of v.2 header i don't know which time to take; besides, first band with smaller
+		          time will be taken */
+		if (((tmpBandEntry->pBandHeader.dwVersion = 1) && (tmpBandEntry->pBandHeader.lBandTime < mtStart))
+			|| ((tmpBandEntry->pBandHeader.dwVersion = 2) && (tmpBandEntry->pBandHeader.lBandTimeLogical < mtStart))) {
+				pBand = tmpBandEntry->ppBand;
+				break;
+			}				
+			
+	}
+	
+	int r = 0; /* TEST */
+	/* now iterate through instruments list on selected band and fill and send all messages related to it */
+	DMUS_PRIVATE_INSTRUMENT *tmpInstrumentEntry;
+	LIST_FOR_EACH (listEntry, &pBand->Instruments) {
+		tmpInstrumentEntry = LIST_ENTRY (listEntry, DMUS_PRIVATE_INSTRUMENT, entry);
+		FIXME("parsing instrument [%i]\n", r);
+		r++;
+		
+		/* allocate the msg */
+		DMUS_CHANNEL_MIDI_PMSG* pMIDI = NULL;
+		if (FAILED(IDirectMusicPerformance_AllocPMsg (pPerf, sizeof(DMUS_MIDI_PMSG), (DMUS_PMSG**)&pMIDI))) {
+			ERR("could not allocate PMsg\n");
+		}
+		
+		/* HERE THE MESSAGE DATA SHOULD BE PUT IN */
+		
+		if (FAILED(IDirectMusicGraph_StampPMsg (pGraph, (DMUS_PMSG*)pMIDI))) {
+			ERR("could not stamp PMsg\n");
+		}
+
+		if (FAILED(IDirectMusicPerformance_SendPMsg (pPerf, (DMUS_PMSG*)pMIDI))) {
+			ERR("could not send PMsg\n");
+		}		
+
+	}
+#endif		
 	return S_OK;
 }
 
@@ -144,7 +212,7 @@
 		|| IsEqualGUID (rguidType, &GUID_UnloadFromAudioPath)) {
 		TRACE("param supported\n");
 		return S_OK;
-		}
+	}
 
 	TRACE("param unsupported\n");
 	return DMUS_E_TYPE_UNSUPPORTED;
@@ -260,6 +328,7 @@
 		}
 		track->lpVtbl = &DirectMusicBandTrack_Vtbl;
 		track->ref = 1;
+		list_init (&track->Bands);
 		track->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandTrackStream));
 		track->pStream->lpVtbl = &DirectMusicBandTrackStream_Vtbl;
 		track->pStream->ref = 1;	
@@ -354,17 +423,17 @@
 						switch (chunkID) {
 							case DMUS_FOURCC_BANDTRACK_CHUNK: {
 								TRACE_(dmfile)(": band track header chunk\n");
-								IStream_Read (pStm, &pTrack->btkHeader, chunkSize, NULL);
+								IStream_Read (pStm, pTrack->btkHeader, chunkSize, NULL);
 								break;
 							}
 							case DMUS_FOURCC_GUID_CHUNK: {
 								TRACE_(dmfile)(": GUID chunk\n");
-								IStream_Read (pStm, &pTrack->vVersion, chunkSize, NULL);
+								IStream_Read (pStm, pTrack->guidID, chunkSize, NULL);
 								break;
 							}
 							case DMUS_FOURCC_VERSION_CHUNK: {
 								TRACE_(dmfile)(": version chunk\n");
-								IStream_Read (pStm, &pTrack->guidID, chunkSize, NULL);
+								IStream_Read (pStm, pTrack->vVersion, chunkSize, NULL);
 								break;
 							}
 							case FOURCC_LIST: {
@@ -381,34 +450,41 @@
 											ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
 											TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
 											switch (chunkID) {
+												/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
+                                              (though strings seem to be valid unicode) */
+												case mmioFOURCC('I','N','A','M'):
 												case DMUS_FOURCC_UNAM_CHUNK: {
 													TRACE_(dmfile)(": name chunk\n");
-													pTrack->wszName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pTrack->wszName, chunkSize, NULL);
+													pTrack->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pTrack->wzName, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','A','R','T'):
 												case DMUS_FOURCC_UART_CHUNK: {
 													TRACE_(dmfile)(": artist chunk\n");
-													pTrack->wszArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pTrack->wszArtist, chunkSize, NULL);
+													pTrack->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pTrack->wzArtist, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','C','O','P'):
 												case DMUS_FOURCC_UCOP_CHUNK: {
 													TRACE_(dmfile)(": copyright chunk\n");
-													pTrack->wszCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pTrack->wszCopyright, chunkSize, NULL);
+													pTrack->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pTrack->wzCopyright, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','S','B','J'):
 												case DMUS_FOURCC_USBJ_CHUNK: {
 													TRACE_(dmfile)(": subject chunk\n");
-													pTrack->wszSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pTrack->wszSubject, chunkSize, NULL);
+													pTrack->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pTrack->wzSubject, chunkSize, NULL);
 													break;
 												}
+												case mmioFOURCC('I','C','M','T'):
 												case DMUS_FOURCC_UCMT_CHUNK: {
 													TRACE_(dmfile)(": comment chunk\n");
-													pTrack->wszComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
-													IStream_Read (pStm, pTrack->wszComment, chunkSize, NULL);
+													pTrack->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
+													IStream_Read (pStm, pTrack->wzComment, chunkSize, NULL);
 													break;
 												}
 												default: {
@@ -437,6 +513,8 @@
 													ListCount[1] = 0;
 													switch (chunkID) {
 														case DMUS_FOURCC_BAND_LIST: {
+															/* init new band list entry */
+															LPDMUS_PRIVATE_BAND pNewBand = (LPDMUS_PRIVATE_BAND) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_BAND));
 															TRACE_(dmfile)(": band list\n");
 															do {
 																IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
@@ -448,18 +526,17 @@
 																		TRACE_(dmfile)(": band item header (v.1) chunk\n");
 																		IStream_Read (pStm, &tempHeaderV1, chunkSize, NULL);
 																		/* now transfer data to universal header */
-																		pTrack->pBandHeaders[pTrack->dwBands].dwVersion = 1;
-																		pTrack->pBandHeaders[pTrack->dwBands].lBandTime = tempHeaderV1.lBandTime;
-																		TRACE_(dmfile)(": (READ): header: lBandTime = %li\n", tempHeaderV1.lBandTime);
+																		pNewBand->pBandHeader.dwVersion = 1;
+																		pNewBand->pBandHeader.lBandTime = tempHeaderV1.lBandTime;
 																		break;
 																	}
 																	case DMUS_FOURCC_BANDITEM_CHUNK2: {
 																		TRACE_(dmfile)(": band item header (v.2) chunk\n");
 																		IStream_Read (pStm, &tempHeaderV2, chunkSize, NULL);
 																		/* now transfer data to universal header */
-																		pTrack->pBandHeaders[pTrack->dwBands].dwVersion = 2;
-																		pTrack->pBandHeaders[pTrack->dwBands].lBandTimeLogical = tempHeaderV2.lBandTimeLogical;
-																		pTrack->pBandHeaders[pTrack->dwBands].lBandTimePhysical = tempHeaderV2.lBandTimePhysical;
+																		pNewBand->pBandHeader.dwVersion = 2;
+																		pNewBand->pBandHeader.lBandTimeLogical = tempHeaderV2.lBandTimeLogical;
+																		pNewBand->pBandHeader.lBandTimePhysical = tempHeaderV2.lBandTimePhysical;
 																		break;
 																	}
 																	case FOURCC_RIFF: {
@@ -479,7 +556,7 @@
 																				IDirectMusicObject* pObject;
 																				if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
 																					/* acquire band from loaded object */
-																					IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicBand, (LPVOID*)&pTrack->ppBands[pTrack->dwBands]);
+																					IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicBand, (LPVOID*)&pNewBand->ppBand);
 																					/*IDirectMusicLoader_Release (pLoader);*/
 																				} else FIXME(": couldn't get band\n");
 																			}
@@ -503,6 +580,7 @@
 																}
 																TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
 															} while (ListCount[1] < ListSize[1]);
+															list_add_tail (&pTrack->Bands, &pNewBand->entry);
 															break;
 														}
 														default: {
@@ -523,7 +601,6 @@
 											}
 											TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
 										} while (ListCount[0] < ListSize[0]);
-										pTrack->dwBands++; /* add reference count */										
 										break;
 									}
 									default: {
@@ -563,7 +640,53 @@
 			return E_FAIL;
 		}
 	}
+	
+	/* DEBUG: dumps whole band track object tree: */
+	if (TRACE_ON(dmband)) {
+		TRACE("*** IDirectMusicBandTrack (%p) ***\n", pTrack);
+		if (pTrack->btkHeader) {
+			TRACE(" - Band track header:\n");
+			TRACE("    - bAutoDownload: %i\n", pTrack->btkHeader->bAutoDownload);
+		}
+		if (pTrack->guidID)
+			TRACE(" - GUID = %s\n", debugstr_guid(pTrack->guidID));
+		if (pTrack->vVersion)
+			TRACE(" - Version = %i,%i,%i,%i\n", (pTrack->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pTrack->vVersion->dwVersionMS && 0x0000FFFF, \
+				(pTrack->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pTrack->vVersion->dwVersionLS && 0x0000FFFF);
+		if (pTrack->wzName)
+			TRACE(" - Name = %s\n", debugstr_w(pTrack->wzName));
+		if (pTrack->wzArtist)		
+			TRACE(" - Artist = %s\n", debugstr_w(pTrack->wzArtist));
+		if (pTrack->wzCopyright)
+			TRACE(" - Copyright = %s\n", debugstr_w(pTrack->wzCopyright));
+		if (pTrack->wzSubject)
+			TRACE(" - Subject = %s\n", debugstr_w(pTrack->wzSubject));
+		if (pTrack->wzComment)
+			TRACE(" - Comment = %s\n", debugstr_w(pTrack->wzComment));
+		
+		TRACE(" - Bands:\n");
 		
+		int r = 0;
+		DMUS_PRIVATE_BAND *tmpEntry;
+		struct list *listEntry;
+			
+		LIST_FOR_EACH (listEntry, &pTrack->Bands) {
+			tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_BAND, entry );
+			TRACE("    - Band[%i]:\n", r);
+			TRACE("       - Band header:\n");
+			TRACE("          - version = %ld\n", tmpEntry->pBandHeader.dwVersion);
+			if (tmpEntry->pBandHeader.dwVersion == 1) {
+				TRACE("          - lBandTime = %li\n", tmpEntry->pBandHeader.lBandTime);
+			} else if (tmpEntry->pBandHeader.dwVersion == 2) {
+				TRACE("          - lBandTimeLogical = %li\n", tmpEntry->pBandHeader.lBandTimeLogical);
+				TRACE("          - lBandTimePhysical = %li\n", tmpEntry->pBandHeader.lBandTimePhysical);				
+			}
+			TRACE("       - Band: %p\n", tmpEntry->ppBand);
+			r++;
+		}
+	}
+
+	
 	return S_OK;
 }
 
diff -Nru Original/wine/dlls/dmband/dmband_private.h wine/dlls/dmband/dmband_private.h
--- Original/wine/dlls/dmband/dmband_private.h	2003-09-11 18:03:30.000000000 +0200
+++ wine/dlls/dmband/dmband_private.h	2003-10-25 21:25:18.000000000 +0200
@@ -33,6 +33,8 @@
 #include "dmplugin.h"
 #include "dmusicf.h"
 #include "dsound.h"
+#include "wine/list.h"
+
 
 /*****************************************************************************
  * Interfaces
@@ -67,6 +69,33 @@
 
 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBandTrack (LPCGUID lpcGUID, LPDIRECTMUSICTRACK8* ppTrack, LPUNKNOWN pUnkOuter);
 
+
+/*****************************************************************************
+ * Auxiliary definitions
+ */
+/* i don't like M$'s idea about two different band item headers, so behold: universal one */
+typedef struct _DMUS_PRIVATE_BAND_ITEM_HEADER {
+	DWORD dwVersion; /* 1 or 2 */
+	/* v.1 */
+	MUSIC_TIME lBandTime;
+	/* v.2 */
+	MUSIC_TIME lBandTimeLogical;
+	MUSIC_TIME lBandTimePhysical;
+} DMUS_PRIVATE_BAND_ITEM_HEADER;
+
+typedef struct _DMUS_PRIVATE_INSTRUMENT {
+	struct list entry; /* for listing elements */
+	DMUS_IO_INSTRUMENT pInstrument;
+	IDirectMusicCollection* ppReferenceCollection;
+} DMUS_PRIVATE_INSTRUMENT, *LPDMUS_PRIVATE_INSTRUMENT;
+
+typedef struct _DMUS_PRIVATE_BAND {
+	struct list entry; /* for listing elements */
+	DMUS_PRIVATE_BAND_ITEM_HEADER pBandHeader;
+	IDirectMusicBandImpl* ppBand;
+} DMUS_PRIVATE_BAND, *LPDMUS_PRIVATE_BAND;
+
+
 /*****************************************************************************
  * IDirectMusicBandImpl implementation structure
  */
@@ -78,18 +107,18 @@
 
   /* IDirectMusicBandImpl fields */
   IDirectMusicBandObject* pObject;
-  GUID guidID; /* unique id */
-  DMUS_IO_VERSION vVersion; /* version */
+
+  GUID* guidID; /* unique id */
+  DMUS_IO_VERSION* vVersion; /* version */
   /* info from UNFO list */
-  WCHAR* wszName;
-  WCHAR* wszArtist;
-  WCHAR* wszCopyright;
-  WCHAR* wszSubject;
-  WCHAR* wszComment;
+  WCHAR* wzName;
+  WCHAR* wzArtist;
+  WCHAR* wzCopyright;
+  WCHAR* wzSubject;
+  WCHAR* wzComment;
+
   /* data */
-  DMUS_IO_INSTRUMENT pInstruments[255];
-  IDirectMusicCollection* ppReferenceCollection[255];
-  DWORD dwInstruments;
+  struct list Instruments;
 };
 
 /* IUnknown: */
@@ -151,15 +180,6 @@
 extern HRESULT WINAPI IDirectMusicBandObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
 extern HRESULT WINAPI IDirectMusicBandObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
 
-/* i don't like M$'s idea about two different band item headers, so behold: universal one */
-typedef struct _DMUS_PRIVATE_BAND_ITEM_HEADER {
-	DWORD dwVersion; /* 1 or 2 */
-	/* v.1 */
-	MUSIC_TIME lBandTime;
-	/* v.2 */
-	MUSIC_TIME lBandTimeLogical;
-	MUSIC_TIME lBandTimePhysical;
-} DMUS_PRIVATE_BAND_ITEM_HEADER;
 
 /*****************************************************************************
  * IDirectMusicBandTrack implementation structure
@@ -172,19 +192,18 @@
 
   /* IDirectMusicBandTrack fields */
   IDirectMusicBandTrackStream* pStream;
-  DMUS_IO_BAND_TRACK_HEADER btkHeader; /* header */
-  GUID guidID; /* unique id */
-  DMUS_IO_VERSION vVersion; /* version */
+  DMUS_IO_BAND_TRACK_HEADER* btkHeader; /* header */
+  GUID* guidID; /* unique id */
+  DMUS_IO_VERSION* vVersion; /* version */
   /* info from UNFO list */
-  WCHAR* wszName;
-  WCHAR* wszArtist;
-  WCHAR* wszCopyright;
-  WCHAR* wszSubject;
-  WCHAR* wszComment;
+  WCHAR* wzName;
+  WCHAR* wzArtist;
+  WCHAR* wzCopyright;
+  WCHAR* wzSubject;
+  WCHAR* wzComment;
+	
   /* data */
-  DMUS_PRIVATE_BAND_ITEM_HEADER pBandHeaders[255]; /* band item headers for bands */
-  IDirectMusicBandImpl* ppBands[255]; /* bands */
-  DWORD dwBands; /* nr. of IDirectMusicBandImpl* and DMUS_PRIVATE_BAND_ITEM_HEADER */
+  struct list Bands;
 };
 
 /* IUnknown: */
@@ -234,12 +253,11 @@
 extern HRESULT WINAPI IDirectMusicBandTrackStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
 extern HRESULT WINAPI IDirectMusicBandTrackStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
 
-static inline const char *debugstr_fourcc( DWORD fourcc )
-{
+static inline const char *debugstr_fourcc (DWORD fourcc) {
     if (!fourcc) return "'null'";
-    return wine_dbg_sprintf( "\'%c%c%c%c\'",
-                             (char)(fourcc), (char)(fourcc >> 8),
-                             (char)(fourcc >> 16), (char)(fourcc >> 24) );
+    return wine_dbg_sprintf ("\'%c%c%c%c\'",
+		(char)(fourcc), (char)(fourcc >> 8),
+		(char)(fourcc >> 16), (char)(fourcc >> 24));
 }
 
 #endif	/* __WINE_DMBAND_PRIVATE_H */

Attachment: signature.asc
Description: To je digitalno podpisan del =?iso-8859-2?Q?sporo=E8ila?=


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

  Powered by Linux