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

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: rebase Created 4 years, 8 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/blink/webaudiosourceprovider_impl.cc ('k') | media/blink/webmediaplayer_impl_unittest.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 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // 90 //
91 // Also our timers are not very accurate (especially for ogg), which becomes 91 // Also our timers are not very accurate (especially for ogg), which becomes
92 // evident at low speeds and on Vista. Since other speeds are risky and outside 92 // evident at low speeds and on Vista. Since other speeds are risky and outside
93 // the norms, we think 1/16x to 16x is a safe and useful range for now. 93 // the norms, we think 1/16x to 16x is a safe and useful range for now.
94 const double kMinRate = 0.0625; 94 const double kMinRate = 0.0625;
95 const double kMaxRate = 16.0; 95 const double kMaxRate = 16.0;
96 96
97 void SetSinkIdOnMediaThread(scoped_refptr<WebAudioSourceProviderImpl> sink, 97 void SetSinkIdOnMediaThread(scoped_refptr<WebAudioSourceProviderImpl> sink,
98 const std::string& device_id, 98 const std::string& device_id,
99 const url::Origin& security_origin, 99 const url::Origin& security_origin,
100 const SwitchOutputDeviceCB& callback) { 100 const OutputDeviceStatusCB& callback) {
101 if (sink->GetOutputDevice()) { 101 sink->SwitchOutputDevice(device_id, security_origin, callback);
102 sink->GetOutputDevice()->SwitchOutputDevice(device_id, security_origin,
103 callback);
104 } else {
105 callback.Run(OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
106 }
107 } 102 }
108 103
109 bool IsSuspendUponHiddenEnabled() { 104 bool IsSuspendUponHiddenEnabled() {
110 #if !defined(OS_ANDROID) 105 #if !defined(OS_ANDROID)
111 // Suspend/Resume is only enabled by default on Android. 106 // Suspend/Resume is only enabled by default on Android.
112 return base::CommandLine::ForCurrentProcess()->HasSwitch( 107 return base::CommandLine::ForCurrentProcess()->HasSwitch(
113 switches::kEnableMediaSuspend); 108 switches::kEnableMediaSuspend);
114 #else 109 #else
115 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 110 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
116 switches::kDisableMediaSuspend); 111 switches::kDisableMediaSuspend);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 pipeline_.SetVolume(volume_ * volume_multiplier_); 493 pipeline_.SetVolume(volume_ * volume_multiplier_);
499 } 494 }
500 495
501 void WebMediaPlayerImpl::setSinkId( 496 void WebMediaPlayerImpl::setSinkId(
502 const blink::WebString& sink_id, 497 const blink::WebString& sink_id,
503 const blink::WebSecurityOrigin& security_origin, 498 const blink::WebSecurityOrigin& security_origin,
504 blink::WebSetSinkIdCallbacks* web_callback) { 499 blink::WebSetSinkIdCallbacks* web_callback) {
505 DCHECK(main_task_runner_->BelongsToCurrentThread()); 500 DCHECK(main_task_runner_->BelongsToCurrentThread());
506 DVLOG(1) << __FUNCTION__; 501 DVLOG(1) << __FUNCTION__;
507 502
508 media::SwitchOutputDeviceCB callback = 503 media::OutputDeviceStatusCB callback =
509 media::ConvertToSwitchOutputDeviceCB(web_callback); 504 media::ConvertToOutputDeviceStatusCB(web_callback);
510 media_task_runner_->PostTask( 505 media_task_runner_->PostTask(
511 FROM_HERE, 506 FROM_HERE,
512 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, 507 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_,
513 sink_id.utf8(), static_cast<url::Origin>(security_origin), 508 sink_id.utf8(), static_cast<url::Origin>(security_origin),
514 callback)); 509 callback));
515 } 510 }
516 511
517 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); 512 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE);
518 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, 513 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData,
519 BufferedDataSource::METADATA); 514 BufferedDataSource::METADATA);
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { 1545 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() {
1551 #if defined(OS_ANDROID) 1546 #if defined(OS_ANDROID)
1552 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); 1547 return !hasVideo() || (delegate_ && !delegate_->IsHidden());
1553 #else 1548 #else
1554 // On non-Android platforms Resume() is always allowed. 1549 // On non-Android platforms Resume() is always allowed.
1555 return true; 1550 return true;
1556 #endif 1551 #endif
1557 } 1552 }
1558 1553
1559 } // namespace media 1554 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webaudiosourceprovider_impl.cc ('k') | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698