Changing the output device at runtime

Zultar

02-09-2011 11:42:44

Hello folks,

I've been wondering what the correct way for reinitializing the OgreOggSound plugin at runtime would look like. (e.g. to support switching between different output devices in the middle of a running application)

So far I figured that there is no way to change the output device of an already initialized OgreOggSoundManager, so I went for unloading the plugin, reloading it and then initalizing the sound manager again. With this approach, however, I get a crash during the second initialization, according to the log right before the creation of AL sources.

The log also states that the cause of the exception is an already existing OgreOggISound object, which i find rather weird, since I unloaded the OgreOggSound plugin just before.

So the actual question is: Is this the correct/intended way of handling this and am I just doing something wrong? If it's not, what else could I try?

For reference, the code of my initialize/uninitialize functions and parts of the OGRE log:

void OgreSoundManager::initialize(const std::string &deviceName)
{
Ogre::Root::getSingleton().loadPlugin("OgreOggSound");
_soundManager = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
if (deviceName == "") _soundManager->init();
else _soundManager->init(deviceName);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../resources/audio/music", "FileSystem", "Music");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../resources/audio/sfx", "FileSystem", "SFX");
}

void OgreSoundManager::uninitialize()
{
Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup("Music");
Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup("SFX");
Ogre::Root::getSingleton().unloadPlugin("OgreOggSound");
_soundManager = NULL;
}


12:25:17: Loading library OgreOggSound
12:25:17: Installing plugin: OgreOggSound
12:25:17: MovableObjectFactory for type 'OgreOggISound' registered.
12:25:17: Plugin successfully installed
12:25:17: *****************************************
12:25:17: *** --- Initialising OgreOggSound --- ***
12:25:17: *** --- OgreOggSound v1.21 --- ***
12:25:17: *****************************************
12:25:17: *** --- OpenAL version 1.1
12:25:17: *** --- AVAILABLE DEVICES --- ***
12:25:17: *** --- SB X-Fi Audio [0001]
12:25:17: *** --- Generic Software
12:25:17: *** --- Choosing: Generic Software
12:25:17: *** --- OpenAL Device successfully created
12:25:18: *** --- OpenAL Context successfully created
12:25:18: *** --- SUPPORTED FORMATS
12:25:18: *** --- AL_FORMAT_MONO16 -- Monophonic Sound
12:25:18: *** --- AL_FORMAT_STEREO16 -- Stereo Sound
12:25:18: *** --- AL_FORMAT_QUAD16 -- 4 Channel Sound
12:25:18: *** --- AL_FORMAT_51CHN16 -- 5.1 Surround Sound
12:25:18: *** --- AL_FORMAT_61CHN16 -- 6.1 Surround Sound
12:25:18: *** --- AL_FORMAT_71CHN16 -- 7.1 Surround Sound
12:25:18: *** --- EFX Detected
12:25:18: *** --- 1 Auxiliary Effect Slot(s)
12:25:18: *** --- 1 Auxiliary Send(s) per Source
12:25:18: *** --- EFFECTS SUPPORTED:
12:25:18: *** --- 'Reverb' Support: YES
12:25:18: *** --- 'EAX Reverb' Support: YES
12:25:18: *** --- 'Chorus' Support: NO
12:25:18: *** --- 'Distortion' Support: NO
12:25:18: *** --- 'Echo' Support: NO
12:25:18: *** --- 'Flanger' Support: NO
12:25:18: *** --- 'Frequency shifter' Support: NO
12:25:18: *** --- 'Vocal Morpher' Support: NO
12:25:18: *** --- 'Pitch shifter' Support: NO
12:25:18: *** --- 'Ring modulator' Support: NO
12:25:18: *** --- 'Autowah' Support: NO
12:25:18: *** --- 'Compressor' Support: NO
12:25:18: *** --- 'Equalizer' Support: NO
12:25:18: *** --- FILTERS SUPPORTED:
12:25:18: *** --- 'Low Pass' Support: YES
12:25:18: *** --- 'High Pass' Support: NO
12:25:18: *** --- 'Band Pass' Support: NO
12:25:18: *** --- XRAM NOT Detected
12:25:18: *** --- EAX 2.0 Detected
12:25:18: *** --- Created 100 sources for simultaneous sounds
12:25:18: *** --- Using BOOST threads for streaming
12:25:18: *** --- Recording devices available:
12:25:18: ***--- 'Mikrofon (Creative SB X-Fi)'
12:25:18: ***--- 'Digital-In (Creative SB X-Fi)'
12:25:18: ***--- '"Was Sie hören" (Creative SB X-'
12:25:18: ***--- 'Mikrofon (High Definition Audio'
12:25:18: ***--- 'Eingang (High Definition Audio-'
12:25:18: *****************************************
12:25:18: *** --- OgreOggSound Initialised --- ***
12:25:18: *****************************************
12:25:18: Creating resource group Music
12:25:18: Added resource location '../resources/audio/music' of type 'FileSystem' to resource group 'Music'
12:25:18: Creating resource group SFX
12:25:18: Added resource location '../resources/audio/sfx' of type 'FileSystem' to resource group 'SFX'
12:25:18: Destroying resource group Music
12:25:18: Unloading resource group Music
12:25:18: Finished unloading resource group Music
12:25:18: Destroying resource group SFX
12:25:18: Unloading resource group SFX
12:25:18: Finished unloading resource group SFX
12:25:18: Uninstalling plugin: OgreOggSound
12:25:18: Plugin successfully uninstalled
12:25:18: Unloading library OgreOggSound
12:25:18: Loading library OgreOggSound
12:25:18: Installing plugin: OgreOggSound
12:25:18: MovableObjectFactory for type 'OgreOggISound' registered.
12:25:18: Plugin successfully installed
12:25:18: *****************************************
12:25:18: *** --- Initialising OgreOggSound --- ***
12:25:18: *** --- OgreOggSound v1.21 --- ***
12:25:18: *****************************************
12:25:18: *** --- OpenAL version 1.1
12:25:18: *** --- AVAILABLE DEVICES --- ***
12:25:18: *** --- SB X-Fi Audio [0001]
12:25:18: *** --- Generic Software
12:25:18: *** --- Choosing: SB X-Fi Audio [0001] (Default device)
12:25:18: *** --- OpenAL Device successfully created
12:25:18: *** --- OpenAL Context successfully created
12:25:18: *** --- SUPPORTED FORMATS
12:25:18: *** --- EFX Detected
12:25:18: *** --- 0 Auxiliary Effect Slot(s)
12:25:18: *** --- 1 Auxiliary Send(s) per Source
12:25:18: *** --- EFFECTS SUPPORTED:
12:25:18: *** --- 'Reverb' Support: YES
12:25:18: *** --- 'EAX Reverb' Support: YES
12:25:18: *** --- 'Chorus' Support: YES
12:25:18: *** --- 'Distortion' Support: YES
12:25:18: *** --- 'Echo' Support: YES
12:25:18: *** --- 'Flanger' Support: YES
12:25:18: *** --- 'Frequency shifter' Support: YES
12:25:18: *** --- 'Vocal Morpher' Support: YES
12:25:18: *** --- 'Pitch shifter' Support: YES
12:25:18: *** --- 'Ring modulator' Support: YES
12:25:18: *** --- 'Autowah' Support: YES
12:25:18: *** --- 'Compressor' Support: YES
12:25:18: *** --- 'Equalizer' Support: YES
12:25:18: *** --- FILTERS SUPPORTED:
12:25:18: *** --- 'Low Pass' Support: YES
12:25:18: *** --- 'High Pass' Support: NO
12:25:18: *** --- 'Band Pass' Support: NO
12:25:18: *** --- XRAM NOT Detected
12:25:18: *** --- EAX 3.0 Detected
12:25:18: OGRE EXCEPTION(4:ItemIdentityException): An object of type 'OgreOggISound' with name 'OgreOggSoundListener' already exists. in SceneManager::createMovableObject at ..\..\..\..\OgreMain\src\OgreSceneManager.cpp (line 6490)


Thanks in advance,
Zultar

stickymango

22-11-2011 22:06:05

Hi Zultar,

Looks like a possible bug, the error indicates an issue with a duplicate listener object, I'll investigate..

stickymango

22-11-2011 23:19:26

Try the latest v1.22 revision in SVN.