OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 render_process_id_, | 77 render_process_id_, |
78 salt) { | 78 salt) { |
79 DCHECK(audio_manager_); | 79 DCHECK(audio_manager_); |
80 } | 80 } |
81 | 81 |
82 AudioRendererHost::~AudioRendererHost() { | 82 AudioRendererHost::~AudioRendererHost() { |
83 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
84 DCHECK(delegates_.empty()); | 84 DCHECK(delegates_.empty()); |
85 } | 85 } |
86 | 86 |
87 void AudioRendererHost::GetOutputControllers( | |
88 const RenderProcessHost::GetAudioOutputControllersCallback& | |
89 callback) const { | |
90 BrowserThread::PostTaskAndReplyWithResult( | |
91 BrowserThread::IO, FROM_HERE, | |
92 base::Bind(&AudioRendererHost::DoGetOutputControllers, this), callback); | |
93 } | |
94 | |
95 void AudioRendererHost::OnChannelClosing() { | 87 void AudioRendererHost::OnChannelClosing() { |
96 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 88 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
97 delegates_.clear(); | 89 delegates_.clear(); |
98 | 90 |
99 // Remove any authorizations for streams that were not yet created | 91 // Remove any authorizations for streams that were not yet created |
100 authorizations_.clear(); | 92 authorizations_.clear(); |
101 } | 93 } |
102 | 94 |
103 void AudioRendererHost::OnDestruct() const { | 95 void AudioRendererHost::OnDestruct() const { |
104 BrowserThread::DeleteOnIOThread::Destruct(this); | 96 BrowserThread::DeleteOnIOThread::Destruct(this); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 141 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
150 | 142 |
151 if (is_valid) | 143 if (is_valid) |
152 return; | 144 return; |
153 | 145 |
154 DLOG(WARNING) << "Render frame for stream (id=" << stream_id | 146 DLOG(WARNING) << "Render frame for stream (id=" << stream_id |
155 << ") no longer exists."; | 147 << ") no longer exists."; |
156 OnStreamError(stream_id); | 148 OnStreamError(stream_id); |
157 } | 149 } |
158 | 150 |
159 RenderProcessHost::AudioOutputControllerList | |
160 AudioRendererHost::DoGetOutputControllers() const { | |
161 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
162 | |
163 RenderProcessHost::AudioOutputControllerList controllers; | |
164 for (const auto& delegate : delegates_) | |
165 controllers.push_back(delegate->GetController()); | |
166 | |
167 return controllers; | |
168 } | |
169 | |
170 /////////////////////////////////////////////////////////////////////////////// | 151 /////////////////////////////////////////////////////////////////////////////// |
171 // IPC Messages handler | 152 // IPC Messages handler |
172 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message) { | 153 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message) { |
173 bool handled = true; | 154 bool handled = true; |
174 IPC_BEGIN_MESSAGE_MAP(AudioRendererHost, message) | 155 IPC_BEGIN_MESSAGE_MAP(AudioRendererHost, message) |
175 IPC_MESSAGE_HANDLER(AudioHostMsg_RequestDeviceAuthorization, | 156 IPC_MESSAGE_HANDLER(AudioHostMsg_RequestDeviceAuthorization, |
176 OnRequestDeviceAuthorization) | 157 OnRequestDeviceAuthorization) |
177 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) | 158 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) |
178 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) | 159 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) |
179 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) | 160 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 376 |
396 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 377 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { |
397 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 378 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
398 return authorizations_.find(stream_id) != authorizations_.end(); | 379 return authorizations_.find(stream_id) != authorizations_.end(); |
399 } | 380 } |
400 | 381 |
401 void AudioRendererHost::OverrideDevicePermissionsForTesting(bool has_access) { | 382 void AudioRendererHost::OverrideDevicePermissionsForTesting(bool has_access) { |
402 authorization_handler_.OverridePermissionsForTesting(has_access); | 383 authorization_handler_.OverridePermissionsForTesting(has_access); |
403 } | 384 } |
404 } // namespace content | 385 } // namespace content |
OLD | NEW |