I’ve recently hit a problem loading MIDI files whereby the file passed in isn’t released properly (I get an access sharing violation if I then try and do any other operation on the file). This is highlighted by the following code:
FMOD_System_CreateSound(m_FMODSystem, "temp.mid", FMOD_HARDWARE, 0, lsound);
DWORD lerrorno = GetLastError();
In the above code, the DeleteFile function fails, and the GetLastError call returns 32 (ERROR_SHARING_VIOLATION – The process cannot access the file because it is being used by another process).
I presume this is because CreateSound has opened the passed in filename but failed to close it again.
Note that this problem only seems to occur with MIDI files, for other file types the above code works and the temp file is deleted correctly.
BTW – I’m running WinXP.
- George Gilbert asked 12 years ago
That’s great thankyou. A few quick follow up questions:
1) When you say “until it is released”, does this mean until I call FMOD_Sound_Release or will the file be released asynchronously a short time after FMOD_System_Create_Sound is called (in which case, how can I detect this)?
2) Presumably if I load the file into memory myself and then call onto FMOD_Sound_Release with the memory pointer then I can work around this and manipulate the *.mid file before waiting for the sound object to be released?
3) Is it only MIDI files that require the file to be available throughout the time the sound is loaded or are there any other formats?
4) Is there a quick way of determining the format of a file from its contents (as opposed to looking at the filename extension) via an FMODEx API (specifically, not by first calling FMOD_System_Create_Sound) so I can do something different for MIDI files (see Q2) than I do for any others?
Please login first to submit.