Bug 1205825 - part 1 - don't reacquire the media cache's monitor in MediaCacheStream::FlushPartialBlockInternal; r=roc

FlushPartialBlockInternal is only ever called by methods that are
already holding the MediaCache's monitor.  So we don't need to reacquire
it every time we call this method.

fixup p1
This commit is contained in:
Nathan Froyd 2015-09-17 23:57:51 -04:00
Родитель a7bc045c29
Коммит eb62b6c5a5
2 изменённых файлов: 6 добавлений и 7 удалений

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

@ -1834,12 +1834,11 @@ MediaCacheStream::NotifyDataReceived(int64_t aSize, const char* aData,
}
void
MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll)
MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll,
ReentrantMonitorAutoEnter& aReentrantMonitor)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
int32_t blockOffset = int32_t(mChannelOffset%BLOCK_SIZE);
if (blockOffset > 0) {
CACHE_LOG(LogLevel::Debug,
@ -1861,7 +1860,7 @@ MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll)
// that will never come.
if ((blockOffset > 0 || mChannelOffset == 0) && aNotifyAll) {
// Wake up readers who may be waiting for this data
mon.NotifyAll();
aReentrantMonitor.NotifyAll();
}
}
@ -1876,7 +1875,7 @@ MediaCacheStream::FlushPartialBlock()
// Note: This writes a full block, so if data is not at the end of the
// stream, the decoder must subsequently choose correct start and end offsets
// for reading/seeking.
FlushPartialBlockInternal(false);
FlushPartialBlockInternal(false, mon);
gMediaCache->QueueUpdate();
}
@ -1897,7 +1896,7 @@ MediaCacheStream::NotifyDataEnded(nsresult aStatus)
// It is prudent to update channel/cache status before calling
// CacheClientNotifyDataEnded() which will read |mChannelEnded|.
FlushPartialBlockInternal(true);
FlushPartialBlockInternal(true, mon);
mChannelEnded = true;
gMediaCache->QueueUpdate();

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

@ -425,7 +425,7 @@ private:
// Used by |NotifyDataEnded| and |FlushPartialBlock|.
// If |aNotifyAll| is true, this function will wake up readers who may be
// waiting on the media cache monitor. Called on the main thread only.
void FlushPartialBlockInternal(bool aNotify);
void FlushPartialBlockInternal(bool aNotify, ReentrantMonitorAutoEnter& aReentrantMonitor);
// A helper function to do the work of closing the stream. Assumes
// that the cache monitor is held. Main thread only.
// aReentrantMonitor is the nsAutoReentrantMonitor wrapper holding the cache monitor.