Bug 1381638 - Prevent sharing multiple input devices in the same process. r=jesup

This commit is contained in:
Jan-Ivar Bruaroey 2017-09-15 23:00:39 -04:00
Родитель 90a660e634
Коммит ffa7a61472
2 изменённых файлов: 14 добавлений и 2 удалений

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

@ -1232,8 +1232,13 @@ public:
self->mSourceListener->GetPrincipalHandle()); self->mSourceListener->GetPrincipalHandle());
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
nsString log; nsString log;
log.AssignASCII("Starting audio failed"); if (rv == NS_ERROR_NOT_AVAILABLE) {
error = new MediaMgrError(NS_LITERAL_STRING("InternalError"), log); log.AssignASCII("Concurrent mic process limit.");
error = new MediaMgrError(NS_LITERAL_STRING("NotReadableError"), log);
} else {
log.AssignASCII("Starting audio failed");
error = new MediaMgrError(NS_LITERAL_STRING("InternalError"), log);
}
} }
} }

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

@ -474,6 +474,13 @@ MediaEngineWebRTCMicrophoneSource::Start(SourceMediaStream *aStream,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Until we fix bug 1400488 we need to block a second tab (OuterWindow)
// from opening an already-open device. If it's the same tab, they
// will share a Graph(), and we can allow it.
if (!mSources.IsEmpty() && aStream->Graph() != mSources[0]->Graph()) {
return NS_ERROR_NOT_AVAILABLE;
}
{ {
MonitorAutoLock lock(mMonitor); MonitorAutoLock lock(mMonitor);
mSources.AppendElement(aStream); mSources.AppendElement(aStream);