| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |