OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/linux/audio_manager_linux.h" | 5 #include "media/audio/linux/audio_manager_linux.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 "media/audio/fake_audio_output_stream.h" |
9 #include "media/audio/linux/alsa_output.h" | 10 #include "media/audio/linux/alsa_output.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 AudioManagerLinux* g_audio_manager = NULL; | 13 AudioManagerLinux* g_audio_manager = NULL; |
13 } // namespace | 14 } // namespace |
14 | 15 |
15 // Implementation of AudioManager. | 16 // Implementation of AudioManager. |
16 bool AudioManagerLinux::HasAudioDevices() { | 17 bool AudioManagerLinux::HasAudioDevices() { |
17 // TODO(ajwong): Make this actually query audio devices. | 18 // TODO(ajwong): Make this actually query audio devices. |
18 return true; | 19 return true; |
19 } | 20 } |
20 | 21 |
21 AudioOutputStream* AudioManagerLinux::MakeAudioStream(Format format, | 22 AudioOutputStream* AudioManagerLinux::MakeAudioStream(Format format, |
22 int channels, | 23 int channels, |
23 int sample_rate, | 24 int sample_rate, |
24 char bits_per_sample) { | 25 char bits_per_sample) { |
25 // TODO(ajwong): Do we want to be able to configure the device? default | 26 // TODO(ajwong): Do we want to be able to configure the device? default |
26 // should work correctly for all mono/stereo, but not surround, which needs | 27 // should work correctly for all mono/stereo, but not surround, which needs |
27 // surround40, surround51, etc. | 28 // surround40, surround51, etc. |
28 // | 29 // |
29 // http://0pointer.de/blog/projects/guide-to-sound-apis.html | 30 // http://0pointer.de/blog/projects/guide-to-sound-apis.html |
30 AlsaPCMOutputStream* stream = | 31 if (format == AudioManager::AUDIO_MOCK) { |
31 new AlsaPCMOutputStream(AlsaPCMOutputStream::kDefaultDevice, | 32 return FakeAudioOutputStream::MakeFakeStream(); |
32 100 /* 100ms minimal buffer */, | 33 } else { |
33 format, channels, sample_rate, bits_per_sample); | 34 AlsaPCMOutputStream* stream = |
34 return stream; | 35 new AlsaPCMOutputStream(AlsaPCMOutputStream::kDefaultDevice, |
| 36 100 /* 100ms minimal buffer */, |
| 37 format, channels, sample_rate, bits_per_sample); |
| 38 return stream; |
| 39 } |
35 } | 40 } |
36 | 41 |
37 AudioManagerLinux::AudioManagerLinux() { | 42 AudioManagerLinux::AudioManagerLinux() { |
38 } | 43 } |
39 | 44 |
40 AudioManagerLinux::~AudioManagerLinux() { | 45 AudioManagerLinux::~AudioManagerLinux() { |
41 } | 46 } |
42 | 47 |
43 void AudioManagerLinux::MuteAll() { | 48 void AudioManagerLinux::MuteAll() { |
44 // TODO(ajwong): Implement. | 49 // TODO(ajwong): Implement. |
45 NOTIMPLEMENTED(); | 50 NOTIMPLEMENTED(); |
46 } | 51 } |
47 | 52 |
48 void AudioManagerLinux::UnMuteAll() { | 53 void AudioManagerLinux::UnMuteAll() { |
49 // TODO(ajwong): Implement. | 54 // TODO(ajwong): Implement. |
50 NOTIMPLEMENTED(); | 55 NOTIMPLEMENTED(); |
51 } | 56 } |
52 | 57 |
53 const void* AudioManagerLinux::GetLastMockBuffer() { | |
54 // TODO(ajwong): Implement. | |
55 NOTIMPLEMENTED(); | |
56 return NULL; | |
57 } | |
58 | |
59 // TODO(ajwong): Collapse this with the windows version. | 58 // TODO(ajwong): Collapse this with the windows version. |
60 void DestroyAudioManagerLinux(void* not_used) { | 59 void DestroyAudioManagerLinux(void* not_used) { |
61 delete g_audio_manager; | 60 delete g_audio_manager; |
62 g_audio_manager = NULL; | 61 g_audio_manager = NULL; |
63 } | 62 } |
64 | 63 |
65 AudioManager* AudioManager::GetAudioManager() { | 64 AudioManager* AudioManager::GetAudioManager() { |
66 if (!g_audio_manager) { | 65 if (!g_audio_manager) { |
67 g_audio_manager = new AudioManagerLinux(); | 66 g_audio_manager = new AudioManagerLinux(); |
68 base::AtExitManager::RegisterCallback(&DestroyAudioManagerLinux, NULL); | 67 base::AtExitManager::RegisterCallback(&DestroyAudioManagerLinux, NULL); |
69 } | 68 } |
70 return g_audio_manager; | 69 return g_audio_manager; |
71 } | 70 } |
OLD | NEW |