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

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

Issue 2795743003: Enable high latency audio on Android N+ for basic playback.
Patch Set: Created 3 years, 8 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 | « no previous file | media/audio/android/opensles_output.h » ('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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 // Pre-Lollipop devices don't support > stereo OpenSLES output and the 326 // Pre-Lollipop devices don't support > stereo OpenSLES output and the
327 // AudioManager APIs for GetOptimalOutputFrameSize() don't support channel 327 // AudioManager APIs for GetOptimalOutputFrameSize() don't support channel
328 // layouts greater than stereo unless low latency audio is supported. 328 // layouts greater than stereo unless low latency audio is supported.
329 if (input_params.channels() <= 2 || 329 if (input_params.channels() <= 2 ||
330 (base::android::BuildInfo::GetInstance()->sdk_int() >= 21 && 330 (base::android::BuildInfo::GetInstance()->sdk_int() >= 21 &&
331 IsAudioLowLatencySupported())) { 331 IsAudioLowLatencySupported())) {
332 channel_layout = input_params.channel_layout(); 332 channel_layout = input_params.channel_layout();
333 } 333 }
334 334
335 buffer_size = GetOptimalOutputFrameSize( 335 // For high latency playback, pass through the requested buffer size.
336 sample_rate, ChannelLayoutToChannelCount(channel_layout)); 336 if (input_params.latency_tag() == AudioLatency::LATENCY_PLAYBACK) {
337 buffer_size = input_params.frames_per_buffer();
338 } else {
339 buffer_size = GetOptimalOutputFrameSize(
340 sample_rate, ChannelLayoutToChannelCount(channel_layout));
341 }
337 } 342 }
338 343
339 int user_buffer_size = GetUserBufferSize(); 344 int user_buffer_size = GetUserBufferSize();
340 if (user_buffer_size) 345 if (user_buffer_size)
341 buffer_size = user_buffer_size; 346 buffer_size = user_buffer_size;
342 347
343 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 348 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
344 sample_rate, bits_per_sample, buffer_size); 349 sample_rate, bits_per_sample, buffer_size);
345 } 350 }
346 351
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 output_volume_override_ = volume; 429 output_volume_override_ = volume;
425 430
426 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 431 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
427 for (OutputStreams::iterator it = streams_.begin(); 432 for (OutputStreams::iterator it = streams_.begin();
428 it != streams_.end(); ++it) { 433 it != streams_.end(); ++it) {
429 (*it)->SetVolume(volume); 434 (*it)->SetVolume(volume);
430 } 435 }
431 } 436 }
432 437
433 } // namespace media 438 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/android/opensles_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698