From 535d18fb36f102a65daf9b95784678bb54d5ce20 Mon Sep 17 00:00:00 2001 From: althekiller Date: Sat, 19 Jun 2010 20:55:00 +0000 Subject: fixed: Make sure we hold our critical section when accessing all AudioManger members. git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31210 568bbfeb-2a22-0410-94d2-cc84cf5bfa90 --- guilib/GUIAudioManager.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'guilib/GUIAudioManager.cpp') diff --git a/guilib/GUIAudioManager.cpp b/guilib/GUIAudioManager.cpp index 7c9768dc93..e0e7e6fbb1 100644 --- a/guilib/GUIAudioManager.cpp +++ b/guilib/GUIAudioManager.cpp @@ -53,15 +53,16 @@ CGUIAudioManager::~CGUIAudioManager() void CGUIAudioManager::Initialize(int iDevice) { - if (m_bInitialized) - return; - if (g_guiSettings.GetString("lookandfeel.soundskin")=="OFF") return; if (iDevice==CAudioContext::DEFAULT_DEVICE) { CSingleLock lock(m_cs); + + if (m_bInitialized) + return; + CLog::Log(LOGDEBUG, "CGUIAudioManager::Initialize"); #ifdef _WIN32 bool bAudioOnAllSpeakers=false; @@ -81,10 +82,11 @@ void CGUIAudioManager::DeInitialize(int iDevice) { if (!(iDevice == CAudioContext::DIRECTSOUND_DEVICE || iDevice == CAudioContext::DEFAULT_DEVICE)) return; + CSingleLock lock(m_cs); + if (!m_bInitialized) return; - CSingleLock lock(m_cs); CLog::Log(LOGDEBUG, "CGUIAudioManager::DeInitialize"); if (m_actionSound) // Wait for finish when an action sound is playing @@ -169,12 +171,12 @@ void CGUIAudioManager::FreeUnused() // \brief Play a sound associated with a CAction void CGUIAudioManager::PlayActionSound(const CAction& action) { + CSingleLock lock(m_cs); + // it's not possible to play gui sounds when passthrough is active if (!m_bInitialized || g_audioContext.IsPassthroughActive()) return; - CSingleLock lock(m_cs); - actionSoundMap::iterator it=m_actionSoundMap.find(action.GetID()); if (it==m_actionSoundMap.end()) return; @@ -200,12 +202,12 @@ void CGUIAudioManager::PlayActionSound(const CAction& action) // Events: SOUND_INIT, SOUND_DEINIT void CGUIAudioManager::PlayWindowSound(int id, WINDOW_SOUND event) { + CSingleLock lock(m_cs); + // it's not possible to play gui sounds when passthrough is active if (!m_bInitialized || g_audioContext.IsPassthroughActive()) return; - CSingleLock lock(m_cs); - windowSoundMap::iterator it=m_windowSoundMap.find(id); if (it==m_windowSoundMap.end()) return; @@ -250,12 +252,12 @@ void CGUIAudioManager::PlayWindowSound(int id, WINDOW_SOUND event) // \brief Play a sound given by filename void CGUIAudioManager::PlayPythonSound(const CStdString& strFileName) { + CSingleLock lock(m_cs); + // it's not possible to play gui sounds when passthrough is active if (!m_bInitialized || g_audioContext.IsPassthroughActive()) return; - CSingleLock lock(m_cs); - // If we already loaded the sound, just play it pythonSoundsMap::iterator itsb=m_pythonSounds.find(strFileName); if (itsb!=m_pythonSounds.end()) @@ -286,6 +288,8 @@ void CGUIAudioManager::PlayPythonSound(const CStdString& strFileName) // xbmc bool CGUIAudioManager::Load() { + CSingleLock lock(m_cs); + m_actionSoundMap.clear(); m_windowSoundMap.clear(); -- cgit v1.2.3