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

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

Issue 393133003: Oilpan: WebAudio: Apply the weak HashMap pattern to remove an entry from AudioContext::m_dirtyAudio… (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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 m_destinationNode->startRendering(); 184 m_destinationNode->startRendering();
185 ++s_hardwareContextCount; 185 ++s_hardwareContextCount;
186 } 186 }
187 187
188 m_isInitialized = true; 188 m_isInitialized = true;
189 } 189 }
190 } 190 }
191 191
192 void AudioContext::clear() 192 void AudioContext::clear()
193 { 193 {
194 #if ENABLE(OILPAN)
195 // We need to run disposers before destructing m_contextGraphMutex.
196 m_liveAudioSummingJunctions.clear();
197 #endif
198
194 // We have to release our reference to the destination node before the conte xt will ever be deleted since the destination node holds a reference to the cont ext. 199 // We have to release our reference to the destination node before the conte xt will ever be deleted since the destination node holds a reference to the cont ext.
195 if (m_destinationNode) 200 if (m_destinationNode)
196 m_destinationNode.clear(); 201 m_destinationNode.clear();
197 202
198 // Audio thread is dead. Nobody will schedule node deletion action. Let's do it ourselves. 203 // Audio thread is dead. Nobody will schedule node deletion action. Let's do it ourselves.
199 do { 204 do {
200 m_nodesToDelete.appendVector(m_nodesMarkedForDeletion); 205 m_nodesToDelete.appendVector(m_nodesMarkedForDeletion);
201 m_nodesMarkedForDeletion.clear(); 206 m_nodesMarkedForDeletion.clear();
202 deleteMarkedNodes(); 207 deleteMarkedNodes();
203 } while (m_nodesToDelete.size()); 208 } while (m_nodesToDelete.size());
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 754
750 for (unsigned i = 0; i < m_deferredBreakConnectionList.size(); ++i) 755 for (unsigned i = 0; i < m_deferredBreakConnectionList.size(); ++i)
751 m_deferredBreakConnectionList[i]->breakConnectionWithLock(); 756 m_deferredBreakConnectionList[i]->breakConnectionWithLock();
752 m_deferredBreakConnectionList.clear(); 757 m_deferredBreakConnectionList.clear();
753 758
754 for (unsigned i = 0; i < m_deferredFinishDerefList.size(); ++i) 759 for (unsigned i = 0; i < m_deferredFinishDerefList.size(); ++i)
755 m_deferredFinishDerefList[i]->finishDeref(); 760 m_deferredFinishDerefList[i]->finishDeref();
756 m_deferredFinishDerefList.clear(); 761 m_deferredFinishDerefList.clear();
757 } 762 }
758 763
764 #if ENABLE(OILPAN)
765 void AudioContext::registerLiveAudioSummingJunction(AudioSummingJunction& juncti on)
766 {
767 ASSERT(isMainThread());
768 m_liveAudioSummingJunctions.add(&junction, adoptPtr(new AudioSummingJunction Disposer(junction)));
769 }
770
771 AudioContext::AudioSummingJunctionDisposer::~AudioSummingJunctionDisposer()
772 {
773 ASSERT(isMainThread());
774 AudioContext::AutoLocker locker(m_junction.context());
haraken 2014/07/18 09:49:30 Won't this cause a dead lock? removeMarkedSummingJ
tkent 2014/07/18 09:52:16 No. AutoLocker supports reentrancy. If the curre
tkent 2014/07/18 09:54:22 Anyway, this AutoLocker is redundant and unnecessa
haraken 2014/07/18 10:01:01 Makes sense. However, I think you can just drop th
tkent 2014/07/18 13:43:09 Indeed.
775 m_junction.context()->removeMarkedSummingJunction(&m_junction);
776 }
777 #endif
778
759 void AudioContext::markForDeletion(AudioNode* node) 779 void AudioContext::markForDeletion(AudioNode* node)
760 { 780 {
761 ASSERT(isGraphOwner()); 781 ASSERT(isGraphOwner());
762 782
763 if (!isInitialized()) 783 if (!isInitialized())
764 m_nodesToDelete.append(node); 784 m_nodesToDelete.append(node);
765 else 785 else
766 m_nodesMarkedForDeletion.append(node); 786 m_nodesMarkedForDeletion.append(node);
767 787
768 // This is probably the best time for us to remove the node from automatic p ull list, 788 // This is probably the best time for us to remove the node from automatic p ull list,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 830
811 // Protect this object from being deleted before we release the mutex locked by AutoLocker. 831 // Protect this object from being deleted before we release the mutex locked by AutoLocker.
812 RefPtrWillBeRawPtr<AudioContext> protect(this); 832 RefPtrWillBeRawPtr<AudioContext> protect(this);
813 { 833 {
814 AutoLocker locker(this); 834 AutoLocker locker(this);
815 835
816 while (size_t n = m_nodesToDelete.size()) { 836 while (size_t n = m_nodesToDelete.size()) {
817 AudioNode* node = m_nodesToDelete[n - 1]; 837 AudioNode* node = m_nodesToDelete[n - 1];
818 m_nodesToDelete.removeLast(); 838 m_nodesToDelete.removeLast();
819 839
840 #if !ENABLE(OILPAN)
haraken 2014/07/18 10:01:00 Probably can we keep this code? In terms of perfor
tkent 2014/07/18 13:43:08 Yeah, It's ok to keep this.
820 // Before deleting the node, clear out any AudioNodeInputs from m_di rtySummingJunctions. 841 // Before deleting the node, clear out any AudioNodeInputs from m_di rtySummingJunctions.
821 unsigned numberOfInputs = node->numberOfInputs(); 842 unsigned numberOfInputs = node->numberOfInputs();
822 for (unsigned i = 0; i < numberOfInputs; ++i) 843 for (unsigned i = 0; i < numberOfInputs; ++i)
823 m_dirtySummingJunctions.remove(node->input(i)); 844 m_dirtySummingJunctions.remove(node->input(i));
845 #endif
824 846
825 // Before deleting the node, clear out any AudioNodeOutputs from m_d irtyAudioNodeOutputs. 847 // Before deleting the node, clear out any AudioNodeOutputs from m_d irtyAudioNodeOutputs.
826 unsigned numberOfOutputs = node->numberOfOutputs(); 848 unsigned numberOfOutputs = node->numberOfOutputs();
827 for (unsigned i = 0; i < numberOfOutputs; ++i) 849 for (unsigned i = 0; i < numberOfOutputs; ++i)
828 m_dirtyAudioNodeOutputs.remove(node->output(i)); 850 m_dirtyAudioNodeOutputs.remove(node->output(i));
829 851
830 #if ENABLE(OILPAN) 852 #if ENABLE(OILPAN)
831 // Finally, clear the keep alive handle that keeps this 853 // Finally, clear the keep alive handle that keeps this
832 // object from being collected. 854 // object from being collected.
833 node->clearKeepAlive(); 855 node->clearKeepAlive();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 // Call the offline rendering completion event listener. 980 // Call the offline rendering completion event listener.
959 dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer)); 981 dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer));
960 } 982 }
961 } 983 }
962 984
963 void AudioContext::trace(Visitor* visitor) 985 void AudioContext::trace(Visitor* visitor)
964 { 986 {
965 visitor->trace(m_renderTarget); 987 visitor->trace(m_renderTarget);
966 visitor->trace(m_destinationNode); 988 visitor->trace(m_destinationNode);
967 visitor->trace(m_listener); 989 visitor->trace(m_listener);
990 #if ENABLE(OILPAN)
991 visitor->trace(m_liveAudioSummingJunctions);
992 #endif
968 EventTargetWithInlineData::trace(visitor); 993 EventTargetWithInlineData::trace(visitor);
969 } 994 }
970 995
971 } // namespace WebCore 996 } // namespace WebCore
972 997
973 #endif // ENABLE(WEB_AUDIO) 998 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698