Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: media/audio/clockless_audio_sink.cc

Issue 1942803002: Caching AudioOutputDevice instances in mixer manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dalecurtis@'s comments addressed, build issue fixed Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698