Starting sound paused, then unpausing causes strange behavior

After initializing system/sounds, I have a “play sound” function that is very simple:

FMOD_CHANNEL *channel = 0;

void play_audio(AudioResID id)
    {
      result = FMOD_System_PlaySound(fmod_sys, sounds[id], 0, true, &channel);
      ERRCHECK(result);
      result = FMOD_Channel_SetVolume(channel, 0.2f);
      ERRCHECK(result);
      result = FMOD_Channel_SetPaused(channel, false);
      ERRCHECK(result);
    }

If I remove the volume/setpaused functions and just do PlaySound with “paused” set to FALSE, the sound plays perfectly fine. However, when I use the code above, the first sound does not play at all, then when the second sound is triggered, the first sound begins playing. The third sound triggers the second sound, and so on.

I am calling FMOD_System_Update() regularly.

You need to call FMOD_System_Update() on a regular basis.

You’re problem is with the command queue. FMOD_Channel_SetPaused is being batched, which is why I suggested FMOD_System_Update() as the correct solution, and why functions such as playSound which contain an implicit flush make your previous channel unpause.

Are you checking the return code from FMOD_System_Update?

// This is a heavy weight command: it will flush all batched commands and execute straight away
system->playSound(sound1, 0, true, &channel);

// this is a light weight command, it will be batched
channel->setVolume(0.2f);

// this is also a light weight command, it will be batched
channel->setPaused(false);

// this is another heavy weight command, it will flush the setvolume & setpaused commands and execute straight away
FMOD::DSP* head;
channel->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &head);

// this will flush all batched commands, as well as updating the system state
system->update();

Edit

I want to clarify that which commands automatically flush the queue and execute immediately, and which will be batched may change in later revisions without documentation. The only function guaranteed to flush commands is System::update().