OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 | 10 |
11 // Used only to make sure we never create more than one instance. | |
12 static AudioManager* g_audio_manager = NULL; | |
13 | |
14 // Forward declaration of the platform specific AudioManager factory function. | 11 // Forward declaration of the platform specific AudioManager factory function. |
15 AudioManager* CreateAudioManager(); | 12 AudioManager* CreateAudioManager(); |
16 | 13 |
17 AudioManager::AudioManager() { | 14 AudioManager::AudioManager() { |
18 CHECK(g_audio_manager == NULL); | |
19 g_audio_manager = this; | |
20 } | 15 } |
21 | 16 |
22 AudioManager::~AudioManager() { | 17 AudioManager::~AudioManager() { |
23 CHECK(g_audio_manager == this); | |
24 g_audio_manager = NULL; | |
25 } | 18 } |
26 | 19 |
27 // static | 20 // static |
28 AudioManager* AudioManager::Create() { | 21 AudioManager* AudioManager::Create() { |
29 AudioManager* ret = CreateAudioManager(); | 22 AudioManager* ret = CreateAudioManager(); |
30 DCHECK(ret == g_audio_manager); | |
31 ret->Init(); | 23 ret->Init(); |
32 return ret; | 24 return ret; |
33 } | 25 } |
OLD | NEW |