OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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_io.h" | 5 #include "media/audio/audio_io.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 | 9 |
10 #include "base/at_exit.h" | |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "media/audio/fake_audio_input_stream.h" | 11 #include "media/audio/fake_audio_input_stream.h" |
13 #include "media/audio/fake_audio_output_stream.h" | 12 #include "media/audio/fake_audio_output_stream.h" |
14 #include "media/audio/win/audio_manager_win.h" | 13 #include "media/audio/win/audio_manager_win.h" |
15 #include "media/audio/win/wavein_input_win.h" | 14 #include "media/audio/win/wavein_input_win.h" |
16 #include "media/audio/win/waveout_output_win.h" | 15 #include "media/audio/win/waveout_output_win.h" |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 // The next 3 constants are some sensible limits to prevent integer overflow | 19 // The next 3 constants are some sensible limits to prevent integer overflow |
(...skipping 14 matching lines...) Expand all Loading... |
35 | 34 |
36 const int kMaxInputChannels = 2; | 35 const int kMaxInputChannels = 2; |
37 const int kMaxSamplesPerPacket = kMaxSampleRate; | 36 const int kMaxSamplesPerPacket = kMaxSampleRate; |
38 // We use 3 buffers for recording audio so that if a recording callback takes | 37 // We use 3 buffers for recording audio so that if a recording callback takes |
39 // some time to return we won't lose audio. More buffers while recording are | 38 // some time to return we won't lose audio. More buffers while recording are |
40 // ok because they don't introduce any delay in recording, unlike in playback | 39 // ok because they don't introduce any delay in recording, unlike in playback |
41 // where you first need to fill in that number of buffers before starting to | 40 // where you first need to fill in that number of buffers before starting to |
42 // play. | 41 // play. |
43 const int kNumInputBuffers = 3; | 42 const int kNumInputBuffers = 3; |
44 | 43 |
45 AudioManagerWin* g_audio_manager = NULL; | |
46 | |
47 } // namespace. | 44 } // namespace. |
48 | 45 |
49 bool AudioManagerWin::HasAudioOutputDevices() { | 46 bool AudioManagerWin::HasAudioOutputDevices() { |
50 return (::waveOutGetNumDevs() != 0); | 47 return (::waveOutGetNumDevs() != 0); |
51 } | 48 } |
52 | 49 |
53 bool AudioManagerWin::HasAudioInputDevices() { | 50 bool AudioManagerWin::HasAudioInputDevices() { |
54 return (::waveInGetNumDevs() != 0); | 51 return (::waveInGetNumDevs() != 0); |
55 } | 52 } |
56 | 53 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 115 |
119 void AudioManagerWin::MuteAll() { | 116 void AudioManagerWin::MuteAll() { |
120 } | 117 } |
121 | 118 |
122 void AudioManagerWin::UnMuteAll() { | 119 void AudioManagerWin::UnMuteAll() { |
123 } | 120 } |
124 | 121 |
125 AudioManagerWin::~AudioManagerWin() { | 122 AudioManagerWin::~AudioManagerWin() { |
126 } | 123 } |
127 | 124 |
128 void DestroyAudioManagerWin(void* param) { | 125 // static |
129 delete g_audio_manager; | 126 AudioManager* AudioManager::CreateAudioManager() { |
130 g_audio_manager = NULL; | 127 return new AudioManagerWin(); |
131 } | 128 } |
132 | |
133 AudioManager* AudioManager::GetAudioManager() { | |
134 if (!g_audio_manager) { | |
135 g_audio_manager = new AudioManagerWin(); | |
136 base::AtExitManager::RegisterCallback(&DestroyAudioManagerWin, NULL); | |
137 } | |
138 return g_audio_manager; | |
139 } | |
OLD | NEW |