Bug 1157654 - Back out changeset 4803c84d4976 (bug 1153690) for frequent failures in dom/media/test/test_mediarecorder_getencodeddata.html .

This commit is contained in:
L. David Baron 2015-04-25 11:09:45 -07:00
parent 744a667732
commit cb11d79c42

View File

@ -368,12 +368,11 @@ class MediaRecorder::Session: public nsIObserver
public:
Session(MediaRecorder* aRecorder, int32_t aTimeSlice)
: mRecorder(aRecorder)
, mTimeSlice(aTimeSlice)
, mStopIssued(false)
, mCanRetrieveData(false)
, mIsRegisterProfiler(false)
, mNeedSessionEndTask(true)
: mRecorder(aRecorder),
mTimeSlice(aTimeSlice),
mStopIssued(false),
mCanRetrieveData(false),
mIsRegisterProfiler(false)
{
MOZ_ASSERT(NS_IsMainThread());
@ -397,11 +396,6 @@ public:
MOZ_ASSERT(NS_IsMainThread());
mStopIssued = true;
CleanupStreams();
if (mNeedSessionEndTask) {
LOG(PR_LOG_DEBUG, ("Session.Stop mNeedSessionEndTask %p", this));
// End the Session directly if there is no ExtractRunnable.
DoSessionEndTask(NS_OK);
}
nsContentUtils::UnregisterShutdownObserver(this);
}
@ -584,10 +578,6 @@ private:
LOG(PR_LOG_DEBUG, ("Session.InitEncoder %p", this));
MOZ_ASSERT(NS_IsMainThread());
if (!mRecorder) {
LOG(PR_LOG_DEBUG, ("Session.InitEncoder failure, mRecorder is null %p", this));
return;
}
// Allocate encoder and bind with union stream.
// At this stage, the API doesn't allow UA to choose the output mimeType format.
@ -599,7 +589,6 @@ private:
}
if (!mEncoder) {
LOG(PR_LOG_DEBUG, ("Session.InitEncoder !mEncoder %p", this));
DoSessionEndTask(NS_ERROR_ABORT);
return;
}
@ -608,7 +597,6 @@ private:
// The Session::stop would clean the mTrackUnionStream. If the AfterTracksAdded
// comes after stop command, this function would crash.
if (!mTrackUnionStream) {
LOG(PR_LOG_DEBUG, ("Session.InitEncoder !mTrackUnionStream %p", this));
DoSessionEndTask(NS_OK);
return;
}
@ -617,26 +605,19 @@ private:
if (!mReadThread) {
nsresult rv = NS_NewNamedThread("Media_Encoder", getter_AddRefs(mReadThread));
if (NS_FAILED(rv)) {
LOG(PR_LOG_DEBUG, ("Session.InitEncoder !mReadThread %p", this));
DoSessionEndTask(rv);
return;
}
}
// In case source media stream does not notify track end, receive
// In case source media stream does not notify track end, recieve
// shutdown notification and stop Read Thread.
nsContentUtils::RegisterShutdownObserver(this);
nsCOMPtr<nsIRunnable> event = new ExtractRunnable(this);
if (NS_FAILED(mReadThread->Dispatch(event, NS_DISPATCH_NORMAL))) {
NS_WARNING("Failed to dispatch ExtractRunnable at beginning");
LOG(PR_LOG_DEBUG, ("Session.InitEncoder !ReadThread->Dispatch %p", this));
DoSessionEndTask(NS_ERROR_ABORT);
}
// Set mNeedSessionEndTask to false because the
// ExtractRunnable/DestroyRunnable will take the response to
// end the session.
mNeedSessionEndTask = false;
}
// application should get blob and onstop event
void DoSessionEndTask(nsresult rv)
@ -656,7 +637,6 @@ private:
if (NS_FAILED(NS_DispatchToMainThread(new DestroyRunnable(this)))) {
MOZ_ASSERT(false, "NS_DispatchToMainThread DestroyRunnable failed");
}
mNeedSessionEndTask = false;
}
void CleanupStreams()
{
@ -730,10 +710,6 @@ private:
bool mCanRetrieveData;
// The register flag for "Media_Encoder" thread to profiler
bool mIsRegisterProfiler;
// False if the InitEncoder called successfully, ensure the
// ExtractRunnable/DestroyRunnable will end the session.
// Main thread only.
bool mNeedSessionEndTask;
};
NS_IMPL_ISUPPORTS(MediaRecorder::Session, nsIObserver)