OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/audio_manager.h" | 5 #include "media/audio/audio_manager.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace { | 10 static bool g_destroy_called = false; |
11 | 11 static AudioManager* g_audio_manager = NULL; |
12 bool g_destroy_called = false; | |
13 AudioManager* g_audio_manager = NULL; | |
14 | |
15 } // namespace | |
16 | 12 |
17 // static | 13 // static |
18 void AudioManager::Destroy(void* not_used) { | 14 void AudioManager::Destroy(void* not_used) { |
19 g_destroy_called = true; | 15 g_destroy_called = true; |
20 | 16 |
21 g_audio_manager->Cleanup(); | 17 g_audio_manager->Cleanup(); |
22 | 18 |
23 AudioManager* audio_manager = g_audio_manager; | 19 AudioManager* audio_manager = g_audio_manager; |
24 g_audio_manager = NULL; | 20 g_audio_manager = NULL; |
25 delete audio_manager; | 21 delete audio_manager; |
26 } | 22 } |
27 | 23 |
28 // static | 24 // static |
29 AudioManager* AudioManager::GetAudioManager() { | 25 AudioManager* AudioManager::GetAudioManager() { |
30 if (!g_audio_manager && !g_destroy_called) { | 26 if (!g_audio_manager && !g_destroy_called) { |
31 g_audio_manager = CreateAudioManager(); | 27 g_audio_manager = CreateAudioManager(); |
32 g_audio_manager->Init(); | 28 g_audio_manager->Init(); |
33 base::AtExitManager::RegisterCallback(&AudioManager::Destroy, NULL); | 29 base::AtExitManager::RegisterCallback(&AudioManager::Destroy, NULL); |
34 } | 30 } |
35 return g_audio_manager; | 31 return g_audio_manager; |
36 } | 32 } |
OLD | NEW |