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

Side by Side Diff: media/audio/android/opensles_output.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 | « media/audio/android/opensles_input.cc ('k') | no next file » | 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 "media/audio/audio_util.h" 8 #include "media/audio/audio_util.h"
9 #include "media/audio/android/audio_manager_android.h" 9 #include "media/audio/android/audio_manager_android.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager, 13 OpenSLESOutputStream::OpenSLESOutputStream(AudioManagerAndroid* manager,
14 const AudioParameters& params) 14 const AudioParameters& params)
15 : audio_manager_(manager), 15 : audio_manager_(manager),
16 callback_(NULL), 16 callback_(NULL),
17 player_(NULL), 17 player_(NULL),
18 simple_buffer_queue_(NULL), 18 simple_buffer_queue_(NULL),
19 active_queue_(0), 19 active_queue_(0),
20 buffer_size_bytes_(0), 20 buffer_size_bytes_(0),
21 started_(false), 21 started_(false),
22 volume_(1.0) { 22 volume_(1.0) {
23 format_.formatType = SL_DATAFORMAT_PCM; 23 format_.formatType = SL_DATAFORMAT_PCM;
24 format_.numChannels = static_cast<SLuint32>(params.channels()); 24 format_.numChannels = static_cast<SLuint32>(params.channels());
25 // Provides sampling rate in milliHertz to OpenSLES. 25 // Provides sampling rate in milliHertz to OpenSLES.
26 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000); 26 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000);
27 format_.bitsPerSample = params.bits_per_sample(); 27 format_.bitsPerSample = params.bits_per_sample();
28 format_.containerSize = params.bits_per_sample(); 28 format_.containerSize = params.bits_per_sample();
29 format_.channelMask = SL_SPEAKER_FRONT_CENTER;
30 format_.endianness = SL_BYTEORDER_LITTLEENDIAN; 29 format_.endianness = SL_BYTEORDER_LITTLEENDIAN;
30 if (format_.numChannels == 1)
31 format_.channelMask = SL_SPEAKER_FRONT_CENTER;
32 else if (format_.numChannels == 2)
33 format_.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
34 else
35 NOTREACHED() << "Unsupported number of channels: " << format_.numChannels;
31 36
32 buffer_size_bytes_ = params.GetBytesPerBuffer(); 37 buffer_size_bytes_ = params.GetBytesPerBuffer();
33 38
34 memset(&audio_data_, 0, sizeof(audio_data_)); 39 memset(&audio_data_, 0, sizeof(audio_data_));
35 } 40 }
36 41
37 OpenSLESOutputStream::~OpenSLESOutputStream() { 42 OpenSLESOutputStream::~OpenSLESOutputStream() {
38 DCHECK(!engine_object_.Get()); 43 DCHECK(!engine_object_.Get());
39 DCHECK(!player_object_.Get()); 44 DCHECK(!player_object_.Get());
40 DCHECK(!output_mixer_.Get()); 45 DCHECK(!output_mixer_.Get());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 297 }
293 } 298 }
294 299
295 void OpenSLESOutputStream::HandleError(SLresult error) { 300 void OpenSLESOutputStream::HandleError(SLresult error) {
296 DLOG(FATAL) << "OpenSLES error " << error; 301 DLOG(FATAL) << "OpenSLES error " << error;
297 if (callback_) 302 if (callback_)
298 callback_->OnError(this, error); 303 callback_->OnError(this, error);
299 } 304 }
300 305
301 } // namespace media 306 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/android/opensles_input.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698