| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 std::string GetAudioHash() { | 42 std::string GetAudioHash() { |
| 43 DCHECK(audio_hash_); | 43 DCHECK(audio_hash_); |
| 44 return audio_hash_->ToString(); | 44 return audio_hash_->ToString(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 // Call Render() repeatedly, keeping track of the rendering time. | 48 // Call Render() repeatedly, keeping track of the rendering time. |
| 49 void Run() override { | 49 void Run() override { |
| 50 base::TimeTicks start; | 50 base::TimeTicks start; |
| 51 while (!stop_event_->IsSignaled()) { | 51 while (!stop_event_->IsSignaled()) { |
| 52 const int frames_received = callback_->Render(audio_bus_.get(), 0); | 52 const int frames_received = callback_->Render(audio_bus_.get(), 0, 0); |
| 53 DCHECK_GE(frames_received, 0); | 53 DCHECK_GE(frames_received, 0); |
| 54 if (audio_hash_) | 54 if (audio_hash_) |
| 55 audio_hash_->Update(audio_bus_.get(), frames_received); | 55 audio_hash_->Update(audio_bus_.get(), frames_received); |
| 56 if (!frames_received) { | 56 if (!frames_received) { |
| 57 // No data received, so let other threads run to provide data. | 57 // No data received, so let other threads run to provide data. |
| 58 base::PlatformThread::YieldCurrentThread(); | 58 base::PlatformThread::YieldCurrentThread(); |
| 59 } else if (start.is_null()) { | 59 } else if (start.is_null()) { |
| 60 // First time we processed some audio, so record the starting time. | 60 // First time we processed some audio, so record the starting time. |
| 61 start = base::TimeTicks::Now(); | 61 start = base::TimeTicks::Now(); |
| 62 } else { | 62 } else { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void ClocklessAudioSink::StartAudioHashForTesting() { | 128 void ClocklessAudioSink::StartAudioHashForTesting() { |
| 129 DCHECK(!initialized_); | 129 DCHECK(!initialized_); |
| 130 hashing_ = true; | 130 hashing_ = true; |
| 131 } | 131 } |
| 132 | 132 |
| 133 std::string ClocklessAudioSink::GetAudioHashForTesting() { | 133 std::string ClocklessAudioSink::GetAudioHashForTesting() { |
| 134 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); | 134 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace media | 137 } // namespace media |
| OLD | NEW |