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

Side by Side Diff: Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp

Issue 1202193002: Make setSinkId try to set the sink even if the given new sinkId equals the current sinkId. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" 6 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt ate, HTMLMediaElement& element, const String& sinkId) 33 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt ate, HTMLMediaElement& element, const String& sinkId)
34 { 34 {
35 WTF_LOG(Media, __FUNCTION__); 35 WTF_LOG(Media, __FUNCTION__);
36 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer(); 36 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer();
37 if (!webMediaPlayer) 37 if (!webMediaPlayer)
38 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "No media player available")); 38 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(AbortError, "No media player available"));
39 39
40 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 40 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
41 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD evice::from(element); 41 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, element, sinkId));
42 if (sinkId == aodElement.m_sinkId)
43 resolver->resolve();
44 else
45 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, eleme nt, sinkId));
46
47 return resolver->promise(); 42 return resolver->promise();
48 } 43 }
49 44
50 const char* HTMLMediaElementAudioOutputDevice::supplementName() 45 const char* HTMLMediaElementAudioOutputDevice::supplementName()
51 { 46 {
52 return "HTMLMediaElementAudioOutputDevice"; 47 return "HTMLMediaElementAudioOutputDevice";
53 } 48 }
54 49
55 HTMLMediaElementAudioOutputDevice& HTMLMediaElementAudioOutputDevice::from(HTMLM ediaElement& element) 50 HTMLMediaElementAudioOutputDevice& HTMLMediaElementAudioOutputDevice::from(HTMLM ediaElement& element)
56 { 51 {
57 HTMLMediaElementAudioOutputDevice* supplement = static_cast<HTMLMediaElement AudioOutputDevice*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supple mentName())); 52 HTMLMediaElementAudioOutputDevice* supplement = static_cast<HTMLMediaElement AudioOutputDevice*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supple mentName()));
58 if (!supplement) { 53 if (!supplement) {
59 supplement = new HTMLMediaElementAudioOutputDevice(); 54 supplement = new HTMLMediaElementAudioOutputDevice();
60 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); 55 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement));
61 } 56 }
62 return *supplement; 57 return *supplement;
63 } 58 }
64 59
65 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) 60 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice)
66 { 61 {
67 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); 62 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor);
68 } 63 }
69 64
70 } // namespace blink 65 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698