Bug 1326330. Part 2 - add assertions and checks. r=JamesCheng

1. ensure the 'finish' event is notified only once.
2. assert pushing items to a finished queue.

MozReview-Commit-ID: 9lYWPANVz0m

--HG--
extra : rebase_source : c05b0c77fdee324798579e0e2ebec6ce6303cbf6
extra : intermediate-source : 80be35003c76fc9cc74f206576394b46317b7880
extra : source : 14f5d5c064fddbbcf5728fb4d19e9c0a4e45fac7
This commit is contained in:
JW Wang 2016-12-23 19:19:04 +08:00
parent 3985fd7208
commit 4eb1252534

View File

@ -43,6 +43,7 @@ public:
inline void Push(T* aItem) {
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
MOZ_ASSERT(!mEndOfStream);
MOZ_ASSERT(aItem);
NS_ADDREF(aItem);
MOZ_ASSERT(aItem->GetEndTime() >= aItem->mTime);
@ -88,8 +89,10 @@ public:
// Informs the media queue that it won't be receiving any more items.
void Finish() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mEndOfStream = true;
mFinishEvent.Notify();
if (!mEndOfStream) {
mEndOfStream = true;
mFinishEvent.Notify();
}
}
// Returns the approximate number of microseconds of items in the queue.