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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing guidou's comments Created 4 years, 9 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/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // 91 //
92 // Also our timers are not very accurate (especially for ogg), which becomes 92 // Also our timers are not very accurate (especially for ogg), which becomes
93 // evident at low speeds and on Vista. Since other speeds are risky and outside 93 // evident at low speeds and on Vista. Since other speeds are risky and outside
94 // the norms, we think 1/16x to 16x is a safe and useful range for now. 94 // the norms, we think 1/16x to 16x is a safe and useful range for now.
95 const double kMinRate = 0.0625; 95 const double kMinRate = 0.0625;
96 const double kMaxRate = 16.0; 96 const double kMaxRate = 16.0;
97 97
98 void SetSinkIdOnMediaThread(scoped_refptr<WebAudioSourceProviderImpl> sink, 98 void SetSinkIdOnMediaThread(scoped_refptr<WebAudioSourceProviderImpl> sink,
99 const std::string& device_id, 99 const std::string& device_id,
100 const url::Origin& security_origin, 100 const url::Origin& security_origin,
101 const SwitchOutputDeviceCB& callback) { 101 const OutputDeviceStatusCB& callback) {
102 if (sink->GetOutputDevice()) { 102 sink->SwitchOutputDevice(device_id, security_origin, callback);
103 sink->GetOutputDevice()->SwitchOutputDevice(device_id, security_origin,
104 callback);
105 } else {
106 callback.Run(OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
107 }
108 } 103 }
109 104
110 bool IsSuspendUponHiddenEnabled() { 105 bool IsSuspendUponHiddenEnabled() {
111 #if !defined(OS_ANDROID) 106 #if !defined(OS_ANDROID)
112 // Suspend/Resume is only enabled by default on Android. 107 // Suspend/Resume is only enabled by default on Android.
113 return base::CommandLine::ForCurrentProcess()->HasSwitch( 108 return base::CommandLine::ForCurrentProcess()->HasSwitch(
114 switches::kEnableMediaSuspend); 109 switches::kEnableMediaSuspend);
115 #else 110 #else
116 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 111 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
117 switches::kDisableMediaSuspend); 112 switches::kDisableMediaSuspend);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 pipeline_.SetVolume(volume_ * volume_multiplier_); 494 pipeline_.SetVolume(volume_ * volume_multiplier_);
500 } 495 }
501 496
502 void WebMediaPlayerImpl::setSinkId( 497 void WebMediaPlayerImpl::setSinkId(
503 const blink::WebString& sink_id, 498 const blink::WebString& sink_id,
504 const blink::WebSecurityOrigin& security_origin, 499 const blink::WebSecurityOrigin& security_origin,
505 blink::WebSetSinkIdCallbacks* web_callback) { 500 blink::WebSetSinkIdCallbacks* web_callback) {
506 DCHECK(main_task_runner_->BelongsToCurrentThread()); 501 DCHECK(main_task_runner_->BelongsToCurrentThread());
507 DVLOG(1) << __FUNCTION__; 502 DVLOG(1) << __FUNCTION__;
508 503
509 media::SwitchOutputDeviceCB callback = 504 media::OutputDeviceStatusCB callback =
510 media::ConvertToSwitchOutputDeviceCB(web_callback); 505 media::ConvertToOutputDeviceStatusCB(web_callback);
511 media_task_runner_->PostTask( 506 media_task_runner_->PostTask(
512 FROM_HERE, 507 FROM_HERE,
513 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, 508 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_,
514 sink_id.utf8(), static_cast<url::Origin>(security_origin), 509 sink_id.utf8(), static_cast<url::Origin>(security_origin),
515 callback)); 510 callback));
516 } 511 }
517 512
518 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); 513 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE);
519 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, 514 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData,
520 BufferedDataSource::METADATA); 515 BufferedDataSource::METADATA);
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { 1500 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() {
1506 #if defined(OS_ANDROID) 1501 #if defined(OS_ANDROID)
1507 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); 1502 return !hasVideo() || (delegate_ && !delegate_->IsHidden());
1508 #else 1503 #else
1509 // On non-Android platforms Resume() is always allowed. 1504 // On non-Android platforms Resume() is always allowed.
1510 return true; 1505 return true;
1511 #endif 1506 #endif
1512 } 1507 }
1513 1508
1514 } // namespace media 1509 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698