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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp

Issue 1593763002: Keep AudioSourceNode from premature GC with ScriptWrappable::hasPendingActivity() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added [DependentLifetime] Created 4 years, 10 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) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 ASSERT(isMainThread()); 783 ASSERT(isMainThread());
784 AutoLocker locker(this); 784 AutoLocker locker(this);
785 785
786 m_activeSourceNodes.append(node); 786 m_activeSourceNodes.append(node);
787 node->handler().makeConnection(); 787 node->handler().makeConnection();
788 } 788 }
789 789
790 void AbstractAudioContext::releaseActiveSourceNodes() 790 void AbstractAudioContext::releaseActiveSourceNodes()
791 { 791 {
792 ASSERT(isMainThread()); 792 ASSERT(isMainThread());
793 for (auto& sourceNode : m_activeSourceNodes) 793 AutoLocker locker(this);
794
795 for (AudioNode* sourceNode : m_activeSourceNodes) {
796
797 // NOTE: this check makes the renderer crash.
hongchan 2016/02/19 00:46:47 It is necessary to half the active source node. Ot
798 if (sourceNode->handler().nodeType() == AudioHandler::NodeTypeOscillator || AudioHandler::NodeTypeAudioBufferSource) {
799 AudioScheduledSourceNode* scheduledSourceNode = static_cast<AudioSch eduledSourceNode*>(sourceNode);
800 scheduledSourceNode->releaseFromContext();
801 }
802
794 sourceNode->handler().breakConnection(); 803 sourceNode->handler().breakConnection();
804 }
795 805
796 m_activeSourceNodes.clear(); 806 m_activeSourceNodes.clear();
797 } 807 }
798 808
799 void AbstractAudioContext::handleStoppableSourceNodes() 809 void AbstractAudioContext::handleStoppableSourceNodes()
800 { 810 {
801 ASSERT(isGraphOwner()); 811 ASSERT(isGraphOwner());
802 812
803 // Find AudioBufferSourceNodes to see if we can stop playing them. 813 // Find AudioBufferSourceNodes to see if we can stop playing them.
804 for (AudioNode* node : m_activeSourceNodes) { 814 for (AudioNode* node : m_activeSourceNodes) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 SecurityOrigin* AbstractAudioContext::securityOrigin() const 957 SecurityOrigin* AbstractAudioContext::securityOrigin() const
948 { 958 {
949 if (executionContext()) 959 if (executionContext())
950 return executionContext()->securityOrigin(); 960 return executionContext()->securityOrigin();
951 961
952 return nullptr; 962 return nullptr;
953 } 963 }
954 964
955 } // namespace blink 965 } // namespace blink
956 966
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698