From c4b74f1ab67a21fee79a8f60b4ab667755304e7e Mon Sep 17 00:00:00 2001 From: "tommi@chromium.org" Date: Fri, 25 Nov 2011 11:06:17 +0000 Subject: Expose a way for unit tests to terminate the AudioManager singleton to avoid conflicts between tests. This fixes occasional crashes when running audio tests manually (won't happen on the bots right now since they don't have the required hardware). TEST=Run content tests with --gtest_filter=*WebRTC* --gtest_repeat=1000 BUG=none Review URL: http://codereview.chromium.org/8558022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111586 0039d316-1c4b-4281-b951-d872f2087c98 --- media/audio/audio_manager.cc | 10 ++++++++++ media/audio/audio_manager.h | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'media') diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc index b11cb9c..45c67f9 100644 --- a/media/audio/audio_manager.cc +++ b/media/audio/audio_manager.cc @@ -32,3 +32,13 @@ AudioManager* AudioManager::GetAudioManager() { } return g_audio_manager; } + +// static +bool AudioManager::SingletonExists() { + return g_audio_manager != NULL; +} + +// static +void AudioManager::Resurrect() { + g_destroy_called = false; +} diff --git a/media/audio/audio_manager.h b/media/audio/audio_manager.h index eb94831..817761a 100644 --- a/media/audio/audio_manager.h +++ b/media/audio/audio_manager.h @@ -120,7 +120,11 @@ class MEDIA_EXPORT AudioManager { virtual void Cleanup() = 0; private: + // Allow unit tests to delete and recreate the singleton. + friend class AutoAudioManagerCleanup; static void Destroy(void*); + static bool SingletonExists(); + static void Resurrect(); // Called by GetAudioManager() to create platform-specific audio manager. static AudioManager* CreateAudioManager(); -- cgit v1.1