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 : f4dccbc5a56e33ecc54d63ddefbae43d90ee95d4
extra : source : f5cc71d38e4a7c0e4db830242c1d454fcbdb9e48
extra : histedit_source : 3cd8615054ce9935047e4168c3a472152792886b
This commit is contained in:
Andreas Pehrson 2018-02-22 12:23:06 +01:00
Родитель c9e4a19d1e
Коммит 411e973fab
4 изменённых файлов: 20 добавлений и 1 удалений

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

@ -237,6 +237,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);
@ -495,8 +499,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