Bug when trying to load wave files on 64-bit Ubuntu [SOLVED]

mega28

06-08-2013 09:40:17

OgreOggSound crashes with the following error when attempting to load a wave file


*****************************************
*** --- Initialising OgreOggSound --- ***
*** --- OgreOggSound v1.22 --- ***
*****************************************
*** --- OpenAL version 1.1
*** --- AVAILABLE DEVICES --- ***
*** --- OpenAL Soft
*** --- Choosing: OpenAL Soft (Default device)
*** --- OpenAL Device successfully created
*** --- OpenAL Context successfully created
*** --- SUPPORTED FORMATS
*** --- AL_FORMAT_MONO16 -- Monophonic Sound
*** --- AL_FORMAT_STEREO16 -- Stereo Sound
*** --- AL_FORMAT_QUAD16 -- 4 Channel Sound
*** --- AL_FORMAT_51CHN16 -- 5.1 Surround Sound
*** --- AL_FORMAT_61CHN16 -- 6.1 Surround Sound
*** --- AL_FORMAT_71CHN16 -- 7.1 Surround Sound
*** --- Created 100 sources for simultaneous sounds
*** --- Using BOOST threads for streaming
*****************************************
*** --- OgreOggSound Initialised --- ***
*****************************************
*** Initializing OIS ***
terminate called after throwing an instance of 'Ogre::InternalErrorException'
what(): OGRE EXCEPTION(7:InternalErrorException): Not a valid WAVE file! in OgreOggStaticWavSound::_openImpl() at /home/mega/Elbatriq/OgreOggSound-1.23/src/OgreOggStaticWavSound.cpp (line 165)

This is due to the difference in sizes of "long int" between 32 and 64-bit linux at least.

The bug disappeared for my case after changing the wave structures in OgreOggISound.h

//! CHUNK header information
// Chunk section within a wav file ('data'/'fact'/'cue' etc..)
typedef struct
{
char chunkID[4]; // 'data' or 'fact'
long int length;
} ChunkHeader;

//! WAVEFORMATEX header information
/** Structure defining a WAVE sounds format.
*/
typedef struct
{
char mRIFF[4]; // 'RIFF'
unsigned long int mLength;
char mWAVE[4]; // 'WAVE'
char mFMT[4]; // 'fmt '
unsigned int mHeaderSize; // varies...
unsigned short int mFormatTag;
unsigned short int mChannels; // 1,2 for stereo data is (l,r) pairs
unsigned long int mSamplesPerSec;
unsigned long int mAvgBytesPerSec;
unsigned short int mBlockAlign;
unsigned short int mBitsPerSample;
} WaveHeader;

//! WAVEFORMATEXTENSIBLE sound information
/** Structure defining a WAVE sounds format.
*/
typedef struct
{
WaveHeader* mFormat;
unsigned short mSamples;
unsigned long int mChannelMask;
char mSubFormat[16];
} WavFormatData;


To the following:

//! CHUNK header information
// Chunk section within a wav file ('data'/'fact'/'cue' etc..)
typedef struct
{
char chunkID[4]; // 'data' or 'fact'
int length;
} ChunkHeader;

//! WAVEFORMATEX header information
/** Structure defining a WAVE sounds format.
*/
typedef struct
{
char mRIFF[4]; // 'RIFF'
unsigned int mLength;
char mWAVE[4]; // 'WAVE'
char mFMT[4]; // 'fmt '
unsigned int mHeaderSize; // varies...
unsigned short int mFormatTag;
unsigned short int mChannels; // 1,2 for stereo data is (l,r) pairs
unsigned int mSamplesPerSec;
unsigned int mAvgBytesPerSec;
unsigned short int mBlockAlign;
unsigned short int mBitsPerSample;
} WaveHeader;

//! WAVEFORMATEXTENSIBLE sound information
/** Structure defining a WAVE sounds format.
*/
typedef struct
{
WaveHeader* mFormat;
unsigned short mSamples;
unsigned int mChannelMask;
char mSubFormat[16];
} WavFormatData;


This of course needs a better fix but it did the trick for me.
A related post: viewtopic.php?f=19&t=14791

stickymango

05-09-2013 23:41:51

Hi mega28,

Thanks for the error report and fix, I haven't looked at 64-bit builds yet so thanks for debugging that, I've committed a fix for this, if you could try it out and report back that would be great.

Much appreciated,

mega28

10-09-2013 06:21:09

Thanks for your reply.
Unfortunately no, the bug presists with the current svn revision [r425].

long int is the same as long as far as I know, so basically nothing changed in "OgreOggISound.h"

Unrelated comment:
I suggest that you add the following line to CMakeLists.txt
SET(CMAKE_DEBUG_POSTFIX "_d")
it made life a lot easier when I tried to build separate debug and release versions of the library.

stickymango

10-09-2013 11:36:24

Noted,

had a read up on portability issues, for now will stick with char/short/int which should be standardised between the 3 supported platforms, I realise this is not ideal and will look into full 32/64-bit portability throughout the lib in due course.

Edit: Committed an update for this issue, please try it out.

Thanks,

mega28

26-09-2013 00:38:31

Sorry for the late reply I didn't notice the edit till now.

That did it for me. Thanks! :)