# HG changeset patch # User nemo # Date 1356371534 18000 # Node ID 023a71940f26cf9ac4e4815552b48fa6e14e850f # Parent ecd51650d5d8d4aea470be2d58024ddf50566e45 Don't play sounds in chat if sound is disabled, try to prevent sound crashes by checking for audio init failure. diff -r ecd51650d5d8 -r 023a71940f26 QTfrontend/ui/mouseoverfilter.cpp --- a/QTfrontend/ui/mouseoverfilter.cpp Mon Dec 24 17:07:12 2012 +0100 +++ b/QTfrontend/ui/mouseoverfilter.cpp Mon Dec 24 12:52:14 2012 -0500 @@ -39,7 +39,7 @@ QComboBox * droplist = dynamic_cast(dist); QSlider * slider = dynamic_cast(dist); QTabWidget * tab = dynamic_cast(dist); - if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) + if (button || textfield || checkbox || droplist || slider || tab) { SDLInteraction::instance().playSoundFile("/Sounds/steps.ogg"); } diff -r ecd51650d5d8 -r 023a71940f26 QTfrontend/ui/widget/qpushbuttonwithsound.cpp --- a/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Mon Dec 24 17:07:12 2012 +0100 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Mon Dec 24 12:52:14 2012 -0500 @@ -33,7 +33,7 @@ void QPushButtonWithSound::buttonClicked() { - if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled()) + if ( !isSoundEnabled ) return; if (this->isEnabled()) diff -r ecd51650d5d8 -r 023a71940f26 QTfrontend/util/SDLInteraction.cpp --- a/QTfrontend/util/SDLInteraction.cpp Mon Dec 24 17:07:12 2012 +0100 +++ b/QTfrontend/util/SDLInteraction.cpp Mon Dec 24 12:52:14 2012 -0500 @@ -25,6 +25,8 @@ #include "SDL_mixer.h" #include "HWApplication.h" +#include "hwform.h" /* you know, we could just put a config singleton lookup function in gameuiconfig or something... */ +#include "gameuiconfig.h" #include "SDLInteraction.h" @@ -186,14 +188,16 @@ return; SDL_Init(SDL_INIT_AUDIO); - Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); - m_audioInitialized = true; + if(!Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)) /* should we keep trying, or just turn off permanently? */ + m_audioInitialized = true; } void SDLInteraction::playSoundFile(const QString & soundFile) { + if (!HWForm::config || !HWForm::config->isFrontendSoundEnabled()) return; SDLAudioInit(); + if (!m_audioInitialized) return; if (!m_soundMap->contains(soundFile)) m_soundMap->insert(soundFile, Mix_LoadWAV_RW(PHYSFSRWOPS_openRead(soundFile.toLocal8Bit().constData()), 1)); @@ -232,6 +236,7 @@ return; SDLAudioInit(); + if (!m_audioInitialized) return; if (m_music == NULL) m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()));