# Starting sound paused, then unpausing causes strange behavior

**URL:** <https://qa.fmod.com/t/starting-sound-paused-then-unpausing-causes-strange-behavior/11701>\
**Category:** FMOD Engine\
**Created:** [October 27, 2014, 2:46pm UTC](https://qa.fmod.com/t/starting-sound-paused-then-unpausing-causes-strange-behavior/11701 "2014-10-27T14:46:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![svern](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@svern](https://qa.fmod.com/u/svern)\
**Post date:** [October 27, 2014, 2:46pm UTC](https://qa.fmod.com/t/starting-sound-paused-then-unpausing-causes-strange-behavior/11701/1 "2014-10-27T14:46:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [October 28, 2014, 12:24am UTC](https://qa.fmod.com/t/starting-sound-paused-then-unpausing-causes-strange-behavior/11701/2 "2014-10-28T00:24:56Z")

</div>

You need to call FMOD\_System\_Update() on a regular basis.

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [October 28, 2014, 12:57am UTC](https://qa.fmod.com/t/starting-sound-paused-then-unpausing-causes-strange-behavior/11701/3 "2014-10-28T00:57:41Z")

</div>

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().
