| 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" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 std::string GetAudioHash() { | 44 std::string GetAudioHash() { |
| 45 DCHECK(audio_hash_); | 45 DCHECK(audio_hash_); |
| 46 return audio_hash_->ToString(); | 46 return audio_hash_->ToString(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Call Render() repeatedly, keeping track of the rendering time. | 50 // Call Render() repeatedly, keeping track of the rendering time. |
| 51 void Run() override { | 51 void Run() override { |
| 52 base::TimeTicks start; | 52 base::TimeTicks start; |
| 53 while (!stop_event_->IsSignaled()) { | 53 while (!stop_event_->IsSignaled()) { |
| 54 const int frames_received = callback_->Render(audio_bus_.get(), 0, 0); | 54 const int frames_received = callback_->Render( |
| 55 base::TimeDelta(), base::TimeTicks::Now(), 0, audio_bus_.get()); |
| 55 DCHECK_GE(frames_received, 0); | 56 DCHECK_GE(frames_received, 0); |
| 56 if (audio_hash_) | 57 if (audio_hash_) |
| 57 audio_hash_->Update(audio_bus_.get(), frames_received); | 58 audio_hash_->Update(audio_bus_.get(), frames_received); |
| 58 if (!frames_received) { | 59 if (!frames_received) { |
| 59 // No data received, so let other threads run to provide data. | 60 // No data received, so let other threads run to provide data. |
| 60 base::PlatformThread::YieldCurrentThread(); | 61 base::PlatformThread::YieldCurrentThread(); |
| 61 } else if (start.is_null()) { | 62 } else if (start.is_null()) { |
| 62 // First time we processed some audio, so record the starting time. | 63 // First time we processed some audio, so record the starting time. |
| 63 start = base::TimeTicks::Now(); | 64 start = base::TimeTicks::Now(); |
| 64 } else { | 65 } else { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 void ClocklessAudioSink::StartAudioHashForTesting() { | 142 void ClocklessAudioSink::StartAudioHashForTesting() { |
| 142 DCHECK(!initialized_); | 143 DCHECK(!initialized_); |
| 143 hashing_ = true; | 144 hashing_ = true; |
| 144 } | 145 } |
| 145 | 146 |
| 146 std::string ClocklessAudioSink::GetAudioHashForTesting() { | 147 std::string ClocklessAudioSink::GetAudioHashForTesting() { |
| 147 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); | 148 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 } // namespace media | 151 } // namespace media |
| OLD | NEW |