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/audio_output_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 return; | 276 return; |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 void AudioOutputController::DoReportError(int code) { | 280 void AudioOutputController::DoReportError(int code) { |
281 DCHECK(message_loop_->BelongsToCurrentThread()); | 281 DCHECK(message_loop_->BelongsToCurrentThread()); |
282 if (state_ != kClosed) | 282 if (state_ != kClosed) |
283 handler_->OnError(this, code); | 283 handler_->OnError(this, code); |
284 } | 284 } |
285 | 285 |
286 int AudioOutputController::OnMoreData(AudioBus* audio_bus, | 286 int AudioOutputController::OnMoreData(AudioBus* dest, |
287 AudioBuffersState buffers_state) { | 287 AudioBuffersState buffers_state) { |
288 TRACE_EVENT0("audio", "AudioOutputController::OnMoreData"); | 288 return OnMoreIOData(NULL, dest, buffers_state); |
| 289 } |
| 290 |
| 291 int AudioOutputController::OnMoreIOData(AudioBus* source, |
| 292 AudioBus* dest, |
| 293 AudioBuffersState buffers_state) { |
| 294 TRACE_EVENT0("audio", "AudioOutputController::OnMoreIOData"); |
289 | 295 |
290 { | 296 { |
291 // Check state and do nothing if we are not playing. | 297 // Check state and do nothing if we are not playing. |
292 // We are on the hardware audio thread, so lock is needed. | 298 // We are on the hardware audio thread, so lock is needed. |
293 base::AutoLock auto_lock(lock_); | 299 base::AutoLock auto_lock(lock_); |
294 if (state_ != kPlaying) { | 300 if (state_ != kPlaying) { |
295 return 0; | 301 return 0; |
296 } | 302 } |
297 } | 303 } |
298 int frames = sync_reader_->Read(audio_bus); | 304 |
| 305 int frames = sync_reader_->Read(source, dest); |
299 sync_reader_->UpdatePendingBytes( | 306 sync_reader_->UpdatePendingBytes( |
300 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame()); | 307 buffers_state.total_bytes() + frames * params_.GetBytesPerFrame()); |
301 return frames; | 308 return frames; |
302 } | 309 } |
303 | 310 |
304 void AudioOutputController::WaitTillDataReady() { | 311 void AudioOutputController::WaitTillDataReady() { |
305 if (!sync_reader_->DataReady()) { | 312 if (!sync_reader_->DataReady()) { |
306 // In the different place we use different mechanism to poll, get max | 313 // In the different place we use different mechanism to poll, get max |
307 // polling delay from constants used there. | 314 // polling delay from constants used there. |
308 const base::TimeDelta kMaxPollingDelay = TimeDelta::FromMilliseconds( | 315 const base::TimeDelta kMaxPollingDelay = TimeDelta::FromMilliseconds( |
(...skipping 22 matching lines...) Expand all Loading... |
331 stream_ = NULL; | 338 stream_ = NULL; |
332 weak_this_.InvalidateWeakPtrs(); | 339 weak_this_.InvalidateWeakPtrs(); |
333 } | 340 } |
334 | 341 |
335 // Should be last in the method, do not touch "this" from here on. | 342 // Should be last in the method, do not touch "this" from here on. |
336 if (done != NULL) | 343 if (done != NULL) |
337 done->Signal(); | 344 done->Signal(); |
338 } | 345 } |
339 | 346 |
340 } // namespace media | 347 } // namespace media |
OLD | NEW |