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

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

Issue 11744026: Add guard to OpenSLESOutputStream::FillBufferQueue() to respect shutdown conditions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | 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
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 void OpenSLESOutputStream::FillBufferQueue() { 254 void OpenSLESOutputStream::FillBufferQueue() {
255 if (!started_) 255 if (!started_)
256 return; 256 return;
257 257
258 // Read data from the registered client source. 258 // Read data from the registered client source.
259 // TODO(xians): Get an accurate delay estimation. 259 // TODO(xians): Get an accurate delay estimation.
260 uint32 hardware_delay = buffer_size_bytes_; 260 uint32 hardware_delay = buffer_size_bytes_;
261 int frames_filled = callback_->OnMoreData( 261 int frames_filled = callback_->OnMoreData(
262 audio_bus_.get(), AudioBuffersState(0, hardware_delay)); 262 audio_bus_.get(), AudioBuffersState(0, hardware_delay));
263 if (frames_filled <= 0)
264 return; // Audio source is shutting down, or halted on error.
263 int num_filled_bytes = 265 int num_filled_bytes =
264 frames_filled * audio_bus_->channels() * format_.bitsPerSample / 8; 266 frames_filled * audio_bus_->channels() * format_.bitsPerSample / 8;
265 DCHECK_LE(static_cast<size_t>(num_filled_bytes), buffer_size_bytes_); 267 DCHECK_LE(static_cast<size_t>(num_filled_bytes), buffer_size_bytes_);
266 // Note: If this ever changes to output raw float the data must be clipped and 268 // Note: If this ever changes to output raw float the data must be clipped and
267 // sanitized since it may come from an untrusted source such as NaCl. 269 // sanitized since it may come from an untrusted source such as NaCl.
268 audio_bus_->ToInterleaved( 270 audio_bus_->ToInterleaved(
269 frames_filled, format_.bitsPerSample / 8, audio_data_[active_queue_]); 271 frames_filled, format_.bitsPerSample / 8, audio_data_[active_queue_]);
270 272
271 // Perform in-place, software-volume adjustments. 273 // Perform in-place, software-volume adjustments.
272 media::AdjustVolume(audio_data_[active_queue_], 274 media::AdjustVolume(audio_data_[active_queue_],
(...skipping 23 matching lines...) Expand all
296 void OpenSLESOutputStream::ReleaseAudioBuffer() { 298 void OpenSLESOutputStream::ReleaseAudioBuffer() {
297 if (audio_data_[0]) { 299 if (audio_data_[0]) {
298 for (int i = 0; i < kNumOfQueuesInBuffer; ++i) { 300 for (int i = 0; i < kNumOfQueuesInBuffer; ++i) {
299 delete [] audio_data_[i]; 301 delete [] audio_data_[i];
300 audio_data_[i] = NULL; 302 audio_data_[i] = NULL;
301 } 303 }
302 } 304 }
303 } 305 }
304 306
305 void OpenSLESOutputStream::HandleError(SLresult error) { 307 void OpenSLESOutputStream::HandleError(SLresult error) {
306 DLOG(FATAL) << "OpenSLES error " << error; 308 DLOG(ERROR) << "OpenSLES error " << error;
307 if (callback_) 309 if (callback_)
308 callback_->OnError(this, error); 310 callback_->OnError(this, error);
309 } 311 }
310 312
311 } // namespace media 313 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698