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

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

Issue 1892433002: Moving device description utils from AudioManager[Base] into AudioDeviceDescription; to be shared b… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase 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
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/cras/audio_manager_cras.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/audio/audio_output_device.h" 5 #include "media/audio/audio_output_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cmath> 10 #include <cmath>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "media/audio/audio_manager_base.h" 19 #include "media/audio/audio_device_description.h"
20 #include "media/audio/audio_output_controller.h" 20 #include "media/audio/audio_output_controller.h"
21 #include "media/base/limits.h" 21 #include "media/base/limits.h"
22 22
23 namespace media { 23 namespace media {
24 24
25 // Takes care of invoking the render callback on the audio thread. 25 // Takes care of invoking the render callback on the audio thread.
26 // An instance of this class is created for each capture stream in 26 // An instance of this class is created for each capture stream in
27 // OnStreamCreated(). 27 // OnStreamCreated().
28 class AudioOutputDevice::AudioThreadCallback 28 class AudioOutputDevice::AudioThreadCallback
29 : public AudioDeviceThread::Callback { 29 : public AudioDeviceThread::Callback {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::Bind(&AudioOutputDevice::SetVolumeOnIOThread, this, volume))) { 135 base::Bind(&AudioOutputDevice::SetVolumeOnIOThread, this, volume))) {
136 return false; 136 return false;
137 } 137 }
138 138
139 return true; 139 return true;
140 } 140 }
141 141
142 OutputDeviceInfo AudioOutputDevice::GetOutputDeviceInfo() { 142 OutputDeviceInfo AudioOutputDevice::GetOutputDeviceInfo() {
143 CHECK(!task_runner()->BelongsToCurrentThread()); 143 CHECK(!task_runner()->BelongsToCurrentThread());
144 did_receive_auth_.Wait(); 144 did_receive_auth_.Wait();
145 return OutputDeviceInfo( 145 return OutputDeviceInfo(AudioDeviceDescription::UseSessionIdToSelectDevice(
146 AudioManagerBase::UseSessionIdToSelectDevice(session_id_, device_id_) 146 session_id_, device_id_)
147 ? matched_device_id_ 147 ? matched_device_id_
148 : device_id_, 148 : device_id_,
149 device_status_, output_params_); 149 device_status_, output_params_);
150 } 150 }
151 151
152 void AudioOutputDevice::RequestDeviceAuthorizationOnIOThread() { 152 void AudioOutputDevice::RequestDeviceAuthorizationOnIOThread() {
153 DCHECK(task_runner()->BelongsToCurrentThread()); 153 DCHECK(task_runner()->BelongsToCurrentThread());
154 DCHECK_EQ(state_, IDLE); 154 DCHECK_EQ(state_, IDLE);
155 state_ = AUTHORIZING; 155 state_ = AUTHORIZING;
156 ipc_->RequestDeviceAuthorization(this, session_id_, device_id_, 156 ipc_->RequestDeviceAuthorization(this, session_id_, device_id_,
157 security_origin_); 157 security_origin_);
158 } 158 }
159 159
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 device_status_ = device_status; 298 device_status_ = device_status;
299 299
300 if (device_status == OUTPUT_DEVICE_STATUS_OK) { 300 if (device_status == OUTPUT_DEVICE_STATUS_OK) {
301 state_ = AUTHORIZED; 301 state_ = AUTHORIZED;
302 if (!did_receive_auth_.IsSignaled()) { 302 if (!did_receive_auth_.IsSignaled()) {
303 output_params_ = output_params; 303 output_params_ = output_params;
304 304
305 // It's possible to not have a matched device obtained via session id. It 305 // It's possible to not have a matched device obtained via session id. It
306 // means matching output device through |session_id_| failed and the 306 // means matching output device through |session_id_| failed and the
307 // default device is used. 307 // default device is used.
308 DCHECK(AudioManagerBase::UseSessionIdToSelectDevice(session_id_, 308 DCHECK(AudioDeviceDescription::UseSessionIdToSelectDevice(session_id_,
309 device_id_) || 309 device_id_) ||
310 matched_device_id_.empty()); 310 matched_device_id_.empty());
311 matched_device_id_ = matched_device_id; 311 matched_device_id_ = matched_device_id;
312 312
313 DVLOG(1) << "AudioOutputDevice authorized, session_id: " << session_id_ 313 DVLOG(1) << "AudioOutputDevice authorized, session_id: " << session_id_
314 << ", device_id: " << device_id_ 314 << ", device_id: " << device_id_
315 << ", matched_device_id: " << matched_device_id_; 315 << ", matched_device_id: " << matched_device_id_;
316 316
317 did_receive_auth_.Signal(); 317 did_receive_auth_.Signal();
318 } 318 }
319 if (start_on_authorized_) 319 if (start_on_authorized_)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 // Update the audio-delay measurement, inform about the number of skipped 444 // Update the audio-delay measurement, inform about the number of skipped
445 // frames, and ask client to render audio. Since |output_bus_| is wrapping 445 // frames, and ask client to render audio. Since |output_bus_| is wrapping
446 // the shared memory the Render() call is writing directly into the shared 446 // the shared memory the Render() call is writing directly into the shared
447 // memory. 447 // memory.
448 render_callback_->Render(output_bus_.get(), std::round(frames_delayed), 448 render_callback_->Render(output_bus_.get(), std::round(frames_delayed),
449 frames_skipped); 449 frames_skipped);
450 } 450 }
451 451
452 } // namespace media 452 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/cras/audio_manager_cras.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698