Bug 896353 - Media Recording - Can't record the mediaStream created by AudioContext. r=roc
☠☠ backed out by 5aa02ee02f4b ☠ ☠
authorRandy Lin <rlin@mozilla.com>
Fri, 26 Jul 2013 20:29:41 +0800
changeset 140124 4fe81f58dbef639635e15d39a0ff33d56b3ce80d
parent 140123 f8f855f0b7dca6063d09cc00763f787e18d944de
child 140125 f2862e93b71017234ca2217cbe28d2d40b940eff
push id1945
push userryanvm@gmail.com
push dateSat, 27 Jul 2013 02:27:26 +0000
treeherderfx-team@4874fa438b1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs896353
milestone25.0a1
Bug 896353 - Media Recording - Can't record the mediaStream created by AudioContext. r=roc
content/media/MediaRecorder.cpp
content/media/MediaRecorder.h
--- a/content/media/MediaRecorder.cpp
+++ b/content/media/MediaRecorder.cpp
@@ -110,16 +110,19 @@ public:
 
 private:
   nsRefPtr<MediaRecorder> mRecorder;
   nsRefPtr<MediaEncoder>  mEncoder;
 };
 
 MediaRecorder::~MediaRecorder()
 {
+  if (mStreamPort) {
+    mStreamPort->Destroy();
+  }
   if (mTrackUnionStream) {
     mTrackUnionStream->Destroy();
   }
 }
 
 void
 MediaRecorder::Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow)
 {
@@ -187,18 +190,17 @@ MediaRecorder::Start(const Optional<int3
   if (mEncodedBufferCache == nullptr) {
     mEncodedBufferCache = new EncodedBufferCache(MAX_ALLOW_MEMORY_BUFFER);
   }
 
   mEncoder = MediaEncoder::CreateEncoder(NS_LITERAL_STRING(""));
   MOZ_ASSERT(mEncoder, "CreateEncoder failed");
 
   mTrackUnionStream->SetAutofinish(true);
-  nsRefPtr<MediaInputPort> port =
-    mTrackUnionStream->AllocateInputPort(mStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
+  mStreamPort = mTrackUnionStream->AllocateInputPort(mStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
 
   if (mEncoder) {
     mTrackUnionStream->AddListener(mEncoder);
   } else {
     aResult.Throw(NS_ERROR_DOM_ABORT_ERR);
   }
 
   if (!mReadThread) {
--- a/content/media/MediaRecorder.h
+++ b/content/media/MediaRecorder.h
@@ -105,16 +105,18 @@ protected:
   // Runnable thread for read data from mediaEncoder. It starts at MediaRecorder::Start() and stops at MediaRecorder::Stop().
   nsCOMPtr<nsIThread> mReadThread;
   // The MediaEncoder object initializes on start() and destroys in ~MediaRecorder.
   nsRefPtr<MediaEncoder> mEncoder;
   // MediaStream passed from js context
   nsRefPtr<DOMMediaStream> mStream;
   // This media stream is used for notifying raw data to encoder and can be blocked.
   nsRefPtr<ProcessedMediaStream> mTrackUnionStream;
+  // This is used for destroing the inputport when destroy the mediaRecorder
+  nsRefPtr<MediaInputPort> mStreamPort;
   // This object creates on start() and destroys in ~MediaRecorder.
   nsAutoPtr<EncodedBufferCache> mEncodedBufferCache;
   // It specifies the container format as well as the audio and video capture formats.
   nsString mMimeType;
   // The interval of timer passed from Start(). On every mTimeSlice milliseconds, if there are buffers store in the EncodedBufferCache,
   // a dataavailable event will be fired.
   int32_t mTimeSlice;
   // The current state of the MediaRecorder object.