Error calling SoundManager::getSample()

36 views
Skip to first unread message

Kevin Godby

unread,
Jun 22, 2010, 5:52:31 AM6/22/10
to osgaudi...@googlegroups.com
Hello.

When I call getSample, it throws an exception as a result of the
createResult being set to FMOD_ERR_UNINITIALIZED in the
Sample::createSampleFromFilename() method of SampleFMOD.cpp.

I've attached an example program that demonstrates this behavior.
(This is using revision 57 of the svn trunk.)

Have I forgotten to call some initialize function?

Thanks!

--Kevin Godby

P.S. I had to modify the SampleFMOD.cpp file and recompile so that it
would print the FMOD error message in addition to the generator
FileError message from osgAudio. It would be handy of the osgAudio
messages were more informative when they're falling back on a generic
response. I just #include <fmod_errors.h> and changed the line to
throw FileError("Unknown error opening Sample file: " +
std::string(FMOD_ErrorString(createResult)));. But even printing the
FMOD error number itself would be better than nothing.

osgaudio-test.cpp

Paul Martz

unread,
Jun 22, 2010, 10:04:36 AM6/22/10
to osgaudi...@googlegroups.com
Kevin Godby wrote:
> Hello.
>
> When I call getSample, it throws an exception as a result of the
> createResult being set to FMOD_ERR_UNINITIALIZED in the
> Sample::createSampleFromFilename() method of SampleFMOD.cpp.
>
> I've attached an example program that demonstrates this behavior.
> (This is using revision 57 of the svn trunk.)
>
> Have I forgotten to call some initialize function?
>
> Thanks!
>
> --Kevin Godby

Hi Kevin -- Thanks for attaching reproducer code. I ran this with the boing.wav
file on the command line, and got the following output:

Initializing osgAudio...
Initializing FMOD. Detected 2 drivers.
0: Speakers / Headphones (SigmaTel High Definition Audio CODEC)
1: Digital Output Device (SPDIF Out) (SigmaTel High Definition Audio CODEC)
Setting distance model to osgAudio::InverseDistanceClamped...
Setting doppler factor to 1...
Creating new sound node...
If you got this far, it means it's a bug on Kevin's computer only.
Email him back and tell him he's an idiot.
SoundManager::~SoundManager(): SoundManager::shutdown() should be called for the
SoundManager before the destructor is called


I'm assuming you get different results?

(I just noticed I'm on r55, but it doesn't look like anything significant has
been committed since then. I'll update and post back if I get different results.)

> P.S. I had to modify the SampleFMOD.cpp file and recompile so that it
> would print the FMOD error message in addition to the generator
> FileError message from osgAudio. It would be handy of the osgAudio
> messages were more informative when they're falling back on a generic
> response. I just #include <fmod_errors.h> and changed the line to
> throw FileError("Unknown error opening Sample file: " +
> std::string(FMOD_ErrorString(createResult)));. But even printing the
> FMOD error number itself would be better than nothing.

Submissions are always welcome. :-)

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

Kevin Godby

unread,
Jun 22, 2010, 2:40:58 PM6/22/10
to osgaudi...@googlegroups.com
Hello, Paul.

On Tue, Jun 22, 2010 at 9:04 AM, Paul Martz <pma...@skew-matrix.com> wrote:
> Hi Kevin -- Thanks for attaching reproducer code. I ran this with the
> boing.wav file on the command line, and got the following output:
>
> Initializing osgAudio...
> Initializing FMOD. Detected 2 drivers.
> 0: Speakers / Headphones (SigmaTel High Definition Audio CODEC)
> 1: Digital Output Device (SPDIF Out) (SigmaTel High Definition Audio CODEC)
> Setting distance model to osgAudio::InverseDistanceClamped...
> Setting doppler factor to 1...
> Creating new sound node...
> If you got this far, it means it's a bug on Kevin's computer only.
> Email him back and tell him he's an idiot.
> SoundManager::~SoundManager(): SoundManager::shutdown() should be called for
> the
>  SoundManager before the destructor is called
>
>
> I'm assuming you get different results?
>
> (I just noticed I'm on r55, but it doesn't look like anything significant
> has been committed since then. I'll update and post back if I get different
> results.)

I added some more debug output to osgAudio and discovered that FMOD
was returning FMOD_ERR_OUTPUT_INIT as a result of the _system->init()
call in the AudioEnvironment::getSystem() method.

After disabling PulseAudio, and running the test program again, it
worked okay. I'll fiddle with PulseAudio on my end and see if I can
get it to play nicely with FMOD.

>> P.S. I had to modify the SampleFMOD.cpp file and recompile so that it
>> would print the FMOD error message in addition to the generator
>> FileError message from osgAudio.  It would be handy of the osgAudio
>> messages were more informative when they're falling back on a generic
>> response.  I just #include <fmod_errors.h> and changed the line to
>> throw FileError("Unknown error opening Sample file: " +
>> std::string(FMOD_ErrorString(createResult)));.  But even printing the
>> FMOD error number itself would be better than nothing.
>
> Submissions are always welcome. :-)

Perhaps if I get time later. (I'm about to go on vacation for a
couple weeks, so it'll be a while.)

In the SoundManager class I wrote for a previous project (that just
wrapped FMOD), I used the following. After each FMOD call that
returned a result I'd call errorCheck(). For example:

_result = _system->init(_soundManagerData.maxChannels,
_soundManagerData.initFlags, NULL);
errorCheck(_result, "SoundManager::init()", "");

errorCheck() looks like this:

void SoundManager::errorCheck(FMOD_RESULT result, const
std::string& func, const std::string& alias)
{
if (FMOD_OK != result)
throw SoundSystemException(FMOD_ErrorString(result), func, alias);
}

The SoundSystemException looks like this:

/**
* A sound system error occurred
*/
class SoundSystemException : public std::exception
{
public:
/**
* The SoundSystemException requires that you pass in the message you
* wish to display, the function that triggered the exception,
* and the alias of the sound used.
*/
SoundSystemException(const std::string& msg, const
std::string& func, const std::string& alias)
{
_message = func + std::string(": [") + alias +
std::string("] ") + msg;
}

virtual ~SoundSystemException() throw ()
{
// no op
}

virtual const char* what() const throw ()
{
std::string msg = "Sound System error: " + _message;
return msg.c_str();
}

private:
std::string _message;
}; // end SoundSystemException

You're welcome to use any or all of that code if you like.

--Kevin Godby

Reply all
Reply to author
Forward
0 new messages