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

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

Issue 1921963004: Add support for multichannel playback to OpenSLES output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid multichannel on KitKat. 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/android/opensles_input.cc ('k') | media/audio/android/opensles_util.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/opensles_output.h" 5 #include "media/audio/android/opensles_output.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "media/audio/android/audio_manager_android.h" 10 #include "media/audio/android/audio_manager_android.h"
(...skipping 24 matching lines...) Expand all
35 volume_(1.0) { 35 volume_(1.0) {
36 DVLOG(2) << "OpenSLESOutputStream::OpenSLESOutputStream(" 36 DVLOG(2) << "OpenSLESOutputStream::OpenSLESOutputStream("
37 << "stream_type=" << stream_type << ")"; 37 << "stream_type=" << stream_type << ")";
38 format_.formatType = SL_DATAFORMAT_PCM; 38 format_.formatType = SL_DATAFORMAT_PCM;
39 format_.numChannels = static_cast<SLuint32>(params.channels()); 39 format_.numChannels = static_cast<SLuint32>(params.channels());
40 // Provides sampling rate in milliHertz to OpenSLES. 40 // Provides sampling rate in milliHertz to OpenSLES.
41 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000); 41 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000);
42 format_.bitsPerSample = params.bits_per_sample(); 42 format_.bitsPerSample = params.bits_per_sample();
43 format_.containerSize = params.bits_per_sample(); 43 format_.containerSize = params.bits_per_sample();
44 format_.endianness = SL_BYTEORDER_LITTLEENDIAN; 44 format_.endianness = SL_BYTEORDER_LITTLEENDIAN;
45 if (format_.numChannels == 1) 45 format_.channelMask = ChannelCountToSLESChannelMask(params.channels());
46 format_.channelMask = SL_SPEAKER_FRONT_CENTER;
47 else if (format_.numChannels == 2)
48 format_.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
49 else
50 NOTREACHED() << "Unsupported number of channels: " << format_.numChannels;
51 46
52 buffer_size_bytes_ = params.GetBytesPerBuffer(); 47 buffer_size_bytes_ = params.GetBytesPerBuffer();
53 audio_bus_ = AudioBus::Create(params); 48 audio_bus_ = AudioBus::Create(params);
54 49
55 memset(&audio_data_, 0, sizeof(audio_data_)); 50 memset(&audio_data_, 0, sizeof(audio_data_));
56 } 51 }
57 52
58 OpenSLESOutputStream::~OpenSLESOutputStream() { 53 OpenSLESOutputStream::~OpenSLESOutputStream() {
59 DVLOG(2) << "OpenSLESOutputStream::~OpenSLESOutputStream()"; 54 DVLOG(2) << "OpenSLESOutputStream::~OpenSLESOutputStream()";
60 DCHECK(thread_checker_.CalledOnValidThread()); 55 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 375 }
381 } 376 }
382 377
383 void OpenSLESOutputStream::HandleError(SLresult error) { 378 void OpenSLESOutputStream::HandleError(SLresult error) {
384 DLOG(ERROR) << "OpenSLES Output error " << error; 379 DLOG(ERROR) << "OpenSLES Output error " << error;
385 if (callback_) 380 if (callback_)
386 callback_->OnError(this); 381 callback_->OnError(this);
387 } 382 }
388 383
389 } // namespace media 384 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/android/opensles_input.cc ('k') | media/audio/android/opensles_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698