# \[iOS\] Certain WAV files triggering channel end callback prematurely.

**URL:** <https://qa.fmod.com/t/ios-certain-wav-files-triggering-channel-end-callback-prematurely/11556>\
**Category:** FMOD Engine\
**Created:** [July 13, 2014, 3:49am UTC](https://qa.fmod.com/t/ios-certain-wav-files-triggering-channel-end-callback-prematurely/11556 "2014-07-13T03:49:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davef](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@davef](https://qa.fmod.com/u/davef)\
**Post date:** [July 13, 2014, 3:49am UTC](https://qa.fmod.com/t/ios-certain-wav-files-triggering-channel-end-callback-prematurely/11556/1 "2014-07-13T03:49:25Z")

</div>

This sound created with Adobe Audition CC - [https://dl.dropboxusercontent.com/u/3571256/test-sound.wav](https://dl.dropboxusercontent.com/u/3571256/test-sound.wav) will trigger FMOD\_CHANNELCONTROL\_CALLBACK\_END twice. Once immediately on playback and then a second time when the sound ends.

Expectation would be FMOD\_CHANNELCONTROL\_CALLBACK\_END is only called when the sound finishes.

I have replicated the issue using the play\_sound example project and changing the button 1 action to look like:

```
    if (Common_BtnPress(BTN_ACTION1))
    {
        
        result = system->playSound(sound1, 0, false, &channel);
        channel->setCallback((FMOD_CHANNELCONTROL_CALLBACK)&ChannelControlCallback);
        ERRCHECK(result);
    }    

```

and then adding the callback

```
    static FMOD_RESULT F_CALLBACK ChannelControlCallback(FMOD_CHANNEL *channel,
                                                                FMOD_CHANNELCONTROL_CALLBACK_TYPE type,
                                                                unsigned int commanddata1,
                                                                unsigned int commanddata2) {
        if (type == FMOD_CHANNELCONTROL_CALLBACK_END) {
            printf("ChannelControlCallback: Sound finished\n");
        }
	    return FMOD_OK;
    }

```

When playing test-sound.wav I see “ChannelControlCallback: Sound finished” twice. When playing drumloop.wav I only see it once (when the sound actually finishes).

---

<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:** [July 14, 2014, 1:04am UTC](https://qa.fmod.com/t/ios-certain-wav-files-triggering-channel-end-callback-prematurely/11556/2 "2014-07-14T01:04:21Z")

</div>

You have the wrong signature for your callback, you’re missing the second argument. The correct code would look like:

`static FMOD_RESULT F_CALLBACK ChannelControlCallback(FMOD_CHANNELCONTROL *channelcontrol, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype, void *commanddata1, void *commanddata2)`

The FMOD\_CHANNELCONTROL\_TYPE argument is new in FMOD 5, and represents if the callback is happening on a Channel or a ChannelGroup.

You wav file has a tempo marker syncpoint at the start. FMOD is trying to send the syncpoint hit callback. You callback is mixing the arguments around and interpreting it as a channel end callback.
