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

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

Issue 10855218: Correct channel mask on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed the comments. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/android/opensles_output.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/opensles_input.h" 5 #include "media/audio/android/opensles_input.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/audio/android/audio_manager_android.h" 8 #include "media/audio/android/audio_manager_android.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 OpenSLESInputStream::OpenSLESInputStream(AudioManagerAndroid* audio_manager, 12 OpenSLESInputStream::OpenSLESInputStream(AudioManagerAndroid* audio_manager,
13 const AudioParameters& params) 13 const AudioParameters& params)
14 : audio_manager_(audio_manager), 14 : audio_manager_(audio_manager),
15 callback_(NULL), 15 callback_(NULL),
16 recorder_(NULL), 16 recorder_(NULL),
17 simple_buffer_queue_(NULL), 17 simple_buffer_queue_(NULL),
18 active_queue_(0), 18 active_queue_(0),
19 buffer_size_bytes_(0), 19 buffer_size_bytes_(0),
20 started_(false) { 20 started_(false) {
21 format_.formatType = SL_DATAFORMAT_PCM; 21 format_.formatType = SL_DATAFORMAT_PCM;
22 format_.numChannels = static_cast<SLuint32>(params.channels()); 22 format_.numChannels = static_cast<SLuint32>(params.channels());
23 // Provides sampling rate in milliHertz to OpenSLES. 23 // Provides sampling rate in milliHertz to OpenSLES.
24 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000); 24 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000);
25 format_.bitsPerSample = params.bits_per_sample(); 25 format_.bitsPerSample = params.bits_per_sample();
26 format_.containerSize = params.bits_per_sample(); 26 format_.containerSize = params.bits_per_sample();
27 format_.channelMask = SL_SPEAKER_FRONT_CENTER;
28 format_.endianness = SL_BYTEORDER_LITTLEENDIAN; 27 format_.endianness = SL_BYTEORDER_LITTLEENDIAN;
28 if (format_.numChannels == 1)
29 format_.channelMask = SL_SPEAKER_FRONT_CENTER;
30 else if (format_.numChannels == 2)
31 format_.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
32 else
33 NOTREACHED() << "Unsupported number of channels: " << format_.numChannels;
29 34
30 buffer_size_bytes_ = params.GetBytesPerBuffer(); 35 buffer_size_bytes_ = params.GetBytesPerBuffer();
31 36
32 memset(&audio_data_, 0, sizeof(audio_data_)); 37 memset(&audio_data_, 0, sizeof(audio_data_));
33 } 38 }
34 39
35 OpenSLESInputStream::~OpenSLESInputStream() { 40 OpenSLESInputStream::~OpenSLESInputStream() {
36 DCHECK(!recorder_object_.Get()); 41 DCHECK(!recorder_object_.Get());
37 DCHECK(!engine_object_.Get()); 42 DCHECK(!engine_object_.Get());
38 DCHECK(!recorder_); 43 DCHECK(!recorder_);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 292 }
288 } 293 }
289 294
290 void OpenSLESInputStream::HandleError(SLresult error) { 295 void OpenSLESInputStream::HandleError(SLresult error) {
291 DLOG(FATAL) << "OpenSLES error " << error; 296 DLOG(FATAL) << "OpenSLES error " << error;
292 if (callback_) 297 if (callback_)
293 callback_->OnError(this, error); 298 callback_->OnError(this, error);
294 } 299 }
295 300
296 } // namespace media 301 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/android/opensles_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698