Will end of the sound cause channel to be reused by priority system?

(Vasiliy Yanushevich) #1

I’m integrating fmod low-level API for our very simple use case and binding some functionality to Lua. I have a wrapper object for Channel with some control API (like pause, resume, volume, position), that keeps reference to channel returned by System::playSound call. Here is list of questions that will make things more clear (I’m using C API):

  1. Is channel reused automatically if sound is over (i.e played all loops to the end)?
  2. Is FMOD_CHANNEL reference gets invalidated once underlying channel is reused?
  3. If I keep reference to the stopped channel, will it remain invalid even if another sound is started at the same channel ID?

(Brett Paterson) #2

If a channel plays a sound to the end, the channel will go invalid after this point, so if you keep trying to update it, it will give you FMOD_ERR_INVALID_HANDLE. Same as if you stopped it manually.
The call to System::update transforms the channel from valid to invalid if this end of sound case happens.

Yes, if you keep a handle to the stopped channel, it will still be invalid if another sound is played on the same channel. It follows the process as described above.
Channel handles are reference counted so an old handle can’t be used to update a new instance of the same channel.

(Vasiliy Yanushevich) #3

Thanks, it works just as expected.