| 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/threading/simple_thread.h" | 7 #include "base/threading/simple_thread.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "media/base/audio_renderer_sink.h" | 9 #include "media/base/audio_renderer_sink.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Generate a signal to stop calling Render(). | 29 // Generate a signal to stop calling Render(). |
| 30 base::TimeDelta Stop() { | 30 base::TimeDelta Stop() { |
| 31 stop_event_->Signal(); | 31 stop_event_->Signal(); |
| 32 thread_->Join(); | 32 thread_->Join(); |
| 33 return playback_time_; | 33 return playback_time_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 // Call Render() repeatedly, keeping track of the rendering time. | 37 // Call Render() repeatedly, keeping track of the rendering time. |
| 38 virtual void Run() OVERRIDE { | 38 virtual void Run() override { |
| 39 base::TimeTicks start; | 39 base::TimeTicks start; |
| 40 while (!stop_event_->IsSignaled()) { | 40 while (!stop_event_->IsSignaled()) { |
| 41 int frames_received = callback_->Render(audio_bus_.get(), 0); | 41 int frames_received = callback_->Render(audio_bus_.get(), 0); |
| 42 if (frames_received <= 0) { | 42 if (frames_received <= 0) { |
| 43 // No data received, so let other threads run to provide data. | 43 // No data received, so let other threads run to provide data. |
| 44 base::PlatformThread::YieldCurrentThread(); | 44 base::PlatformThread::YieldCurrentThread(); |
| 45 } else if (start.is_null()) { | 45 } else if (start.is_null()) { |
| 46 // First time we processed some audio, so record the starting time. | 46 // First time we processed some audio, so record the starting time. |
| 47 start = base::TimeTicks::HighResNow(); | 47 start = base::TimeTicks::HighResNow(); |
| 48 } else { | 48 } else { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 playing_ = false; | 101 playing_ = false; |
| 102 playback_time_ = thread_->Stop(); | 102 playback_time_ = thread_->Stop(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool ClocklessAudioSink::SetVolume(double volume) { | 105 bool ClocklessAudioSink::SetVolume(double volume) { |
| 106 // Audio is always muted. | 106 // Audio is always muted. |
| 107 return volume == 0.0; | 107 return volume == 0.0; |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace media | 110 } // namespace media |
| OLD | NEW |