зеркало из https://github.com/mozilla/pjs.git
Bug 750258. Ensure that MediaStreamListener::NotifyBlockingChanged is always called for a new listener, and similar for NotifyFinished called on an already-finished stream. Rely on this to set readyState correctly for media elements consuming a stream. r=jesup,cpearce
This commit is contained in:
Родитель
3623f99501
Коммит
640888aaee
|
@ -2645,7 +2645,11 @@ void nsHTMLMediaElement::ResourceLoaded()
|
|||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
||||
AddRemoveSelfReference();
|
||||
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA) {
|
||||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA);
|
||||
// MediaStream sources are put into HAVE_CURRENT_DATA state here on setup. If the
|
||||
// stream is not blocked, we will receive a notification that will put it
|
||||
// into HAVE_ENOUGH_DATA state.
|
||||
ChangeReadyState(mStream ? nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA
|
||||
: nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA);
|
||||
}
|
||||
// Ensure a progress event is dispatched at the end of download.
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("progress"));
|
||||
|
|
|
@ -1761,6 +1761,17 @@ MediaStream::ChangeExplicitBlockerCount(PRInt32 aDelta)
|
|||
GraphImpl()->AppendMessage(new Message(this, aDelta));
|
||||
}
|
||||
|
||||
void
|
||||
MediaStream::AddListenerImpl(already_AddRefed<MediaStreamListener> aListener)
|
||||
{
|
||||
MediaStreamListener* listener = *mListeners.AppendElement() = aListener;
|
||||
listener->NotifyBlockingChanged(GraphImpl(),
|
||||
mBlocked.GetAt(GraphImpl()->mCurrentTime) ? MediaStreamListener::BLOCKED : MediaStreamListener::UNBLOCKED);
|
||||
if (mNotifiedFinished) {
|
||||
listener->NotifyFinished(GraphImpl());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaStream::AddListener(MediaStreamListener* aListener)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,10 @@ class MediaStreamGraph;
|
|||
* reentry into media graph methods is possible, although very much discouraged!
|
||||
* You should do something non-blocking and non-reentrant (e.g. dispatch an
|
||||
* event to some thread) and return.
|
||||
*
|
||||
* When a listener is first attached, we guarantee to send a NotifyBlockingChanged
|
||||
* callback to notify of the initial blocking state. Also, if a listener is
|
||||
* attached to a stream that has already finished, we'll call NotifyFinished.
|
||||
*/
|
||||
class MediaStreamListener {
|
||||
public:
|
||||
|
@ -263,10 +267,7 @@ public:
|
|||
{
|
||||
mExplicitBlockerCount.SetAtAndAfter(aTime, mExplicitBlockerCount.GetAt(aTime) + aDelta);
|
||||
}
|
||||
void AddListenerImpl(already_AddRefed<MediaStreamListener> aListener)
|
||||
{
|
||||
*mListeners.AppendElement() = aListener;
|
||||
}
|
||||
void AddListenerImpl(already_AddRefed<MediaStreamListener> aListener);
|
||||
void RemoveListenerImpl(MediaStreamListener* aListener)
|
||||
{
|
||||
mListeners.RemoveElement(aListener);
|
||||
|
|
Загрузка…
Ссылка в новой задаче