Dear FMOD Support,
I stumbled upon a bug which seems to be caused by the FMOD engine, and not by me.
It seems to be caused by a conditional transition region, in combination with a “system.update()” call.
I have included the FMOD project, and example code (modified from the simple event example).
Here is how to reproduce:
- Copy “DontCallUs.bank” to the resource directory of the examples
- Replace “simple event.cpp” with my copy (copy-paste below)
- Run the example on a real iPhone (I used iPhone5). It does NOT happen in the simulator!
- Press “A” to start event.
Your help would be very much appreciated.
Mark
simple event.cpp
#include "fmod_studio.hpp"
#include "fmod.hpp"
#include "common.h"
#include <stdio.h>
FMOD::Studio::System pSystem;
FMOD::Studio::Bank masterBank;
FMOD::Studio::EventInstance eventInstance;
void startAudio() {
//Load Bank
ERRCHECK( pSystem.loadBank(Common_MediaPath("DontCallUs.bank"), &masterBank) );
//Load event
FMOD::Studio::ID loopingAmbienceID = {0};
ERRCHECK( FMOD::Studio::parseID("{6fea8e2b-6d94-419e-b211-9e83aafbf7fe}", &loopingAmbienceID) );
FMOD::Studio::EventDescription loopingAmbienceDescription;
ERRCHECK( pSystem.getEvent(&loopingAmbienceID, FMOD_STUDIO_LOAD_BEGIN_NOW, &loopingAmbienceDescription) );
ERRCHECK( loopingAmbienceDescription.createInstance(&eventInstance) );
//Start event
ERRCHECK( eventInstance.start());
}
const char* drawStatus() {
int position = 0;
float volume = 0.0;
bool paused = false;
const char* playbackeStateStr;
const char* loadingStateStr;
if(eventInstance.isValid()) {
eventInstance.getTimelinePosition(&position);
eventInstance.getVolume(&volume);
eventInstance.getPaused(&paused);
FMOD_STUDIO_PLAYBACK_STATE playbackState;
eventInstance.getPlaybackState(&playbackState);
switch (playbackState) {
case FMOD_STUDIO_PLAYBACK_IDLE:
playbackeStateStr = "IDLE"; break;
case FMOD_STUDIO_PLAYBACK_PLAYING:
playbackeStateStr = "PLAYING"; break;
case FMOD_STUDIO_PLAYBACK_STOPPED:
playbackeStateStr = "STOPPED"; break;
case FMOD_STUDIO_PLAYBACK_SUSTAINING:
playbackeStateStr = "SUSTAINING"; break;
}
FMOD_STUDIO_LOADING_STATE loadingState;
eventInstance.getLoadingState(&loadingState);
switch (loadingState) {
case FMOD_STUDIO_LOADING_STATE_LOADED:
loadingStateStr = "LOADED"; break;
case FMOD_STUDIO_LOADING_STATE_LOADING:
loadingStateStr = "LOADING"; break;
case FMOD_STUDIO_LOADING_STATE_UNLOADED:
loadingStateStr = "UNLOADED"; break;
case FMOD_STUDIO_LOADING_STATE_UNLOADING:
loadingStateStr = "UNLOADING"; break;
}
} else {
playbackeStateStr = "...";
loadingStateStr = "...";
}
FMOD::System* system;
pSystem.getLowLevelSystem(&system);
int channels;
system->getChannelsPlaying(&channels);
Common_Draw("Loading: %s; Pos: %i; Vol: %f; Paused: %s; Playback: %s; Used Channels: %i",loadingStateStr,position,volume,(paused?"Yes":"No"),playbackeStateStr,channels);
}
int FMOD_Main()
{
// Init FMOD::STUDIO::SYSTEM
void *extraDriverData = 0;
Common_Init(&extraDriverData);
ERRCHECK( FMOD::Studio::System::create(&pSystem) );
ERRCHECK( pSystem.initialize(32, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData) );
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
startAudio();
}
ERRCHECK( pSystem.update() );
Common_Draw("==================================================");
Common_Draw("Crash with conditional transition region ");
Common_Draw("==================================================");
Common_Draw("");
Common_Draw("Press %s to CRASH", Common_BtnStr(BTN_ACTION1));
Common_Draw("Press %s to quit", Common_BtnStr(BTN_QUIT));
Common_Draw("", Common_BtnStr(BTN_QUIT));
drawStatus();
Common_Sleep(50);
} while (!Common_BtnPress(BTN_QUIT));
ERRCHECK( pSystem.release() );
Common_Close();
return 0;
}