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_base.h" | 5 #include "media/audio/audio_manager_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/audio/audio_output_dispatcher.h" | 10 #include "media/audio/audio_output_dispatcher.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // See bug: http://crbug.com/30242. | 77 // See bug: http://crbug.com/30242. |
78 if (num_output_streams_ >= max_num_output_streams_) { | 78 if (num_output_streams_ >= max_num_output_streams_) { |
79 DLOG(ERROR) << "Number of opened output audio streams " | 79 DLOG(ERROR) << "Number of opened output audio streams " |
80 << num_output_streams_ | 80 << num_output_streams_ |
81 << " exceed the max allowed number " | 81 << " exceed the max allowed number " |
82 << max_num_output_streams_; | 82 << max_num_output_streams_; |
83 return NULL; | 83 return NULL; |
84 } | 84 } |
85 | 85 |
86 AudioOutputStream* stream = NULL; | 86 AudioOutputStream* stream = NULL; |
87 if (params.format == AudioParameters::AUDIO_MOCK) { | 87 if (params.format() == AudioParameters::AUDIO_MOCK) { |
88 stream = FakeAudioOutputStream::MakeFakeStream(this, params); | 88 stream = FakeAudioOutputStream::MakeFakeStream(this, params); |
89 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 89 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { |
90 stream = MakeLinearOutputStream(params); | 90 stream = MakeLinearOutputStream(params); |
91 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 91 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
92 stream = MakeLowLatencyOutputStream(params); | 92 stream = MakeLowLatencyOutputStream(params); |
93 } | 93 } |
94 | 94 |
95 if (stream) | 95 if (stream) |
96 ++num_output_streams_; | 96 ++num_output_streams_; |
97 | 97 |
98 return stream; | 98 return stream; |
99 } | 99 } |
100 | 100 |
101 AudioInputStream* AudioManagerBase::MakeAudioInputStream( | 101 AudioInputStream* AudioManagerBase::MakeAudioInputStream( |
102 const AudioParameters& params, const std::string& device_id) { | 102 const AudioParameters& params, const std::string& device_id) { |
103 if (!params.IsValid() || (params.channels > kMaxInputChannels) || | 103 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || |
104 device_id.empty()) { | 104 device_id.empty()) { |
105 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; | 105 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
108 | 108 |
109 if (num_input_streams_ >= max_num_input_streams_) { | 109 if (num_input_streams_ >= max_num_input_streams_) { |
110 DLOG(ERROR) << "Number of opened input audio streams " | 110 DLOG(ERROR) << "Number of opened input audio streams " |
111 << num_input_streams_ | 111 << num_input_streams_ |
112 << " exceed the max allowed number " << max_num_input_streams_; | 112 << " exceed the max allowed number " << max_num_input_streams_; |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
116 AudioInputStream* stream = NULL; | 116 AudioInputStream* stream = NULL; |
117 if (params.format == AudioParameters::AUDIO_MOCK) { | 117 if (params.format() == AudioParameters::AUDIO_MOCK) { |
118 stream = FakeAudioInputStream::MakeFakeStream(this, params); | 118 stream = FakeAudioInputStream::MakeFakeStream(this, params); |
119 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 119 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { |
120 stream = MakeLinearInputStream(params, device_id); | 120 stream = MakeLinearInputStream(params, device_id); |
121 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 121 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
122 stream = MakeLowLatencyInputStream(params, device_id); | 122 stream = MakeLowLatencyInputStream(params, device_id); |
123 } | 123 } |
124 | 124 |
125 if (stream) | 125 if (stream) |
126 ++num_input_streams_; | 126 ++num_input_streams_; |
127 | 127 |
128 return stream; | 128 return stream; |
129 } | 129 } |
130 | 130 |
131 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( | 131 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // both physical audio stream objects that belong to the dispatcher as | 219 // both physical audio stream objects that belong to the dispatcher as |
220 // well as the message loop of the audio thread that will soon go away. | 220 // well as the message loop of the audio thread that will soon go away. |
221 // So, better crash now than later. | 221 // So, better crash now than later. |
222 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; | 222 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; |
223 dispatcher = NULL; | 223 dispatcher = NULL; |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 output_dispatchers_.clear(); | 227 output_dispatchers_.clear(); |
228 } | 228 } |
OLD | NEW |