From f53400cd04d77af49302b6d76b6499ff6725348d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 2 Jul 2009 16:24:17 +0000 Subject: [PATCH] Applied patch from IRC user case__, adding support for FmodAudioManager::set_volume/get_volume --- panda/src/audiotraits/fmodAudioManager.cxx | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 4d9fd85848..1bc0fcb5f0 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -515,25 +515,40 @@ setSpeakerSetup(AudioManager::SpeakerModeCategory cat) { //////////////////////////////////////////////////////////////////// // Function: FmodAudioManager::set_volume(float volume) // Access: Public -// Description: -// There isn't a specific system volume function in FMOD-EX, -// so this function is moot now. +// Description: Sets the master volume. //////////////////////////////////////////////////////////////////// void FmodAudioManager::set_volume(float volume) { - audio_warning("FmodAudioManager::set_volume has no effect." ); + FMOD::ChannelGroup *channelGroup; + FMOD_RESULT result; + + result = _system->getMasterChannelGroup(&channelGroup); + if (result == FMOD_OK) { + channelGroup->setVolume(volume); + } else { + fmod_audio_errcheck("_system->getMasterChannelGroup()", result); + } } //////////////////////////////////////////////////////////////////// // Function: FmodAudioManager::get_volume() // Access: Public -// Description: -// There isn't a specific system volume function in FMOD-EX, -// so this function is moot now. +// Description: Returns the master volume. //////////////////////////////////////////////////////////////////// float FmodAudioManager:: get_volume() const { - audio_warning("FmodAudioManager::get_volume has no effect." ); - return 1.0; + FMOD::ChannelGroup *channelGroup; + FMOD_RESULT result; + float volume; + + result = _system->getMasterChannelGroup(&channelGroup); + if (result == FMOD_OK) { + channelGroup->getVolume(&volume); + } else { + fmod_audio_errcheck("_system->getMasterChannelGroup()", result); + volume = 1.0; + } + + return volume; } ////////////////////////////////////////////////////////////////////