Bug 1438134 - Resolve ApplyConstraints and end track on unexpected error. r?jib
MozReview-Commit-ID: 1uVHTCOwlQw
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1266,36 +1266,39 @@ public:
[p]()
{
if (!MediaManager::Exists()) {
return;
}
p->Resolve(false);
},
- [p, weakWindow = nsWeakPtr(do_GetWeakReference(aWindow))]
+ [p, weakWindow = nsWeakPtr(do_GetWeakReference(aWindow)),
+ listener = mListener, trackID = mTrackID]
(Maybe<nsString>&& aBadConstraint)
{
if (!MediaManager::Exists()) {
return;
}
if (!weakWindow->IsAlive()) {
return;
}
- nsCOMPtr<nsPIDOMWindowInner> window = do_QueryReferent(weakWindow);
if (aBadConstraint.isNothing()) {
- auto error = MakeRefPtr<MediaStreamError>(
- window,
- NS_LITERAL_STRING("InternalError"));
- p->Reject(error);
+ // Unexpected error during reconfig that left the source
+ // stopped. We resolve the promise and end the track.
+ if (listener) {
+ listener->StopTrack(trackID);
+ }
+ p->Resolve(false);
return;
}
+ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryReferent(weakWindow);
auto error = MakeRefPtr<MediaStreamError>(
window,
NS_LITERAL_STRING("OverConstrainedError"),
NS_LITERAL_STRING(""),
aBadConstraint.valueOr(nsString()));
p->Reject(error);
});