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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 AudioRendererSink::RenderCallback* callback_; | 69 AudioRendererSink::RenderCallback* callback_; |
70 std::unique_ptr<AudioBus> audio_bus_; | 70 std::unique_ptr<AudioBus> audio_bus_; |
71 std::unique_ptr<base::WaitableEvent> stop_event_; | 71 std::unique_ptr<base::WaitableEvent> stop_event_; |
72 std::unique_ptr<base::DelegateSimpleThread> thread_; | 72 std::unique_ptr<base::DelegateSimpleThread> thread_; |
73 base::TimeDelta playback_time_; | 73 base::TimeDelta playback_time_; |
74 std::unique_ptr<AudioHash> audio_hash_; | 74 std::unique_ptr<AudioHash> audio_hash_; |
75 }; | 75 }; |
76 | 76 |
77 ClocklessAudioSink::ClocklessAudioSink() | 77 ClocklessAudioSink::ClocklessAudioSink() |
78 : initialized_(false), playing_(false), hashing_(false) {} | 78 : ClocklessAudioSink(OutputDeviceInfo()) {} |
| 79 |
| 80 ClocklessAudioSink::ClocklessAudioSink(const OutputDeviceInfo& device_info) |
| 81 : device_info_(device_info), |
| 82 initialized_(false), |
| 83 playing_(false), |
| 84 hashing_(false) {} |
79 | 85 |
80 ClocklessAudioSink::~ClocklessAudioSink() {} | 86 ClocklessAudioSink::~ClocklessAudioSink() {} |
81 | 87 |
82 void ClocklessAudioSink::Initialize(const AudioParameters& params, | 88 void ClocklessAudioSink::Initialize(const AudioParameters& params, |
83 RenderCallback* callback) { | 89 RenderCallback* callback) { |
84 DCHECK(!initialized_); | 90 DCHECK(!initialized_); |
85 thread_.reset(new ClocklessAudioSinkThread(params, callback, hashing_)); | 91 thread_.reset(new ClocklessAudioSinkThread(params, callback, hashing_)); |
86 initialized_ = true; | 92 initialized_ = true; |
87 } | 93 } |
88 | 94 |
(...skipping 26 matching lines...) Expand all Loading... |
115 playing_ = false; | 121 playing_ = false; |
116 playback_time_ = thread_->Stop(); | 122 playback_time_ = thread_->Stop(); |
117 } | 123 } |
118 | 124 |
119 bool ClocklessAudioSink::SetVolume(double volume) { | 125 bool ClocklessAudioSink::SetVolume(double volume) { |
120 // Audio is always muted. | 126 // Audio is always muted. |
121 return volume == 0.0; | 127 return volume == 0.0; |
122 } | 128 } |
123 | 129 |
124 OutputDeviceInfo ClocklessAudioSink::GetOutputDeviceInfo() { | 130 OutputDeviceInfo ClocklessAudioSink::GetOutputDeviceInfo() { |
125 return OutputDeviceInfo(); | 131 return device_info_; |
126 } | 132 } |
127 | 133 |
128 void ClocklessAudioSink::StartAudioHashForTesting() { | 134 void ClocklessAudioSink::StartAudioHashForTesting() { |
129 DCHECK(!initialized_); | 135 DCHECK(!initialized_); |
130 hashing_ = true; | 136 hashing_ = true; |
131 } | 137 } |
132 | 138 |
133 std::string ClocklessAudioSink::GetAudioHashForTesting() { | 139 std::string ClocklessAudioSink::GetAudioHashForTesting() { |
134 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); | 140 return thread_ && hashing_ ? thread_->GetAudioHash() : std::string(); |
135 } | 141 } |
136 | 142 |
137 } // namespace media | 143 } // namespace media |
OLD | NEW |