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 26 matching lines...) Expand all Loading... |
37 // Call Render() repeatedly, keeping track of the rendering time. | 37 // Call Render() repeatedly, keeping track of the rendering time. |
38 void Run() override { | 38 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::Now(); |
48 } else { | 48 } else { |
49 // Keep track of the last time data was rendered. | 49 // Keep track of the last time data was rendered. |
50 playback_time_ = base::TimeTicks::HighResNow() - start; | 50 playback_time_ = base::TimeTicks::Now() - start; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 AudioRendererSink::RenderCallback* callback_; | 55 AudioRendererSink::RenderCallback* callback_; |
56 scoped_ptr<AudioBus> audio_bus_; | 56 scoped_ptr<AudioBus> audio_bus_; |
57 scoped_ptr<base::WaitableEvent> stop_event_; | 57 scoped_ptr<base::WaitableEvent> stop_event_; |
58 scoped_ptr<base::DelegateSimpleThread> thread_; | 58 scoped_ptr<base::DelegateSimpleThread> thread_; |
59 base::TimeDelta playback_time_; | 59 base::TimeDelta playback_time_; |
60 }; | 60 }; |
(...skipping 40 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 |