Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Not sure if I'm doing it right

DrFail
Guest
Quote
2012-06-17 15:54:23

Hello,
In my current project I'm using Irrklang inside a sound managing class. When I play a sound, everything seems to work fine. But when I looked up the Task Manager, i've seen that everytime the sound is played the memory usage increses. So i'm not sure if I use Irrklang the right way.

Here's the code I'm using:
Sound-Manager class:

private:
irrklang::ISoundEngine* soundEngine;
std::vector<irrklang::ISoundSource*> sounds;

irrklang::ISound* music;

bool musicIsOn;

void loadSounds (void)
{
The function loads all filenames including the paths and puts the Sound sources into a vector.
sounds.push_back( soundEngine->addSoundSourceFromFile(file.c_str()) );
}


public:
void start (void)
{
soundEngine = createIrrKlangDevice();
loadSounds();
}

void playMusic (int ID)
{
stopCurrentMusic();
if (musicIsOn)
{
music = soundEngine->play2D(sounds.at(ID), true, false, true);
}
}

void stopCurrentMusic (void)
{
if (music)
{
music->setIsPaused(true);
music->stop();
}
}

Could somebody tell me what's wrong?


erik
Registered User
Quote
2012-06-17 16:55:29

After Music->stop(), add a music->drop() in order to free its memory.


DrFail
Guest
Quote
2012-06-17 17:43:54

Thanks, that was it.
And is it possible that the ISound object cleares up itself, after the sound stops playing?


niko
Moderator
Quote
2012-06-17 18:55:51

Sure, you just call drop() immideately, after you don't need the pointer anymore. The music will continue playing, and the memory gets freed automatically then after it finished.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact