mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1103188 - Keep track of stopped tracks in gUM stream listener. r=jib
This is needed to avoid something like: * [old stream] stop track 1 -> deallocate MediaDevice for track 1 * [new stream] gUM() -> allocate MediaDevice for track 1 * [old stream] stop stream -> deallocate MediaDevice for track 1 * [new stream] gUM() -> start MediaDevice for track 1 (oops, MediaDevice was no more!)
This commit is contained in:
parent
b53b7b0e03
commit
310106a37d
@ -3016,7 +3016,6 @@ GetUserMediaCallbackMediaStreamListener::Invalidate()
|
||||
if (mStopped) {
|
||||
return;
|
||||
}
|
||||
mStopped = true;
|
||||
|
||||
// We can't take a chance on blocking here, so proxy this to another
|
||||
// thread.
|
||||
@ -3025,8 +3024,10 @@ GetUserMediaCallbackMediaStreamListener::Invalidate()
|
||||
MediaManager::PostTask(FROM_HERE,
|
||||
new MediaOperationTask(MEDIA_STOP,
|
||||
this, nullptr, nullptr,
|
||||
mAudioDevice, mVideoDevice,
|
||||
!mAudioStopped ? mAudioDevice.get() : nullptr,
|
||||
!mVideoStopped ? mVideoDevice.get() : nullptr,
|
||||
mFinished, mWindowID, nullptr));
|
||||
mStopped = mAudioStopped = mVideoStopped = true;
|
||||
}
|
||||
|
||||
// Doesn't kill audio
|
||||
@ -3041,12 +3042,13 @@ GetUserMediaCallbackMediaStreamListener::StopSharing()
|
||||
// Stop the whole stream if there's no audio; just the video track if we have both
|
||||
if (!mAudioDevice) {
|
||||
Invalidate();
|
||||
} else {
|
||||
} else if (!mVideoStopped) {
|
||||
MediaManager::PostTask(FROM_HERE,
|
||||
new MediaOperationTask(MEDIA_STOP_TRACK,
|
||||
this, nullptr, nullptr,
|
||||
nullptr, mVideoDevice,
|
||||
mFinished, mWindowID, nullptr));
|
||||
mVideoStopped = true;
|
||||
}
|
||||
} else if (mAudioDevice &&
|
||||
mAudioDevice->GetMediaSource() == dom::MediaSourceEnum::AudioCapture) {
|
||||
@ -3166,12 +3168,16 @@ GetUserMediaCallbackMediaStreamListener::StopTrack(TrackID aTrackID, bool aIsAud
|
||||
{
|
||||
// XXX to support multiple tracks of a type in a stream, this should key off
|
||||
// the TrackID and not just the type
|
||||
bool stopAudio = aIsAudio && !mAudioStopped;
|
||||
bool stopVideo = !aIsAudio && !mVideoStopped;
|
||||
MediaManager::PostTask(FROM_HERE,
|
||||
new MediaOperationTask(MEDIA_STOP_TRACK,
|
||||
this, nullptr, nullptr,
|
||||
aIsAudio ? mAudioDevice.get() : nullptr,
|
||||
!aIsAudio ? mVideoDevice.get() : nullptr,
|
||||
stopAudio ? mAudioDevice.get() : nullptr,
|
||||
stopVideo ? mVideoDevice.get() : nullptr,
|
||||
mFinished, mWindowID, nullptr));
|
||||
mAudioStopped |= stopAudio;
|
||||
mVideoStopped |= stopVideo;
|
||||
} else {
|
||||
LOG(("gUM track %d ended, but we don't have type %s",
|
||||
aTrackID, aIsAudio ? "audio" : "video"));
|
||||
|
@ -128,7 +128,9 @@ public:
|
||||
, mWindowID(aWindowID)
|
||||
, mStopped(false)
|
||||
, mFinished(false)
|
||||
, mRemoved(false) {}
|
||||
, mRemoved(false)
|
||||
, mAudioStopped(false)
|
||||
, mVideoStopped(false) {}
|
||||
|
||||
~GetUserMediaCallbackMediaStreamListener()
|
||||
{
|
||||
@ -312,6 +314,14 @@ private:
|
||||
// MainThread only.
|
||||
bool mRemoved;
|
||||
|
||||
// true if we have sent MEDIA_STOP or MEDIA_STOP_TRACK for mAudioDevice.
|
||||
// MainThread only.
|
||||
bool mAudioStopped;
|
||||
|
||||
// true if we have sent MEDIA_STOP or MEDIA_STOP_TRACK for mAudioDevice.
|
||||
// MainThread only.
|
||||
bool mVideoStopped;
|
||||
|
||||
// Set at Activate on MainThread
|
||||
|
||||
// Accessed from MediaStreamGraph thread, MediaManager thread, and MainThread
|
||||
|
Loading…
Reference in New Issue
Block a user