Bug 1457661 - P2. Ensure we call NotifyDataEnded for local resource once size is known. r=bryce

A call to NotifyDataEnded is required even if the size was known when the resource was created. This ensures that the readyState is properly updated and that playback can immediately as no more data can be added once first loaded.

MozReview-Commit-ID: FaJMBxJ9NkM

--HG--
extra : rebase_source : 448087a22635dac2aa31611c2b58a8e9c77121ec
This commit is contained in:
Jean-Yves Avenard 2018-05-28 23:06:38 +02:00
Родитель cb6ce94cf2
Коммит 34c40846b5
2 изменённых файлов: 15 добавлений и 6 удалений

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

@ -19,21 +19,27 @@ FileMediaResource::EnsureSizeInitialized()
{ {
mLock.AssertCurrentThreadOwns(); mLock.AssertCurrentThreadOwns();
NS_ASSERTION(mInput, "Must have file input stream"); NS_ASSERTION(mInput, "Must have file input stream");
if (mSizeInitialized) { if (mSizeInitialized && mNotifyDataEndedProcessed) {
return; return;
} }
if (!mSizeInitialized) {
// Get the file size and inform the decoder.
uint64_t size;
nsresult res = mInput->Available(&size);
if (NS_SUCCEEDED(res) && size <= INT64_MAX) {
mSize = (int64_t)size;
}
}
mSizeInitialized = true; mSizeInitialized = true;
// Get the file size and inform the decoder. if (!mNotifyDataEndedProcessed && mSize >= 0) {
uint64_t size;
nsresult res = mInput->Available(&size);
if (NS_SUCCEEDED(res) && size <= INT64_MAX) {
mSize = (int64_t)size;
mCallback->AbstractMainThread()->Dispatch( mCallback->AbstractMainThread()->Dispatch(
NewRunnableMethod<nsresult>("MediaResourceCallback::NotifyDataEnded", NewRunnableMethod<nsresult>("MediaResourceCallback::NotifyDataEnded",
mCallback.get(), mCallback.get(),
&MediaResourceCallback::NotifyDataEnded, &MediaResourceCallback::NotifyDataEnded,
NS_OK)); NS_OK));
} }
mNotifyDataEndedProcessed = true;
} }
nsresult nsresult

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

@ -133,6 +133,9 @@ private:
// when mSizeInitialized is true if we tried and failed to get the size // when mSizeInitialized is true if we tried and failed to get the size
// of the file. // of the file.
bool mSizeInitialized; bool mSizeInitialized;
// Set to true if NotifyDataEnded callback has been processed (which only
// occurs if resource size is known)
bool mNotifyDataEndedProcessed = false;
}; };
} // namespace mozilla } // namespace mozilla