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/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void AudioOutputController::Play() { | 82 void AudioOutputController::Play() { |
83 message_loop_->PostTask(FROM_HERE, base::Bind( | 83 message_loop_->PostTask(FROM_HERE, base::Bind( |
84 &AudioOutputController::DoPlay, this)); | 84 &AudioOutputController::DoPlay, this)); |
85 } | 85 } |
86 | 86 |
87 void AudioOutputController::Pause() { | 87 void AudioOutputController::Pause() { |
88 message_loop_->PostTask(FROM_HERE, base::Bind( | 88 message_loop_->PostTask(FROM_HERE, base::Bind( |
89 &AudioOutputController::DoPause, this)); | 89 &AudioOutputController::DoPause, this)); |
90 } | 90 } |
91 | 91 |
92 void AudioOutputController::Flush() { | |
93 message_loop_->PostTask(FROM_HERE, base::Bind( | |
94 &AudioOutputController::DoFlush, this)); | |
95 } | |
96 | |
97 void AudioOutputController::Close(const base::Closure& closed_task) { | 92 void AudioOutputController::Close(const base::Closure& closed_task) { |
98 DCHECK(!closed_task.is_null()); | 93 DCHECK(!closed_task.is_null()); |
99 message_loop_->PostTaskAndReply(FROM_HERE, base::Bind( | 94 message_loop_->PostTaskAndReply(FROM_HERE, base::Bind( |
100 &AudioOutputController::DoClose, this), closed_task); | 95 &AudioOutputController::DoClose, this), closed_task); |
101 } | 96 } |
102 | 97 |
103 void AudioOutputController::SetVolume(double volume) { | 98 void AudioOutputController::SetVolume(double volume) { |
104 message_loop_->PostTask(FROM_HERE, base::Bind( | 99 message_loop_->PostTask(FROM_HERE, base::Bind( |
105 &AudioOutputController::DoSetVolume, this, volume)); | 100 &AudioOutputController::DoSetVolume, this, volume)); |
106 } | 101 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 227 |
233 if (state_ != kPaused) | 228 if (state_ != kPaused) |
234 return; | 229 return; |
235 | 230 |
236 // Send a special pause mark to the low-latency audio thread. | 231 // Send a special pause mark to the low-latency audio thread. |
237 sync_reader_->UpdatePendingBytes(kPauseMark); | 232 sync_reader_->UpdatePendingBytes(kPauseMark); |
238 | 233 |
239 handler_->OnPaused(); | 234 handler_->OnPaused(); |
240 } | 235 } |
241 | 236 |
242 void AudioOutputController::DoFlush() { | |
243 DCHECK(message_loop_->BelongsToCurrentThread()); | |
244 | |
245 // TODO(hclam): Actually flush the audio device. | |
246 } | |
247 | |
248 void AudioOutputController::DoClose() { | 237 void AudioOutputController::DoClose() { |
249 DCHECK(message_loop_->BelongsToCurrentThread()); | 238 DCHECK(message_loop_->BelongsToCurrentThread()); |
250 | 239 |
251 if (state_ != kClosed) { | 240 if (state_ != kClosed) { |
252 DoStopCloseAndClearStream(); | 241 DoStopCloseAndClearStream(); |
253 sync_reader_->Close(); | 242 sync_reader_->Close(); |
254 state_ = kClosed; | 243 state_ = kClosed; |
255 } | 244 } |
256 } | 245 } |
257 | 246 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); | 414 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); |
426 base::AtomicRefCountInc(&num_allowed_io_); | 415 base::AtomicRefCountInc(&num_allowed_io_); |
427 } | 416 } |
428 | 417 |
429 void AudioOutputController::DisallowEntryToOnMoreIOData() { | 418 void AudioOutputController::DisallowEntryToOnMoreIOData() { |
430 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); | 419 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); |
431 DCHECK(is_zero); | 420 DCHECK(is_zero); |
432 } | 421 } |
433 | 422 |
434 } // namespace media | 423 } // namespace media |
OLD | NEW |