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

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

Issue 1967833002: Merge M51: "Add support for multichannel playback to OpenSLES output." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/android/opensles_input.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 295 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
296 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; 296 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
297 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; 297 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
298 int sample_rate = GetNativeOutputSampleRate(); 298 int sample_rate = GetNativeOutputSampleRate();
299 int buffer_size = GetOptimalOutputFrameSize(sample_rate, 2); 299 int buffer_size = GetOptimalOutputFrameSize(sample_rate, 2);
300 int bits_per_sample = 16; 300 int bits_per_sample = 16;
301 if (input_params.IsValid()) { 301 if (input_params.IsValid()) {
302 // Use the client's input parameters if they are valid. 302 // Use the client's input parameters if they are valid.
303 sample_rate = input_params.sample_rate(); 303 sample_rate = input_params.sample_rate();
304 bits_per_sample = input_params.bits_per_sample(); 304 bits_per_sample = input_params.bits_per_sample();
305 channel_layout = input_params.channel_layout(); 305
306 // Pre-Lollipop devices don't support > stereo OpenSLES output and the
307 // AudioManager APIs for GetOptimalOutputFrameSize() don't support channel
308 // layouts greater than stereo unless low latency audio is supported.
309 if (input_params.channels() <= 2 ||
310 (base::android::BuildInfo::GetInstance()->sdk_int() >= 21 &&
311 IsAudioLowLatencySupported())) {
312 channel_layout = input_params.channel_layout();
313 }
314
306 buffer_size = GetOptimalOutputFrameSize( 315 buffer_size = GetOptimalOutputFrameSize(
307 sample_rate, ChannelLayoutToChannelCount(channel_layout)); 316 sample_rate, ChannelLayoutToChannelCount(channel_layout));
308 } 317 }
309 318
310 int user_buffer_size = GetUserBufferSize(); 319 int user_buffer_size = GetUserBufferSize();
311 if (user_buffer_size) 320 if (user_buffer_size)
312 buffer_size = user_buffer_size; 321 buffer_size = user_buffer_size;
313 322
314 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 323 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
315 sample_rate, bits_per_sample, buffer_size); 324 sample_rate, bits_per_sample, buffer_size);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 output_volume_override_ = volume; 418 output_volume_override_ = volume;
410 419
411 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 420 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
412 for (OutputStreams::iterator it = streams_.begin(); 421 for (OutputStreams::iterator it = streams_.begin();
413 it != streams_.end(); ++it) { 422 it != streams_.end(); ++it) {
414 (*it)->SetVolume(volume); 423 (*it)->SetVolume(volume);
415 } 424 }
416 } 425 }
417 426
418 } // namespace media 427 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/android/opensles_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698