Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 3b781bf062425814208b18e67bcd5c3da9712c68..367d587732a04f7b2b179edf8f37be62f2daac8e 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -284,7 +284,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum |
, m_textTracks(nullptr) |
, m_ignoreTrackDisplayUpdate(0) |
#if ENABLE(WEB_AUDIO) |
- , m_audioSourceNode(0) |
+ , m_audioSourceNode(nullptr) |
#endif |
{ |
ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
@@ -372,7 +372,13 @@ HTMLMediaElement::~HTMLMediaElement() |
// crbug.com/378229 |
m_isFinalizing = true; |
#endif |
- clearMediaPlayerAndAudioSourceProviderClient(); |
+ |
+ // The m_audioSourceNode is either dead already or it is dying together with |
+ // this HTMLMediaElement which it strongly keeps alive. |
+#if !ENABLE(OILPAN) |
+ ASSERT(!m_audioSourceNode); |
+#endif |
+ clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
#if !ENABLE(OILPAN) |
document().decrementLoadEventDelayCount(); |
@@ -3119,22 +3125,13 @@ void HTMLMediaElement::userCancelledLoad() |
updateActiveTextTrackCues(0); |
} |
-void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClient() |
+void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLocking() |
{ |
#if ENABLE(WEB_AUDIO) |
- if (m_audioSourceNode) |
- m_audioSourceNode->lock(); |
- |
if (audioSourceProvider()) |
audioSourceProvider()->setClient(0); |
#endif |
- |
m_player.clear(); |
- |
-#if ENABLE(WEB_AUDIO) |
- if (m_audioSourceNode) |
- m_audioSourceNode->unlock(); |
-#endif |
} |
void HTMLMediaElement::clearMediaPlayer(int flags) |
@@ -3145,7 +3142,17 @@ void HTMLMediaElement::clearMediaPlayer(int flags) |
m_delayingLoadForPreloadNone = false; |
- clearMediaPlayerAndAudioSourceProviderClient(); |
+#if ENABLE(WEB_AUDIO) |
+ if (m_audioSourceNode) |
+ m_audioSourceNode->lock(); |
+#endif |
+ |
+ clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
+ |
+#if ENABLE(WEB_AUDIO) |
+ if (m_audioSourceNode) |
+ m_audioSourceNode->unlock(); |
+#endif |
stopPeriodicTimers(); |
m_loadTimer.stop(); |
@@ -3656,8 +3663,15 @@ void HTMLMediaElement::trace(Visitor* visitor) |
visitor->trace(m_nextChildNodeToConsider); |
visitor->trace(m_textTracks); |
visitor->trace(m_textTracksWhenResourceSelectionBegan); |
+ visitor->registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::clearWeakMembers>(this); |
WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
HTMLElement::trace(visitor); |
} |
+void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
+{ |
+ if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
+ audioSourceProvider()->setClient(0); |
haraken
2014/06/11 01:19:49
This looks OK but it would be better to just call
zerny-chromium
2014/06/11 06:26:57
I don't think so, since m_audioSourceNode is dying
|
+} |
+ |
} |