OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/audio/audio_manager.h" | |
6 | |
7 #include "base/at_exit.h" | |
8 #include "base/logging.h" | |
9 | |
10 namespace { | |
11 | |
12 AudioManager* g_audio_manager = NULL; | |
13 | |
14 // NullAudioManager is the audio manager used on the systems that have no | |
15 // audio support. | |
16 class NullAudioManager : public AudioManager { | |
17 public: | |
18 NullAudioManager() { } | |
19 | |
20 // Implementation of AudioManager. | |
21 virtual bool HasAudioOutputDevices() { return false; } | |
22 virtual bool HasAudioInputDevices() { return false; } | |
23 virtual AudioOutputStream* MakeAudioOutputStream(Format format, int channels, | |
24 int sample_rate, | |
25 char bits_per_sample) { | |
26 NOTIMPLEMENTED(); | |
27 return NULL; | |
28 } | |
29 virtual AudioInputStream* MakeAudioInputStream(Format format, int channels, | |
30 int sample_rate, | |
31 char bits_per_sample, | |
32 uint32 samples_per_packet) { | |
33 NOTIMPLEMENTED(); | |
34 return NULL; | |
35 } | |
36 virtual void MuteAll() { NOTIMPLEMENTED(); } | |
37 virtual void UnMuteAll() { NOTIMPLEMENTED(); } | |
38 | |
39 private: | |
40 DISALLOW_COPY_AND_ASSIGN(NullAudioManager); | |
41 }; | |
42 | |
43 } // namespace | |
44 | |
45 // static | |
46 void AudioManager::Destroy(void* not_used) { | |
47 delete g_audio_manager; | |
48 g_audio_manager = NULL; | |
49 } | |
50 | |
51 // static | |
52 AudioManager* AudioManager::GetAudioManager() { | |
53 if (!g_audio_manager) { | |
54 g_audio_manager = CreateAudioManager(); | |
55 g_audio_manager->Init(); | |
56 base::AtExitManager::RegisterCallback(&AudioManager::Destroy, NULL); | |
57 } | |
58 return g_audio_manager; | |
59 } | |
OLD | NEW |