[SOLVED](SVN) Playing sound crashes app


26-09-2009 00:18:14

Hey Sticky!

First off thanks for the library. :)

Last night I was playing sound on my laptop just fine. Today I tried on my tower at work, and the game crashes when trying to play a sound. I checked out OgreOggSound and built from source so I could provide some debug info, I hope it helps.

When the crash occurs I get the following message:

Unhandled exception at 0x01e9940d (OgreOggSound_d.dll) in RotM_d.exe:
0xC0000094: Integer division by zero.

The offending line (OgreOggStaticWavSound.cpp):

mPlayTime = ((mFormatData.mFormat->mLength-mAudioOffset) / ((mFormatData.mFormat->mBitsPerSample/8) * mFormatData.mFormat->mSamplesPerSec)) / mFormatData.mFormat->mChannels;

mBitsPerSample is 0.

Also note that I have installed the OpenAL redist and the SDK on this machine. I'm also using the Threaded version, with Boost.

And for reference, here is my code:

std::string SoundManager::playAmbientSound(const std::string& fileName)
std::string name = "AutoNameGeneratedSound" + Ogre::StringConverter::toString(mAutoNameCounter++);

OgreOggSound::OgreOggISound* sound = mOgreOggSoundManager->createSound(name,fileName);

return name;

Hope this helps. If mBitsPerSample is not supposed to be 0, we should gaurd against it.

[Edit] As it turns out, I'm using some random .wav that I downloaded online (it plays in media player). When I tried to play the same wav I played on my laptop, everything worked fine.. [/Edit]


26-09-2009 10:01:03

Last night I was debugging a couple of problem wav files by co-incidence and found I was not reading wav files correctly, I have since committed a fix which should now handle wav audio correctly, could you try that and see if it fixes your problem?

There is a check for the mBitsPerSample in the load function which should return an error if it isn't 8/16, not sure how that was skipped for your file, I'll check :?

[Edit] Plugged a possible escape route in WAV load function for compressed wav files, it should now generate an exception when encountering this type of file, I've noticed they are quite common audio files from the internet, maybe this was the cause...[Edit]


29-09-2009 00:00:25

Ok tested it out, I get an exception, as designed:

15:58:49: *** --- OgreOggStaticWavSound::open() - Compressed WAV NOT supported!!
15:59:35: *** --- OgreOggStaticWavSound::open() - Unable to load audio data into buffer!!


29-09-2009 09:51:43

Is this issue now solved?


29-09-2009 18:26:51

Yes thanks, I have updated the title.