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

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

Issue 1958333006: Prevent audio thread access to finished, non-active AudioNodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.h ('k') | 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 /* 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } 780 }
781 m_finishedSourceNodes.clear(); 781 m_finishedSourceNodes.clear();
782 } 782 }
783 783
784 void AbstractAudioContext::releaseFinishedSourceNodes() 784 void AbstractAudioContext::releaseFinishedSourceNodes()
785 { 785 {
786 ASSERT(isGraphOwner()); 786 ASSERT(isGraphOwner());
787 ASSERT(isAudioThread()); 787 ASSERT(isAudioThread());
788 bool didRemove = false; 788 bool didRemove = false;
789 for (AudioHandler* handler : m_finishedSourceHandlers) { 789 for (AudioHandler* handler : m_finishedSourceHandlers) {
790 for (unsigned i = 0; i < m_activeSourceNodes.size(); ++i) { 790 for (AudioNode* node : m_activeSourceNodes) {
791 if (handler == &m_activeSourceNodes[i]->handler()) { 791 if (m_finishedSourceNodes.contains(node))
792 continue;
793 if (handler == &node->handler()) {
792 handler->breakConnection(); 794 handler->breakConnection();
793 m_finishedSourceNodes.append(m_activeSourceNodes[i]); 795 m_finishedSourceNodes.add(node);
794 didRemove = true; 796 didRemove = true;
795 break; 797 break;
796 } 798 }
797 } 799 }
798 } 800 }
799 if (didRemove) 801 if (didRemove)
800 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&AbstractAudioContext::removeFinishedSourceNodes, this)) ; 802 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&AbstractAudioContext::removeFinishedSourceNodes, this)) ;
801 803
802 m_finishedSourceHandlers.clear(); 804 m_finishedSourceHandlers.clear();
803 } 805 }
(...skipping 15 matching lines...) Expand all
819 821
820 m_activeSourceNodes.clear(); 822 m_activeSourceNodes.clear();
821 } 823 }
822 824
823 void AbstractAudioContext::handleStoppableSourceNodes() 825 void AbstractAudioContext::handleStoppableSourceNodes()
824 { 826 {
825 ASSERT(isGraphOwner()); 827 ASSERT(isGraphOwner());
826 828
827 // Find AudioBufferSourceNodes to see if we can stop playing them. 829 // Find AudioBufferSourceNodes to see if we can stop playing them.
828 for (AudioNode* node : m_activeSourceNodes) { 830 for (AudioNode* node : m_activeSourceNodes) {
831 if (m_finishedSourceNodes.contains(node))
Raymond Toy 2016/05/10 16:04:20 Can you add a comment here why you're skipping act
sof 2016/05/10 19:09:09 Added comment, let's see if it makes sense in 6 mo
Raymond Toy 2016/05/10 19:54:57 Excellent! At least I'll have some understanding
832 continue;
829 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo urce) { 833 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo urce) {
830 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod e*>(node); 834 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod e*>(node);
831 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode(); 835 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode();
832 } 836 }
833 } 837 }
834 } 838 }
835 839
836 void AbstractAudioContext::handlePreRenderTasks() 840 void AbstractAudioContext::handlePreRenderTasks()
837 { 841 {
838 ASSERT(isAudioThread()); 842 ASSERT(isAudioThread());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 972
969 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const 973 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const
970 { 974 {
971 if (getExecutionContext()) 975 if (getExecutionContext())
972 return getExecutionContext()->getSecurityOrigin(); 976 return getExecutionContext()->getSecurityOrigin();
973 977
974 return nullptr; 978 return nullptr;
975 } 979 }
976 980
977 } // namespace blink 981 } // namespace blink
978
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698