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/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "media/audio/android/audio_manager_android.h" | 9 #include "media/audio/android/audio_manager_android.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (SL_RESULT_SUCCESS != err) | 320 if (SL_RESULT_SUCCESS != err) |
321 HandleError(err); | 321 HandleError(err); |
322 | 322 |
323 active_buffer_index_ = (active_buffer_index_ + 1) % kMaxNumOfBuffersInQueue; | 323 active_buffer_index_ = (active_buffer_index_ + 1) % kMaxNumOfBuffersInQueue; |
324 } | 324 } |
325 | 325 |
326 void OpenSLESInputStream::SetupAudioBuffer() { | 326 void OpenSLESInputStream::SetupAudioBuffer() { |
327 DCHECK(thread_checker_.CalledOnValidThread()); | 327 DCHECK(thread_checker_.CalledOnValidThread()); |
328 DCHECK(!audio_data_[0]); | 328 DCHECK(!audio_data_[0]); |
329 for (int i = 0; i < kMaxNumOfBuffersInQueue; ++i) { | 329 for (int i = 0; i < kMaxNumOfBuffersInQueue; ++i) { |
330 audio_data_[i] = new uint8[buffer_size_bytes_]; | 330 audio_data_[i] = new uint8_t[buffer_size_bytes_]; |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 void OpenSLESInputStream::ReleaseAudioBuffer() { | 334 void OpenSLESInputStream::ReleaseAudioBuffer() { |
335 DCHECK(thread_checker_.CalledOnValidThread()); | 335 DCHECK(thread_checker_.CalledOnValidThread()); |
336 if (audio_data_[0]) { | 336 if (audio_data_[0]) { |
337 for (int i = 0; i < kMaxNumOfBuffersInQueue; ++i) { | 337 for (int i = 0; i < kMaxNumOfBuffersInQueue; ++i) { |
338 delete[] audio_data_[i]; | 338 delete[] audio_data_[i]; |
339 audio_data_[i] = NULL; | 339 audio_data_[i] = NULL; |
340 } | 340 } |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 void OpenSLESInputStream::HandleError(SLresult error) { | 344 void OpenSLESInputStream::HandleError(SLresult error) { |
345 DLOG(ERROR) << "OpenSLES Input error " << error; | 345 DLOG(ERROR) << "OpenSLES Input error " << error; |
346 if (callback_) | 346 if (callback_) |
347 callback_->OnError(this); | 347 callback_->OnError(this); |
348 } | 348 } |
349 | 349 |
350 } // namespace media | 350 } // namespace media |
OLD | NEW |