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" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 | 13 |
14 using base::Time; | 14 using base::Time; |
15 using base::WaitableEvent; | 15 using base::WaitableEvent; |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 // Signal a pause in low-latency mode. | 19 // Special signals to send to the renderer in low-latency mode. |
20 const int AudioOutputController::kPauseMark = -1; | 20 const int AudioOutputController::kPauseMark = -1; |
| 21 const int AudioOutputController::kStopMark = -2; |
21 | 22 |
22 // Polling-related constants. | 23 // Polling-related constants. |
23 const int AudioOutputController::kPollNumAttempts = 3; | 24 const int AudioOutputController::kPollNumAttempts = 3; |
24 const int AudioOutputController::kPollPauseInMilliseconds = 3; | 25 const int AudioOutputController::kPollPauseInMilliseconds = 3; |
25 | 26 |
26 AudioOutputController::AudioOutputController(AudioManager* audio_manager, | 27 AudioOutputController::AudioOutputController(AudioManager* audio_manager, |
27 EventHandler* handler, | 28 EventHandler* handler, |
28 uint32 capacity, | 29 uint32 capacity, |
29 SyncReader* sync_reader) | 30 SyncReader* sync_reader) |
30 : audio_manager_(audio_manager), | 31 : audio_manager_(audio_manager), |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 297 } |
297 } | 298 } |
298 | 299 |
299 void AudioOutputController::DoClose(const base::Closure& closed_task) { | 300 void AudioOutputController::DoClose(const base::Closure& closed_task) { |
300 DCHECK(message_loop_->BelongsToCurrentThread()); | 301 DCHECK(message_loop_->BelongsToCurrentThread()); |
301 | 302 |
302 if (state_ != kClosed) { | 303 if (state_ != kClosed) { |
303 DoStopCloseAndClearStream(NULL); | 304 DoStopCloseAndClearStream(NULL); |
304 | 305 |
305 if (LowLatencyMode()) { | 306 if (LowLatencyMode()) { |
| 307 sync_reader_->UpdatePendingBytes(kStopMark); |
306 sync_reader_->Close(); | 308 sync_reader_->Close(); |
307 } | 309 } |
308 | 310 |
309 state_ = kClosed; | 311 state_ = kClosed; |
310 } | 312 } |
311 | 313 |
312 closed_task.Run(); | 314 closed_task.Run(); |
313 } | 315 } |
314 | 316 |
315 void AudioOutputController::DoSetVolume(double volume) { | 317 void AudioOutputController::DoSetVolume(double volume) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 stream_ = NULL; | 427 stream_ = NULL; |
426 weak_this_.InvalidateWeakPtrs(); | 428 weak_this_.InvalidateWeakPtrs(); |
427 } | 429 } |
428 | 430 |
429 // Should be last in the method, do not touch "this" from here on. | 431 // Should be last in the method, do not touch "this" from here on. |
430 if (done != NULL) | 432 if (done != NULL) |
431 done->Signal(); | 433 done->Signal(); |
432 } | 434 } |
433 | 435 |
434 } // namespace media | 436 } // namespace media |
OLD | NEW |