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

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 604753003: Removing #ifdefs for WEB_AUDIO compile time flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "public/platform/Platform.h" 74 #include "public/platform/Platform.h"
75 #include "public/platform/WebContentDecryptionModule.h" 75 #include "public/platform/WebContentDecryptionModule.h"
76 #include "public/platform/WebInbandTextTrack.h" 76 #include "public/platform/WebInbandTextTrack.h"
77 #include "wtf/CurrentTime.h" 77 #include "wtf/CurrentTime.h"
78 #include "wtf/MathExtras.h" 78 #include "wtf/MathExtras.h"
79 #include "wtf/NonCopyingSort.h" 79 #include "wtf/NonCopyingSort.h"
80 #include "wtf/Uint8Array.h" 80 #include "wtf/Uint8Array.h"
81 #include "wtf/text/CString.h" 81 #include "wtf/text/CString.h"
82 #include <limits> 82 #include <limits>
83 83
84 #if ENABLE(WEB_AUDIO)
85 #include "platform/audio/AudioSourceProvider.h" 84 #include "platform/audio/AudioSourceProvider.h"
86 #include "platform/audio/AudioSourceProviderClient.h" 85 #include "platform/audio/AudioSourceProviderClient.h"
87 #endif
88 86
89 using blink::WebInbandTextTrack; 87 using blink::WebInbandTextTrack;
90 using blink::WebMediaPlayer; 88 using blink::WebMediaPlayer;
91 using blink::WebMimeRegistry; 89 using blink::WebMimeRegistry;
92 using blink::WebMediaPlayerClient; 90 using blink::WebMediaPlayerClient;
93 91
94 namespace blink { 92 namespace blink {
95 93
96 #if !LOG_DISABLED 94 #if !LOG_DISABLED
97 static String urlForLoggingMedia(const KURL& url) 95 static String urlForLoggingMedia(const KURL& url)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); 163 m_mediaElement->endIgnoringTrackDisplayUpdateRequests();
166 } 164 }
167 165
168 private: 166 private:
169 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; 167 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement;
170 }; 168 };
171 169
172 class AudioSourceProviderClientLockScope { 170 class AudioSourceProviderClientLockScope {
173 STACK_ALLOCATED(); 171 STACK_ALLOCATED();
174 public: 172 public:
175 #if ENABLE(WEB_AUDIO)
176 AudioSourceProviderClientLockScope(HTMLMediaElement& element) 173 AudioSourceProviderClientLockScope(HTMLMediaElement& element)
177 : m_client(element.audioSourceNode()) 174 : m_client(element.audioSourceNode())
178 { 175 {
179 if (m_client) 176 if (m_client)
180 m_client->lock(); 177 m_client->lock();
181 } 178 }
182 ~AudioSourceProviderClientLockScope() 179 ~AudioSourceProviderClientLockScope()
183 { 180 {
184 if (m_client) 181 if (m_client)
185 m_client->unlock(); 182 m_client->unlock();
186 } 183 }
187 184
188 private: 185 private:
189 Member<AudioSourceProviderClient> m_client; 186 Member<AudioSourceProviderClient> m_client;
190 #else
191 explicit AudioSourceProviderClientLockScope(HTMLMediaElement&) { }
192 ~AudioSourceProviderClientLockScope() { }
193 #endif
194 }; 187 };
195 188
196 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind) 189 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind)
197 { 190 {
198 switch (kind) { 191 switch (kind) {
199 case WebMediaPlayerClient::AudioTrackKindNone: 192 case WebMediaPlayerClient::AudioTrackKindNone:
200 return emptyAtom; 193 return emptyAtom;
201 case WebMediaPlayerClient::AudioTrackKindAlternative: 194 case WebMediaPlayerClient::AudioTrackKindAlternative:
202 return AudioTrack::alternativeKeyword(); 195 return AudioTrack::alternativeKeyword();
203 case WebMediaPlayerClient::AudioTrackKindDescriptions: 196 case WebMediaPlayerClient::AudioTrackKindDescriptions:
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 , m_playingRemotely(false) 348 , m_playingRemotely(false)
356 #if ENABLE(OILPAN) 349 #if ENABLE(OILPAN)
357 , m_isFinalizing(false) 350 , m_isFinalizing(false)
358 , m_closeMediaSourceWhenFinalizing(false) 351 , m_closeMediaSourceWhenFinalizing(false)
359 #endif 352 #endif
360 , m_lastTextTrackUpdateTime(-1) 353 , m_lastTextTrackUpdateTime(-1)
361 , m_audioTracks(AudioTrackList::create(*this)) 354 , m_audioTracks(AudioTrackList::create(*this))
362 , m_videoTracks(VideoTrackList::create(*this)) 355 , m_videoTracks(VideoTrackList::create(*this))
363 , m_textTracks(nullptr) 356 , m_textTracks(nullptr)
364 , m_ignoreTrackDisplayUpdate(0) 357 , m_ignoreTrackDisplayUpdate(0)
365 #if ENABLE(WEB_AUDIO)
366 , m_audioSourceNode(nullptr) 358 , m_audioSourceNode(nullptr)
367 #endif
368 { 359 {
369 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); 360 ASSERT(RuntimeEnabledFeatures::mediaEnabled());
370 361
371 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); 362 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this);
372 363
373 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) 364 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture())
374 m_userGestureRequiredForPlay = true; 365 m_userGestureRequiredForPlay = true;
375 366
376 setHasCustomStyleCallbacks(); 367 setHasCustomStyleCallbacks();
377 addElementToDocumentMap(this, &document); 368 addElementToDocumentMap(this, &document);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // avoid having to finalize it from here; this whole #if block 445 // avoid having to finalize it from here; this whole #if block
455 // could then be removed (along with the state bit it depends on.) 446 // could then be removed (along with the state bit it depends on.)
456 // crbug.com/378229 447 // crbug.com/378229
457 m_isFinalizing = true; 448 m_isFinalizing = true;
458 #endif 449 #endif
459 450
460 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). 451 // m_audioSourceNode is explicitly cleared by AudioNode::dispose().
461 // Since AudioNode::dispose() is guaranteed to be always called before 452 // Since AudioNode::dispose() is guaranteed to be always called before
462 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared 453 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared
463 // even if the AudioNode and the HTMLMediaElement die together. 454 // even if the AudioNode and the HTMLMediaElement die together.
464 #if ENABLE(WEB_AUDIO)
465 ASSERT(!m_audioSourceNode); 455 ASSERT(!m_audioSourceNode);
466 #endif
467 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); 456 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
468 457
469 #if !ENABLE(OILPAN) 458 #if !ENABLE(OILPAN)
470 document().decrementLoadEventDelayCount(); 459 document().decrementLoadEventDelayCount();
471 #endif 460 #endif
472 } 461 }
473 462
474 #if ENABLE(OILPAN) 463 #if ENABLE(OILPAN)
475 void HTMLMediaElement::setCloseMediaSourceWhenFinalizing() 464 void HTMLMediaElement::setCloseMediaSourceWhenFinalizing()
476 { 465 {
(...skipping 2969 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 3435
3447 // Reset m_readyState since m_player is gone. 3436 // Reset m_readyState since m_player is gone.
3448 m_readyState = HAVE_NOTHING; 3437 m_readyState = HAVE_NOTHING;
3449 invalidateCachedTime(); 3438 invalidateCachedTime();
3450 updateMediaController(); 3439 updateMediaController();
3451 updateActiveTextTrackCues(0); 3440 updateActiveTextTrackCues(0);
3452 } 3441 }
3453 3442
3454 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3443 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3455 { 3444 {
3456 #if ENABLE(WEB_AUDIO)
3457 if (audioSourceProvider()) 3445 if (audioSourceProvider())
3458 audioSourceProvider()->setClient(0); 3446 audioSourceProvider()->setClient(0);
3459 #endif
3460 m_player.clear(); 3447 m_player.clear();
3461 } 3448 }
3462 3449
3463 void HTMLMediaElement::clearMediaPlayer(int flags) 3450 void HTMLMediaElement::clearMediaPlayer(int flags)
3464 { 3451 {
3465 forgetResourceSpecificTracks(); 3452 forgetResourceSpecificTracks();
3466 3453
3467 closeMediaSource(); 3454 closeMediaSource();
3468 3455
3469 cancelDeferredLoad(); 3456 cancelDeferredLoad();
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3800 AudioSourceProviderClientLockScope scope(*this); 3787 AudioSourceProviderClientLockScope scope(*this);
3801 3788
3802 closeMediaSource(); 3789 closeMediaSource();
3803 3790
3804 m_player = MediaPlayer::create(this); 3791 m_player = MediaPlayer::create(this);
3805 3792
3806 // We haven't yet found out if any remote routes are available. 3793 // We haven't yet found out if any remote routes are available.
3807 m_remoteRoutesAvailable = false; 3794 m_remoteRoutesAvailable = false;
3808 m_playingRemotely = false; 3795 m_playingRemotely = false;
3809 3796
3810 #if ENABLE(WEB_AUDIO)
3811 if (m_audioSourceNode && audioSourceProvider()) { 3797 if (m_audioSourceNode && audioSourceProvider()) {
3812 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. 3798 // When creating the player, make sure its AudioSourceProvider knows abo ut the client.
3813 audioSourceProvider()->setClient(m_audioSourceNode); 3799 audioSourceProvider()->setClient(m_audioSourceNode);
3814 } 3800 }
3815 #endif
3816 } 3801 }
3817 3802
3818 #if ENABLE(WEB_AUDIO)
3819 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3803 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
3820 { 3804 {
3821 m_audioSourceNode = sourceNode; 3805 m_audioSourceNode = sourceNode;
3822 3806
3823 AudioSourceProviderClientLockScope scope(*this); 3807 AudioSourceProviderClientLockScope scope(*this);
3824 if (audioSourceProvider()) 3808 if (audioSourceProvider())
3825 audioSourceProvider()->setClient(m_audioSourceNode); 3809 audioSourceProvider()->setClient(m_audioSourceNode);
3826 } 3810 }
3827 3811
3828 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() 3812 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
3829 { 3813 {
3830 if (m_player) 3814 if (m_player)
3831 return m_player->audioSourceProvider(); 3815 return m_player->audioSourceProvider();
3832 3816
3833 return 0; 3817 return 0;
3834 } 3818 }
3835 #endif
3836 3819
3837 const AtomicString& HTMLMediaElement::mediaGroup() const 3820 const AtomicString& HTMLMediaElement::mediaGroup() const
3838 { 3821 {
3839 return fastGetAttribute(mediagroupAttr); 3822 return fastGetAttribute(mediagroupAttr);
3840 } 3823 }
3841 3824
3842 void HTMLMediaElement::setMediaGroup(const AtomicString& group) 3825 void HTMLMediaElement::setMediaGroup(const AtomicString& group)
3843 { 3826 {
3844 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup 3827 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup
3845 // attribute is set, changed, or removed, the user agent must run the follow ing steps: 3828 // attribute is set, changed, or removed, the user agent must run the follow ing steps:
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 visitor->trace(m_asyncEventQueue); 3969 visitor->trace(m_asyncEventQueue);
3987 visitor->trace(m_error); 3970 visitor->trace(m_error);
3988 visitor->trace(m_currentSourceNode); 3971 visitor->trace(m_currentSourceNode);
3989 visitor->trace(m_nextChildNodeToConsider); 3972 visitor->trace(m_nextChildNodeToConsider);
3990 visitor->trace(m_mediaSource); 3973 visitor->trace(m_mediaSource);
3991 visitor->trace(m_audioTracks); 3974 visitor->trace(m_audioTracks);
3992 visitor->trace(m_videoTracks); 3975 visitor->trace(m_videoTracks);
3993 visitor->trace(m_textTracks); 3976 visitor->trace(m_textTracks);
3994 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3977 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3995 visitor->trace(m_mediaController); 3978 visitor->trace(m_mediaController);
3996 #if ENABLE(WEB_AUDIO)
3997 visitor->registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::clearWeakM embers>(this); 3979 visitor->registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::clearWeakM embers>(this);
3998 #endif
3999 HeapSupplementable<HTMLMediaElement>::trace(visitor); 3980 HeapSupplementable<HTMLMediaElement>::trace(visitor);
4000 #endif 3981 #endif
4001 HTMLElement::trace(visitor); 3982 HTMLElement::trace(visitor);
4002 } 3983 }
4003 3984
4004 void HTMLMediaElement::createPlaceholderTracksIfNecessary() 3985 void HTMLMediaElement::createPlaceholderTracksIfNecessary()
4005 { 3986 {
4006 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 3987 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
4007 return; 3988 return;
4008 3989
(...skipping 13 matching lines...) Expand all
4022 4003
4023 // Enable the first audio track if an audio track hasn't been enabled yet. 4004 // Enable the first audio track if an audio track hasn't been enabled yet.
4024 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 4005 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
4025 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 4006 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
4026 4007
4027 // Select the first video track if a video track hasn't been selected yet. 4008 // Select the first video track if a video track hasn't been selected yet.
4028 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 4009 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
4029 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 4010 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
4030 } 4011 }
4031 4012
4032 #if ENABLE(WEB_AUDIO)
4033 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4013 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4034 { 4014 {
4035 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4015 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4036 audioSourceProvider()->setClient(0); 4016 audioSourceProvider()->setClient(0);
4037 } 4017 }
4038 #endif
4039 4018
4040 } 4019 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698