I’d like to be able to know if the channel passed into the callback has started playing something else between stopping and the Update function being called, but it looks like FMOD_Channel_IsPlaying always returns true for the channel object given to the callback, even if the update function is not called for several seconds after the sound finished, which seems odd – is this expected behavior? What is the right way to tell?
- DuncanC asked 11 years ago
Thanks for taking a second look. The reason I wanted this was that I want to maintain an associative array of channel to sound, with rows set and cleared by wrapped versions of Play and Stop, and cleared also by a sound ending. If I just cleared the row in the callback unconditionally, then there could be times (I realize probably not very often) that a channel came to a natural stop and then started playing something else in the interval between two updates, and the channel’s array entry would be erroneously cleared. After the patch goes through, is there any other good reason why I wouldn’t be able to do this? (I realize there is an existing function for getting the current sound for a channel, that’s not the purpose of the array.)
- DuncanC answered 11 years ago
As the callback is called from the main thread from System::update I dont think you’re going to get any situation that you described, but anyway it is pretty much an aesthetic issue – the channel is obviously stopped when you get the end callback, so clearing your value is good enough when the callback occurs – and yes Channel::getCurrentSound is probably more efficient.
At the moment it looks like fmod’s new channel management code to not pick a voice until it has REALLY stopped (ie it could still be in the mixer thread) is leaving the state of the channel as playing for a few more ms. This is good for internal channel selection reasons (and it removes criticalsection stalls waiting for the mixer to stop before reusing the channel) it is not as good for the user, i’ll see if i can make it bypass that logic for the user call.
ok scratch that it just looks like the channel is not marked as stopped until the channel callback is finished.
If it wasn’t, you would just be getting FMOD_ERR_INVALID_HANDLE for every function you tried to call on the channel pointer. (rendering the handle useless).
Please login first to submit.