| OLD | NEW |
| 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 "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 21 matching lines...) Expand all Loading... |
| 32 started_(false), | 32 started_(false), |
| 33 audio_bus_(media::AudioBus::Create(params)) { | 33 audio_bus_(media::AudioBus::Create(params)) { |
| 34 DVLOG(2) << __PRETTY_FUNCTION__; | 34 DVLOG(2) << __PRETTY_FUNCTION__; |
| 35 format_.formatType = SL_DATAFORMAT_PCM; | 35 format_.formatType = SL_DATAFORMAT_PCM; |
| 36 format_.numChannels = static_cast<SLuint32>(params.channels()); | 36 format_.numChannels = static_cast<SLuint32>(params.channels()); |
| 37 // Provides sampling rate in milliHertz to OpenSLES. | 37 // Provides sampling rate in milliHertz to OpenSLES. |
| 38 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000); | 38 format_.samplesPerSec = static_cast<SLuint32>(params.sample_rate() * 1000); |
| 39 format_.bitsPerSample = params.bits_per_sample(); | 39 format_.bitsPerSample = params.bits_per_sample(); |
| 40 format_.containerSize = params.bits_per_sample(); | 40 format_.containerSize = params.bits_per_sample(); |
| 41 format_.endianness = SL_BYTEORDER_LITTLEENDIAN; | 41 format_.endianness = SL_BYTEORDER_LITTLEENDIAN; |
| 42 if (format_.numChannels == 1) | 42 format_.channelMask = ChannelCountToSLESChannelMask(params.channels()); |
| 43 format_.channelMask = SL_SPEAKER_FRONT_CENTER; | |
| 44 else if (format_.numChannels == 2) | |
| 45 format_.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; | |
| 46 else | |
| 47 NOTREACHED() << "Unsupported number of channels: " << format_.numChannels; | |
| 48 | 43 |
| 49 buffer_size_bytes_ = params.GetBytesPerBuffer(); | 44 buffer_size_bytes_ = params.GetBytesPerBuffer(); |
| 50 | 45 |
| 51 memset(&audio_data_, 0, sizeof(audio_data_)); | 46 memset(&audio_data_, 0, sizeof(audio_data_)); |
| 52 } | 47 } |
| 53 | 48 |
| 54 OpenSLESInputStream::~OpenSLESInputStream() { | 49 OpenSLESInputStream::~OpenSLESInputStream() { |
| 55 DVLOG(2) << __PRETTY_FUNCTION__; | 50 DVLOG(2) << __PRETTY_FUNCTION__; |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 DCHECK(!recorder_object_.Get()); | 52 DCHECK(!recorder_object_.Get()); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 337 } |
| 343 } | 338 } |
| 344 | 339 |
| 345 void OpenSLESInputStream::HandleError(SLresult error) { | 340 void OpenSLESInputStream::HandleError(SLresult error) { |
| 346 DLOG(ERROR) << "OpenSLES Input error " << error; | 341 DLOG(ERROR) << "OpenSLES Input error " << error; |
| 347 if (callback_) | 342 if (callback_) |
| 348 callback_->OnError(this); | 343 callback_->OnError(this); |
| 349 } | 344 } |
| 350 | 345 |
| 351 } // namespace media | 346 } // namespace media |
| OLD | NEW |