Backed out changeset cace8e8e8556 because of the wrong bug number
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 01 May 2013 01:15:09 -0400
changeset 130440 0ad4e00d794536b440bd8cd3bfdf448755a558bf
parent 130439 cace8e8e855692a7d2648de7e9a99cd323e813bc
child 130441 c00516696e8c2e409f20bca466afb8467a1c60a1
push id27369
push usereakhgari@mozilla.com
push dateWed, 01 May 2013 05:16:03 +0000
treeherdermozilla-inbound@c00516696e8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone23.0a1
backs outcace8e8e855692a7d2648de7e9a99cd323e813bc
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset cace8e8e8556 because of the wrong bug number
content/media/webaudio/AudioContext.cpp
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -292,57 +292,43 @@ AudioContext::DestinationStream() const
 }
 
 double
 AudioContext::CurrentTime() const
 {
   return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime());
 }
 
-template <class T>
 static PLDHashOperator
-GetHashtableEntry(nsPtrHashKey<T>* aEntry, void* aData)
+StopAudioBufferSourceNode(nsPtrHashKey<AudioBufferSourceNode>* aEntry, void* aData)
 {
-  nsTArray<T*>* array = static_cast<nsTArray<T*>*>(aData);
-  array->AppendElement(aEntry->GetKey());
+  ErrorResult rv;
+  aEntry->GetKey()->Stop(0.0, rv);
   return PL_DHASH_NEXT;
 }
 
-template <class T>
-static void
-GetHashtableElements(nsTHashtable<nsPtrHashKey<T> >& aHashtable, nsTArray<T*>& aArray)
+static PLDHashOperator
+StopScriptProcessorNode(nsPtrHashKey<ScriptProcessorNode>* aEntry, void* aData)
 {
-  aHashtable.EnumerateEntries(&GetHashtableEntry<T>, &aArray);
+  aEntry->GetKey()->Stop();
+  return PL_DHASH_NEXT;
 }
 
 void
 AudioContext::Shutdown()
 {
   Suspend();
   mDecoder.Shutdown();
 
   // Stop all audio buffer source nodes, to make sure that they release
   // their self-references.
-  // We first gather an array of the nodes and then call Stop on each one,
-  // since Stop may delete the object and therefore trigger a re-entrant
-  // hashtable call to remove the pointer from the hashtable, which is
-  // not safe.
-  nsTArray<AudioBufferSourceNode*> sourceNodes;
-  GetHashtableElements(mAudioBufferSourceNodes, sourceNodes);
-  for (uint32_t i = 0; i < sourceNodes.Length(); ++i) {
-    ErrorResult rv;
-    sourceNodes[i]->Stop(0.0, rv);
-  }
+  mAudioBufferSourceNodes.EnumerateEntries(StopAudioBufferSourceNode, nullptr);
   // Stop all script processor nodes, to make sure that they release
   // their self-references.
-  nsTArray<ScriptProcessorNode*> spNodes;
-  GetHashtableElements(mScriptProcessorNodes, spNodes);
-  for (uint32_t i = 0; i < spNodes.Length(); ++i) {
-    spNodes[i]->Stop();
-  }
+  mScriptProcessorNodes.EnumerateEntries(StopScriptProcessorNode, nullptr);
 }
 
 void
 AudioContext::Suspend()
 {
   MediaStream* ds = DestinationStream();
   if (ds) {
     ds->ChangeExplicitBlockerCount(1);