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

Side by Side Diff: Source/modules/webaudio/AudioContext.cpp

Issue 386403002: WebAudio: Split AudioNode::finishDeref into two parts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 bool AudioContext::isAudioThread() const 674 bool AudioContext::isAudioThread() const
675 { 675 {
676 return currentThread() == m_audioThread; 676 return currentThread() == m_audioThread;
677 } 677 }
678 678
679 bool AudioContext::isGraphOwner() const 679 bool AudioContext::isGraphOwner() const
680 { 680 {
681 return currentThread() == m_graphOwnerThread; 681 return currentThread() == m_graphOwnerThread;
682 } 682 }
683 683
684 void AudioContext::addDeferredBreakConnection(AudioNode& node)
685 {
686 ASSERT(isAudioThread());
687 m_deferredBreakConnectionList.append(&node);
688 }
689
684 void AudioContext::addDeferredFinishDeref(AudioNode* node) 690 void AudioContext::addDeferredFinishDeref(AudioNode* node)
685 { 691 {
686 ASSERT(isAudioThread()); 692 ASSERT(isAudioThread());
687 m_deferredFinishDerefList.append(node); 693 m_deferredFinishDerefList.append(node);
688 } 694 }
689 695
690 void AudioContext::handlePreRenderTasks() 696 void AudioContext::handlePreRenderTasks()
691 { 697 {
692 ASSERT(isAudioThread()); 698 ASSERT(isAudioThread());
693 699
(...skipping 14 matching lines...) Expand all
708 714
709 void AudioContext::handlePostRenderTasks() 715 void AudioContext::handlePostRenderTasks()
710 { 716 {
711 ASSERT(isAudioThread()); 717 ASSERT(isAudioThread());
712 718
713 // Must use a tryLock() here too. Don't worry, the lock will very rarely be contended and this method is called frequently. 719 // Must use a tryLock() here too. Don't worry, the lock will very rarely be contended and this method is called frequently.
714 // The worst that can happen is that there will be some nodes which will tak e slightly longer than usual to be deleted or removed 720 // The worst that can happen is that there will be some nodes which will tak e slightly longer than usual to be deleted or removed
715 // from the render graph (in which case they'll render silence). 721 // from the render graph (in which case they'll render silence).
716 bool mustReleaseLock; 722 bool mustReleaseLock;
717 if (tryLock(mustReleaseLock)) { 723 if (tryLock(mustReleaseLock)) {
718 // Take care of finishing any derefs where the tryLock() failed previous ly. 724 // Take care of AudioNode tasks where the tryLock() failed previously.
719 handleDeferredFinishDerefs(); 725 handleDeferredAudioNodeTasks();
720 726
721 // Dynamically clean up nodes which are no longer needed. 727 // Dynamically clean up nodes which are no longer needed.
722 derefFinishedSourceNodes(); 728 derefFinishedSourceNodes();
723 729
724 // Don't delete in the real-time thread. Let the main thread do it. 730 // Don't delete in the real-time thread. Let the main thread do it.
725 // Ref-counted objects held by certain AudioNodes may not be thread-safe . 731 // Ref-counted objects held by certain AudioNodes may not be thread-safe .
726 scheduleNodeDeletion(); 732 scheduleNodeDeletion();
727 733
728 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu ts. 734 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu ts.
729 handleDirtyAudioSummingJunctions(); 735 handleDirtyAudioSummingJunctions();
730 handleDirtyAudioNodeOutputs(); 736 handleDirtyAudioNodeOutputs();
731 737
732 updateAutomaticPullNodes(); 738 updateAutomaticPullNodes();
733 739
734 if (mustReleaseLock) 740 if (mustReleaseLock)
735 unlock(); 741 unlock();
736 } 742 }
737 } 743 }
738 744
739 void AudioContext::handleDeferredFinishDerefs() 745 void AudioContext::handleDeferredAudioNodeTasks()
740 { 746 {
741 ASSERT(isAudioThread() && isGraphOwner()); 747 ASSERT(isAudioThread() && isGraphOwner());
748
749 for (unsigned i = 0; i < m_deferredBreakConnectionList.size(); ++i)
750 m_deferredBreakConnectionList[i]->breakConnectionWithLock();
751 m_deferredBreakConnectionList.clear();
752
742 for (unsigned i = 0; i < m_deferredFinishDerefList.size(); ++i) { 753 for (unsigned i = 0; i < m_deferredFinishDerefList.size(); ++i) {
743 AudioNode* node = m_deferredFinishDerefList[i]; 754 AudioNode* node = m_deferredFinishDerefList[i];
sof 2014/07/14 19:09:26 style nit: if you want to use a consistent style i
tkent 2014/07/15 01:19:23 Done.
744 node->finishDeref(); 755 node->finishDeref();
745 } 756 }
746
747 m_deferredFinishDerefList.clear(); 757 m_deferredFinishDerefList.clear();
748 } 758 }
749 759
750 void AudioContext::markForDeletion(AudioNode* node) 760 void AudioContext::markForDeletion(AudioNode* node)
751 { 761 {
752 ASSERT(isGraphOwner()); 762 ASSERT(isGraphOwner());
753 763
754 if (!isInitialized()) 764 if (!isInitialized())
755 m_nodesToDelete.append(node); 765 m_nodesToDelete.append(node);
756 else 766 else
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 visitor->trace(m_renderTarget); 964 visitor->trace(m_renderTarget);
955 visitor->trace(m_destinationNode); 965 visitor->trace(m_destinationNode);
956 visitor->trace(m_listener); 966 visitor->trace(m_listener);
957 visitor->trace(m_dirtySummingJunctions); 967 visitor->trace(m_dirtySummingJunctions);
958 EventTargetWithInlineData::trace(visitor); 968 EventTargetWithInlineData::trace(visitor);
959 } 969 }
960 970
961 } // namespace WebCore 971 } // namespace WebCore
962 972
963 #endif // ENABLE(WEB_AUDIO) 973 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698