Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Sounds do not stop after calling ISound::stop()

Registered User
2017-05-08 01:57:41


I'm having an issue stopping sounds.

I am using a sound manager class to keep track of these sounds. I store ISound pointers in a map, and they are being loaded something like this:

irrklang::ISound * newSound = soundEngine->play2D(filepath.c_str(), false, true, true);

// Check if sound was preloaded correctly
if(newSound) m_soundMap.insert( std::pair<std::string, irrklang::ISound*>(soundName, newSound));

I have a member function that plays sounds no problem by doing something like this:

irrklang::ISound * sound = m_soundMap[soundName];

// Make sure this isn't null, god forbid a segfault happens here that would be really annoying
if(sound) soundEngine->play2D(sound->getSoundSource(), looped);

In another member function, I attempt to stop a sound:

irrklang::ISound * sound = m_soundMap[soundName];


Peculiarly, the sound continues to play after this stop method is called. With the help of a debugger, I have determined that the sounds are being loaded, found, and played correctly. The only thing that doesn't work is stopping the sound. The stop method is being called in the correct place in my project, and it almost seems that the sound->stop() and sound->drop() are being "skipped" over, but I know this isn't the issue.

I was able to force a sound to stop with the line:


However, this is not necessarily what I want since I want to be able to play a sound again without calling my load method again. I've searched through the forums for a bit looking for a solution but haven't found one. Any help getting me pointed in the right direction would be superb!


2017-05-09 07:50:50

Hm, are you sure that you are stopping the right instance of the sound? Because you are mapping them by sound name. And if you play the same sound twice, it has the same entry in the map, that way you cannot stop a nice instance anymore.

Also, when you dropping it, be sure that you forget every reference to that sound, since if you try to dereference the pointer again, it might not exist anymore.

Create reply:

Posted by: (you are not logged in)

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




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



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