IDirectMusicSegment8::Download failed?

Started by
2 comments, last by hweemiin 16 years, 9 months ago
Hi, I'm working on an application which allow users to select different games to play depending on their credits. Following is what I did: 1. Create IDirectMusicLoader8. 2. Create IDirectMusicPerformance8. 3. Create IDirectMusicAudioPath8 from performance. 4. Read data from wave file. 5. Get IDirectMusicSegment8 object from loader. 6. Calls IDirectMusicSegment8::Download to performance. 7. Repeats step 4 to 6 with 3 other files. 8. Randomly play loaded segments. 9. Stop all playing. 10. Calls IDirectMusicLoader8::ReleaseObjectByUnknown for segment. 11. Calls IDirectMusicSegment8::Unload for performance. 12. Release segment. 13. Repeats step 10 to 12 for all loaded segments. 14. Read data from the first wave file again. 15. Get IDirectMsuicSegment8 object from loader. 16. Calls IDirectMusicSegment8::Download but E_FAIL was returned. Anyone know why?
Advertisement
try use the interface IDirectMusicLoader8* for loading

example:

IDirectMusicLoader8* DSloader = NULL;

IDirectMusicSegment8* DSsegment = NULL;

//function for load file wav
bool loadFile(char* file)
{

WCHAR sound[MAX_PATH];

//convert char for WCHAR
MultiByteToWideChar(CP_ACP, 0, file, -1, sound, MAX_PATH);

//load the file
if(FAILED(DSloader->LoadObjectFromFile(CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8, sound, (void**)&DSsegment )))
return false;

//convert the segment for type WAV
DSsegment->Download( DSperformance );

return true;
}
Also, the debug runtimes should spit out some sort of error message when a function fails.
Thanks guys, I have figured out where the problem is.

It seem like I shouldn't use a global IDirectMusicLoader8 to load all wave files, cause in the DirectX manual I found a line stating that wave data should not be released before IDirectMusicLoader8 object. So now I use a local IDirectMusicLoader8 every time I want to load a wave file, and the problem gone.

This topic is closed to new replies.

Advertisement