0
0

Hi,
I am currently writing a little wrapper around FMOD, for getting used to it. But I always get an exception when executing a specific part of code. I Debugged it and found out, that all system and sound are valid pointers to valid objects, so thats not a cause for the exception. What also keeps me thinking is, that I handle all kind of exceptions through catch(…), but still the debugger sais the exception is unhandled. Can you guys help me please?

[code:1z85o7ea]
FMOD::Channel* temp;
Channel* temp2 = 0;
try
{
if(system->playSound(FMOD_CHANNEL_FREE, sound->getSound(), true, &temp) == FMOD_OK)
{
temp2 = new Channel(this, temp);
channels.push_back(temp2);
}
}
catch(...)
{}
return temp2;
[/code:1z85o7ea]

Edit: the Version of my fmodex.dll is 0.4.18.1 and Im using windows

Thanks in advance

CrimsonKing

  • You must to post comments
0
0

Why dont you upgrade to the latest 4.18.4 stable? The unhandled exception should occur in fmods engine, the reason may be that your code try to access non initialized or invalid objects, but i also get ue’s (that i cant handle) as soon as my code doesnt release the engine object before quit. It also kills the whole ide on me (vb6).

  • You must to post comments
0
0

I have updated now, but the problem isnt solved or changed
Edit: I checked all used objects, they are all valid and proper, so that cant be the reason. The exception occurs in the line with playsound, so not shutting down the engine cant be part of the problem either

  • You must to post comments
0
0

have you tried
system->playSound(FMOD_CHANNEL_FREE, sound, true, &temp) ?

i usually code this C style, so not sure sure on the wwhole object things, but this is what I do in C
[code:1pknuk17]
//create a stream
fmodError = FMOD_System_CreateStream(fmodSystem, sFile, fmodFlags, NULL, &fmodSound);
if (fmodError != FMOD_OK)
{
lstPlaylist.Items[Settings.Index].Font = &ItemErrorFont;
return fmodError;
}

//create a channel and play a sound on it
fmodError = FMOD_System_PlaySound(fmodSystem,FMOD_CHANNEL_FREE,fmodSound,false, &fmodChannel);
if (fmodError != FMOD_OK) 
{
    lstPlaylist.Items[Settings.Index].Font = &ItemErrorFont;
    return fmodError;
}

[/code:1pknuk17]

instead of using sound->getSound(), just reference sound… i think that might work.

  • You must to post comments
0
0

I am using a wrapper class in my code above and the sound object in there is not of type FMOD::Sound* but MyNamespace::Sound, which contains an FMOD::Sound pointer. Therefore I cant give playSound the sound pointer. But thanks for trying

  • You must to post comments
0
0

perhaps if you show us a little more code (like where you have things defined and where you actually create the stream) we can help you a little more.

  • You must to post comments
0
0

Here is my code, but I fear its a little long, but thanks to anyone willing to read through it to help me!

There is some input code being used in here, I dont think it has anything to do with the error, but if you wish, I can post it here too.

SoundServer.hpp
[code:q4x62acn]

ifndef SOUNDSERVER_HPP

define SOUNDSERVER_HPP

include "fmod.hpp"

include <vector>

namespace Sound2D
{

class Sound;
class SoundServer;
class Channel
{
private:
    FMOD::Channel* channel;
    SoundServer* server;
public:
    Channel(SoundServer*, FMOD::Channel*);
    bool setVolume(float);
    bool setPriority(int);
    bool setPaused(bool);
};

class Sound
{
private:
    SoundServer* server;
    FMOD::Sound* sound;
public:
    Sound(FMOD::Sound*, SoundServer*);
    Channel* play();
    FMOD::Sound* getSound();
};

class SoundServer
{
private:
    SoundServer();
    SoundServer(SoundServer&amp;);
    static SoundServer* Singleton;
    std::vector&lt;Channel*&gt; channels;
    std::vector&lt;Sound*&gt; sounds;
    FMOD::System* system;
public:
    ~SoundServer();
    static SoundServer* getSingleton();

    void update();

    Sound* loadSample(std::string);
    Sound* loadStream(std::string);
    Sound* loadCompressedSample(std::string);

    Channel* play(Sound*);
};

}

endif

[/code:q4x62acn]

SoundServer.cpp
[code:q4x62acn]

include "SoundServer.hpp"

include <iostream>

include <exception>

Sound2D::SoundServer* Sound2D::SoundServer::Singleton = 0;

Sound2D::Channel::Channel(SoundServer* ser, FMOD::Channel* chan)
{
channel = chan;
server = ser;
}

bool Sound2D::Channel::setVolume(float volume)
{
return channel->setVolume(volume) == FMOD_OK;
}

bool Sound2D::Channel::setPriority(int priority)
{
return channel->setPriority(priority) == FMOD_OK;
}

bool Sound2D::Channel::setPaused(bool pause)
{
return channel->setPaused(pause);
}

Sound2D::Sound::Sound(FMOD::Sound * soun, Sound2D::SoundServer *serv)
{
server = serv;
sound = sound;
}

Sound2D::Channel* Sound2D::Sound::play()
{
return server->play(this);
}

Sound2D::SoundServer::SoundServer()
{
if(FMOD::System_Create(&system) == FMOD_OK)
if(system->init(200,FMOD_INIT_NORMAL, 0) == FMOD_OK);
}

Sound2D::SoundServer::SoundServer(Sound2D::SoundServer &){}

Sound2D::Sound* Sound2D::SoundServer::loadSample(std::string file)
{
FMOD::Sound* temp = 0;
Sound* temp2 = 0;
if(system->createSound(file.c_str(), FMOD_DEFAULT, 0, &temp) == FMOD_OK)
{
temp2 = new Sound(temp, this);
sounds.push_back (temp2);
}
else
return 0;
return temp2;
}

Sound2D::Sound* Sound2D::SoundServer::loadStream(std::string file)
{
FMOD::Sound* temp;
Sound* temp2;
if(system->createStream(file.c_str(), FMOD_DEFAULT, 0, &temp) == FMOD_OK)
{
temp2 = new Sound(temp, this);
sounds.push_back(temp2);
}
else
return 0;
return temp2;
}

Sound2D::Sound* Sound2D::SoundServer::loadCompressedSample(std::string file)
{
FMOD::Sound* temp;
Sound* temp2 = 0;
if(system->createSound(file.c_str(), FMOD_CREATECOMPRESSEDSAMPLE, 0, &temp) == FMOD_OK)
{
temp2 = new Sound(temp, this);
sounds.push_back(temp2);
}
else
return 0;
return temp2;
}

Sound2D::Channel* Sound2D::SoundServer::play(Sound2D::Sound sound)
{
FMOD::Channel
temp;
Channel* temp2 = 0;
try
{
if(system->playSound(FMOD_CHANNEL_FREE, sound->getSound(), true, &temp) == FMOD_OK)
{
temp2 = new Channel(this, temp);
channels.push_back(temp2);
}
}
catch(...)
{}
return temp2;
}

FMOD::Sound* Sound2D::Sound::getSound()
{
return sound;
}

Sound2D::SoundServer* Sound2D::SoundServer::getSingleton()
{
if(!Singleton)
Singleton = new SoundServer();
return Singleton;
}

Sound2D::SoundServer::~SoundServer(){}

void Sound2D::SoundServer::update()
{
system->update();
}
[/code:q4x62acn]

main.cpp
[code:q4x62acn]

include "SoundServer.hpp"

include "Input.hpp"

include <SDL.h>

include <SDL_syswm.h>

class Key : public Input::KeyListener
{
public:
bool run;
Key(Sound2D::Channel* ch, Sound2D::SoundServer* s){run=true;pause = false; channel = ch; sound = s;}
bool pause;
Sound2D::SoundServer* sound;
Sound2D::Channel* channel;
void HandleKeyEvent()
{
if(!KeyBuffer.empty())
{
Input::KeyListener::KeyEvent* temp = KeyBuffer.front();
if(temp->code == Input::KC_SPACE)
{
pause = !pause;
channel->setPaused(pause);
}
else if(temp->code == Input::KC_ESCAPE)
{
run = false;
}
KeyBuffer.pop_front();
delete temp;
}
}
};

int main(int argc, char** argv)
{

freopen( &quot;stdout.txt&quot;, &quot;wt&quot;, stdout );
freopen( &quot;stderr.txt&quot;, &quot;wt&quot;, stderr );

SDL_Init(SDL_INIT_VIDEO);
SDL_Surface* screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);

SDL_SysWMinfo wmInfo;
SDL_VERSION(&amp;wmInfo.version);
SDL_GetWMInfo(&amp;wmInfo);
HWND hWnd = (HWND) wmInfo.window;

std::ostringstream wnd;
wnd &lt;&lt; (std::size_t)hWnd;

std::locale::global(std::locale(&quot;german&quot;));

Input::Input* in = Input::Input::getSingleton(wnd,800,600);

Sound2D::SoundServer* sound = Sound2D::SoundServer::getSingleton();
Sound2D::Sound* song = sound-&gt;loadSample(&quot;test2.mp3&quot;);
Sound2D::Channel* temp = song-&gt;play();


Key* kb = new Key(temp, sound);
in-&gt;addKeyListener(kb,&quot;ee&quot;);

while(kb-&gt;run)
{
    in-&gt;capture();
    kb-&gt;HandleKeyEvent();
    sound-&gt;update();
}

delete in;
delete kb;
delete sound;
SDL_Quit();
return 0;

}
[/code:q4x62acn]

  • You must to post comments
0
0

[code:1ovdug3g]
Sound2D::Sound::Sound(FMOD::Sound * soun, Sound2D::SoundServer *serv)
{
server = serv;
sound = sound;
}
[/code:1ovdug3g]

I’m guessing you mean this to read: [code:1ovdug3g]sound = soun;[/code:1ovdug3g] This could be giving you an invalid handle to pass to playSound.

Hope this helps.

  • You must to post comments
0
0

[quote="PeterStirling":35av8mf2][code:35av8mf2]
Sound2D::Sound::Sound(FMOD::Sound * soun, Sound2D::SoundServer *serv)
{
server = serv;
sound = sound;
}
[/code:35av8mf2]

I’m guessing you mean this to read: [code:35av8mf2]sound = soun;[/code:35av8mf2] This could be giving you an invalid handle to pass to playSound.

Hope this helps.[/quote:35av8mf2]
Shoudn’t FMOD return something like FMOD_ERR_INVALID_HANDLE in this case?

  • You must to post comments
0
0

[quote:1fainne7]Shoudn’t FMOD return something like FMOD_ERR_INVALID_HANDLE in this case?[/quote:1fainne7]
No. It would be a lot of overhead for FMOD to check every object you pass to it and would slow things down. The channels handles often become invalid, so it makes sense to check those. It’s your responsibility to pass in a valid sound object.
This shouldn’t be difficult to debug, if you let the code run in debug mode and break at the exception you can go to the line of code where it breaks and check the value of the parameters you are passing in, you’ll see that you have an object which hasn’t been initialized (sound = 0xcccccccc).

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.