Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: media/audio/android/audio_manager_android.cc

Issue 2917203002: Add MuteableAudioOutputStream interface to export SetMute(). (Closed)
Patch Set: Bug fixed Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/android/audio_manager_android.h" 5 #include "media/audio/android/audio_manager_android.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 AudioOutputStream* AudioManagerAndroid::MakeAudioOutputStream( 166 AudioOutputStream* AudioManagerAndroid::MakeAudioOutputStream(
167 const AudioParameters& params, 167 const AudioParameters& params,
168 const std::string& device_id, 168 const std::string& device_id,
169 const LogCallback& log_callback) { 169 const LogCallback& log_callback) {
170 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 170 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
171 AudioOutputStream* stream = AudioManagerBase::MakeAudioOutputStream( 171 AudioOutputStream* stream = AudioManagerBase::MakeAudioOutputStream(
172 params, std::string(), AudioManager::LogCallback()); 172 params, std::string(), AudioManager::LogCallback());
173 if (stream) 173 if (stream)
174 streams_.insert(static_cast<OpenSLESOutputStream*>(stream)); 174 streams_.insert(static_cast<MuteableAudioOutputStream*>(stream));
175 return stream; 175 return stream;
176 } 176 }
177 177
178 AudioInputStream* AudioManagerAndroid::MakeAudioInputStream( 178 AudioInputStream* AudioManagerAndroid::MakeAudioInputStream(
179 const AudioParameters& params, 179 const AudioParameters& params,
180 const std::string& device_id, 180 const std::string& device_id,
181 const LogCallback& log_callback) { 181 const LogCallback& log_callback) {
182 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 182 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
183 bool has_no_input_streams = HasNoAudioInputStreams(); 183 bool has_no_input_streams = HasNoAudioInputStreams();
184 AudioInputStream* stream = AudioManagerBase::MakeAudioInputStream( 184 AudioInputStream* stream = AudioManagerBase::MakeAudioInputStream(
185 params, device_id, AudioManager::LogCallback()); 185 params, device_id, AudioManager::LogCallback());
186 186
187 // The audio manager for Android creates streams intended for real-time 187 // The audio manager for Android creates streams intended for real-time
188 // VoIP sessions and therefore sets the audio mode to MODE_IN_COMMUNICATION. 188 // VoIP sessions and therefore sets the audio mode to MODE_IN_COMMUNICATION.
189 // If a Bluetooth headset is used, the audio stream will use the SCO 189 // If a Bluetooth headset is used, the audio stream will use the SCO
190 // channel and therefore have a limited bandwidth (8kHz). 190 // channel and therefore have a limited bandwidth (8kHz).
191 if (stream && has_no_input_streams) { 191 if (stream && has_no_input_streams) {
192 communication_mode_is_on_ = true; 192 communication_mode_is_on_ = true;
193 SetCommunicationAudioModeOn(true); 193 SetCommunicationAudioModeOn(true);
194 } 194 }
195 return stream; 195 return stream;
196 } 196 }
197 197
198 void AudioManagerAndroid::ReleaseOutputStream(AudioOutputStream* stream) { 198 void AudioManagerAndroid::ReleaseOutputStream(AudioOutputStream* stream) {
199 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 199 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
200 streams_.erase(static_cast<OpenSLESOutputStream*>(stream)); 200 streams_.erase(static_cast<MuteableAudioOutputStream*>(stream));
201 AudioManagerBase::ReleaseOutputStream(stream); 201 AudioManagerBase::ReleaseOutputStream(stream);
202 } 202 }
203 203
204 void AudioManagerAndroid::ReleaseInputStream(AudioInputStream* stream) { 204 void AudioManagerAndroid::ReleaseInputStream(AudioInputStream* stream) {
205 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 205 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
206 AudioManagerBase::ReleaseInputStream(stream); 206 AudioManagerBase::ReleaseInputStream(stream);
207 207
208 // Restore the audio mode which was used before the first communication- 208 // Restore the audio mode which was used before the first communication-
209 // mode stream was created. 209 // mode stream was created.
210 if (HasNoAudioInputStreams()) { 210 if (HasNoAudioInputStreams()) {
(...skipping 17 matching lines...) Expand all
228 DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!"; 228 DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!";
229 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); 229 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
230 230
231 // Set stream type which matches the current system-wide audio mode used by 231 // Set stream type which matches the current system-wide audio mode used by
232 // the Android audio manager. 232 // the Android audio manager.
233 const SLint32 stream_type = communication_mode_is_on_ ? 233 const SLint32 stream_type = communication_mode_is_on_ ?
234 SL_ANDROID_STREAM_VOICE : SL_ANDROID_STREAM_MEDIA; 234 SL_ANDROID_STREAM_VOICE : SL_ANDROID_STREAM_MEDIA;
235 return new OpenSLESOutputStream(this, params, stream_type); 235 return new OpenSLESOutputStream(this, params, stream_type);
236 } 236 }
237 237
238 AudioOutputStream* AudioManagerAndroid::MakeBitstreamOutputStream(
239 const AudioParameters& params,
240 const std::string& device_id,
241 const LogCallback& log_callback) {
242 // TODO(tsunghung): add output stream for audio bitstream formats.
243 NOTREACHED();
244 return nullptr;
245 }
246
238 AudioInputStream* AudioManagerAndroid::MakeLinearInputStream( 247 AudioInputStream* AudioManagerAndroid::MakeLinearInputStream(
239 const AudioParameters& params, 248 const AudioParameters& params,
240 const std::string& device_id, 249 const std::string& device_id,
241 const LogCallback& log_callback) { 250 const LogCallback& log_callback) {
242 // TODO(henrika): add support for device selection if/when any client 251 // TODO(henrika): add support for device selection if/when any client
243 // needs it. 252 // needs it.
244 DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!"; 253 DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!";
245 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); 254 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
246 return new OpenSLESInputStream(this, params); 255 return new OpenSLESInputStream(this, params);
247 } 256 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 output_volume_override_ = volume; 430 output_volume_override_ = volume;
422 431
423 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 432 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
424 for (OutputStreams::iterator it = streams_.begin(); 433 for (OutputStreams::iterator it = streams_.begin();
425 it != streams_.end(); ++it) { 434 it != streams_.end(); ++it) {
426 (*it)->SetVolume(volume); 435 (*it)->SetVolume(volume);
427 } 436 }
428 } 437 }
429 438
430 } // namespace media 439 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/android/audio_manager_android.h ('k') | media/audio/android/muteable_audio_output_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698