OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/clockless_audio_sink.h" | 5 #include "media/audio/clockless_audio_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
11 #include "media/base/audio_hash.h" | 11 #include "media/base/audio_hash.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // Internal to ClocklessAudioSink. Class is used to call Render() on a seperate | 15 // Internal to ClocklessAudioSink. Class is used to call Render() on a seperate |
16 // thread, running as fast as it can read the data. | 16 // thread, running as fast as it can read the data. |
17 class ClocklessAudioSinkThread : public base::DelegateSimpleThread::Delegate { | 17 class ClocklessAudioSinkThread : public base::DelegateSimpleThread::Delegate { |
18 public: | 18 public: |
19 ClocklessAudioSinkThread(const AudioParameters& params, | 19 ClocklessAudioSinkThread(const AudioParameters& params, |
20 AudioRendererSink::RenderCallback* callback, | 20 AudioRendererSink::RenderCallback* callback, |
21 bool hashing) | 21 bool hashing) |
22 : callback_(callback), | 22 : callback_(callback), |
23 audio_bus_(AudioBus::Create(params)), | 23 audio_bus_(AudioBus::Create(params)), |
24 stop_event_(new base::WaitableEvent(false, false)) { | 24 stop_event_(new base::WaitableEvent( |
| 25 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 26 base::WaitableEvent::InitialState::NOT_SIGNALED)) { |
25 if (hashing) | 27 if (hashing) |
26 audio_hash_.reset(new AudioHash()); | 28 audio_hash_.reset(new AudioHash()); |
27 } | 29 } |
28 | 30 |
29 void Start() { | 31 void Start() { |
30 stop_event_->Reset(); | 32 stop_event_->Reset(); |
31 thread_.reset(new base::DelegateSimpleThread(this, "ClocklessAudioSink")); | 33 thread_.reset(new base::DelegateSimpleThread(this, "ClocklessAudioSink")); |
32 thread_->Start(); | 34 thread_->Start(); |
33 } | 35 } |
34 | 36 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void ClocklessAudioSink::StartAudioHashForTesting() { | 136 void ClocklessAudioSink::StartAudioHashForTesting() { |
135 DCHECK(!initialized_); | 137 DCHECK(!initialized_); |
136 hashing_ = true; | 138 hashing_ = true; |
137 } | 139 } |
138 | 140 |
139 std::string ClocklessAudioSink::GetAudioHashForTesting() { | 141 std::string ClocklessAudioSink::GetAudioHashForTesting() { |
140 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); | 142 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); |
141 } | 143 } |
142 | 144 |
143 } // namespace media | 145 } // namespace media |
OLD | NEW |