| 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/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/context_utils.h" | 8 #include "base/android/context_utils.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 307 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 308 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; | 308 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; |
| 309 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 309 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
| 310 int sample_rate = GetNativeOutputSampleRate(); | 310 int sample_rate = GetNativeOutputSampleRate(); |
| 311 int buffer_size = GetOptimalOutputFrameSize(sample_rate, 2); | 311 int buffer_size = GetOptimalOutputFrameSize(sample_rate, 2); |
| 312 int bits_per_sample = 16; | 312 int bits_per_sample = 16; |
| 313 if (input_params.IsValid()) { | 313 if (input_params.IsValid()) { |
| 314 // Use the client's input parameters if they are valid. | 314 // Use the client's input parameters if they are valid. |
| 315 sample_rate = input_params.sample_rate(); | 315 sample_rate = input_params.sample_rate(); |
| 316 bits_per_sample = input_params.bits_per_sample(); | 316 bits_per_sample = input_params.bits_per_sample(); |
| 317 channel_layout = input_params.channel_layout(); | 317 |
| 318 // Pre-Lollipop devices don't support > stereo OpenSLES output and the |
| 319 // AudioManager APIs for GetOptimalOutputFrameSize() don't support channel |
| 320 // layouts greater than stereo unless low latency audio is supported. |
| 321 if (input_params.channels() <= 2 || |
| 322 (base::android::BuildInfo::GetInstance()->sdk_int() >= 21 && |
| 323 IsAudioLowLatencySupported())) { |
| 324 channel_layout = input_params.channel_layout(); |
| 325 } |
| 326 |
| 318 buffer_size = GetOptimalOutputFrameSize( | 327 buffer_size = GetOptimalOutputFrameSize( |
| 319 sample_rate, ChannelLayoutToChannelCount(channel_layout)); | 328 sample_rate, ChannelLayoutToChannelCount(channel_layout)); |
| 320 } | 329 } |
| 321 | 330 |
| 322 int user_buffer_size = GetUserBufferSize(); | 331 int user_buffer_size = GetUserBufferSize(); |
| 323 if (user_buffer_size) | 332 if (user_buffer_size) |
| 324 buffer_size = user_buffer_size; | 333 buffer_size = user_buffer_size; |
| 325 | 334 |
| 326 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | 335 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
| 327 sample_rate, bits_per_sample, buffer_size); | 336 sample_rate, bits_per_sample, buffer_size); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 output_volume_override_ = volume; | 420 output_volume_override_ = volume; |
| 412 | 421 |
| 413 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 422 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 414 for (OutputStreams::iterator it = streams_.begin(); | 423 for (OutputStreams::iterator it = streams_.begin(); |
| 415 it != streams_.end(); ++it) { | 424 it != streams_.end(); ++it) { |
| 416 (*it)->SetVolume(volume); | 425 (*it)->SetVolume(volume); |
| 417 } | 426 } |
| 418 } | 427 } |
| 419 | 428 |
| 420 } // namespace media | 429 } // namespace media |
| OLD | NEW |