Bug 1436694 - Clarify that MediaEngineSources can be double-stopped. r=padenot

This is already true for the audio sources. It should be for all.

Crashtests showed that shutting down amidst the async init can lead to
double-stops. It is impossible to completely protect yourself from them without
waiting for all queued operations to resolve (results to become known) before
taking action. Doing that would require a refactor in MediaManager and cause
higher latency for device operations so it seems like the wrong way to go.

MozReview-Commit-ID: 5Cci6whzTL7

--HG--
extra : rebase_source : 18efef4e294ac2b02753721ca5813bcbf63e3111
This commit is contained in:
Andreas Pehrson 2018-02-22 12:23:06 +01:00
Родитель 98c3816ece
Коммит 0815f2e5dc
4 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -238,6 +238,10 @@ MediaEngineDefaultVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandl
{
AssertIsOnOwningThread();
if (mState == kStopped || mState == kAllocated) {
return NS_OK;
}
MOZ_ASSERT(mState == kStarted);
MOZ_ASSERT(mTimer);
MOZ_ASSERT(mStream);
@ -498,8 +502,11 @@ MediaEngineDefaultAudioSource::Stop(const RefPtr<const AllocationHandle>& aHandl
{
AssertIsOnOwningThread();
MOZ_ASSERT(mState == kStarted);
if (mState == kStopped || mState == kAllocated) {
return NS_OK;
}
MOZ_ASSERT(mState == kStarted);
MutexAutoLock lock(mMutex);
mState = kStopped;

Просмотреть файл

@ -324,6 +324,10 @@ MediaEngineRemoteVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandle
LOG((__PRETTY_FUNCTION__));
AssertIsOnOwningThread();
if (mState == kStopped || mState == kAllocated) {
return NS_OK;
}
MOZ_ASSERT(mState == kStarted);
if (camera::GetChildAndCall(&camera::CamerasChild::StopCapture,

Просмотреть файл

@ -171,6 +171,9 @@ public:
*
* If this was the last AllocationHandle that had been started,
* the underlying device will be stopped.
*
* Double-stopping a given allocation handle is allowed and will return NS_OK.
* This is necessary sometimes during shutdown.
*/
virtual nsresult Stop(const RefPtr<const AllocationHandle>& aHandle) = 0;

Просмотреть файл

@ -402,6 +402,11 @@ nsresult
MediaEngineTabVideoSource::Stop(const RefPtr<const AllocationHandle>& aHandle)
{
AssertIsOnOwningThread();
if (mState == kStopped || mState == kAllocated) {
return NS_OK;
}
MOZ_ASSERT(mState == kStarted);
// If mBlackedoutWindow is true, we may be running