Backed out 4 changesets (bug 1401471) because it depends on 1401461 which is being backed out

Backed out changeset 6a2c85349226 (bug 1401471)
Backed out changeset 554875cb6a2e (bug 1401471)
Backed out changeset f871c6aa4d90 (bug 1401471)
Backed out changeset ff9dbb6a6692 (bug 1401471)

MozReview-Commit-ID: 80kxfUqbik4
This commit is contained in:
Phil Ringnalda 2017-09-21 20:29:08 -07:00
Родитель 3d183512ad
Коммит 4627ae77ed
2 изменённых файлов: 45 добавлений и 58 удалений

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

@ -462,6 +462,7 @@ MediaCacheStream::MediaCacheStream(ChannelMediaResource* aClient,
, mIsTransportSeekable(false)
, mCacheSuspended(false)
, mChannelEnded(false)
, mChannelOffset(0)
, mStreamLength(-1)
, mStreamOffset(0)
, mPlaybackBytesPerSecond(10000)
@ -1122,25 +1123,13 @@ MediaCache::PredictNextUseForIncomingData(MediaCacheStream* aStream)
std::min<int64_t>(millisecondsAhead, INT32_MAX));
}
enum StreamAction { NONE, SEEK, SEEK_AND_RESUME, RESUME, SUSPEND };
void
MediaCache::Update()
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
struct StreamAction
{
enum
{
NONE,
SEEK,
RESUME,
SUSPEND
} mTag = NONE;
// Members for 'SEEK' only.
bool mResume = false;
int64_t mSeekTarget = -1;
};
// The action to use for each stream. We store these so we can make
// decisions while holding the cache lock but implement those decisions
// without holding the cache lock, since we need to call out to
@ -1261,7 +1250,7 @@ MediaCache::Update()
int32_t readaheadLimit = Preferences::GetInt("media.cache_readahead_limit", 30);
for (uint32_t i = 0; i < mStreams.Length(); ++i) {
actions.AppendElement(StreamAction{});
actions.AppendElement(NONE);
MediaCacheStream* stream = mStreams[i];
if (stream->mClosed) {
@ -1399,17 +1388,15 @@ MediaCache::Update()
// in mPartialBlockBuffer.
stream->mChannelOffset =
OffsetToBlockIndexUnchecked(desiredOffset) * BLOCK_SIZE;
actions[i].mTag = StreamAction::SEEK;
actions[i].mResume = stream->mCacheSuspended;
actions[i].mSeekTarget = stream->mChannelOffset;
actions[i] = stream->mCacheSuspended ? SEEK_AND_RESUME : SEEK;
// mChannelOffset is updated to a new position. We don't want data from
// the old channel to be written to the wrong position. 0 is a sentinel
// value which will not match any ID passed to NotifyDataReceived().
stream->mLoadID = 0;
} else if (enableReading && stream->mCacheSuspended) {
actions[i].mTag = StreamAction::RESUME;
actions[i] = RESUME;
} else if (!enableReading && !stream->mCacheSuspended) {
actions[i].mTag = StreamAction::SUSPEND;
actions[i] = SUSPEND;
}
}
#ifdef DEBUG
@ -1430,47 +1417,47 @@ MediaCache::Update()
// being set correctly for all streams.
for (uint32_t i = 0; i < mStreams.Length(); ++i) {
MediaCacheStream* stream = mStreams[i];
switch (actions[i].mTag) {
case StreamAction::SEEK:
stream->mCacheSuspended = false;
stream->mChannelEnded = false;
break;
case StreamAction::RESUME:
stream->mCacheSuspended = false;
break;
case StreamAction::SUSPEND:
stream->mCacheSuspended = true;
break;
default:
break;
switch (actions[i]) {
case SEEK:
case SEEK_AND_RESUME:
stream->mCacheSuspended = false;
stream->mChannelEnded = false;
break;
case RESUME:
stream->mCacheSuspended = false;
break;
case SUSPEND:
stream->mCacheSuspended = true;
break;
default:
break;
}
}
for (uint32_t i = 0; i < mStreams.Length(); ++i) {
MediaCacheStream* stream = mStreams[i];
nsresult rv;
switch (actions[i].mTag) {
case StreamAction::SEEK:
LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)",
stream,
actions[i].mSeekTarget,
actions[i].mResume);
rv = stream->mClient->CacheClientSeek(actions[i].mSeekTarget,
actions[i].mResume);
break;
case StreamAction::RESUME:
LOG("Stream %p Resumed", stream);
rv = stream->mClient->CacheClientResume();
QueueSuspendedStatusUpdate(stream->mResourceID);
break;
case StreamAction::SUSPEND:
LOG("Stream %p Suspended", stream);
rv = stream->mClient->CacheClientSuspend();
QueueSuspendedStatusUpdate(stream->mResourceID);
break;
default:
rv = NS_OK;
break;
switch (actions[i]) {
case SEEK:
case SEEK_AND_RESUME:
LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)", stream,
stream->mChannelOffset, actions[i] == SEEK_AND_RESUME);
rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
actions[i] == SEEK_AND_RESUME);
break;
case RESUME:
LOG("Stream %p Resumed", stream);
rv = stream->mClient->CacheClientResume();
QueueSuspendedStatusUpdate(stream->mResourceID);
break;
case SUSPEND:
LOG("Stream %p Suspended", stream);
rv = stream->mClient->CacheClientSuspend();
QueueSuspendedStatusUpdate(stream->mResourceID);
break;
default:
rv = NS_OK;
break;
}
if (NS_FAILED(rv)) {
@ -2205,7 +2192,7 @@ MediaCacheStream::GetLength()
int64_t
MediaCacheStream::GetOffset() const
{
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
MOZ_ASSERT(NS_IsMainThread());
return mChannelOffset;
}

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

@ -460,6 +460,8 @@ private:
bool mCacheSuspended;
// True if the channel ended and we haven't seeked it again.
bool mChannelEnded;
// The offset where the next data from the channel will arrive
int64_t mChannelOffset;
// The reported or discovered length of the data, or -1 if nothing is
// known
int64_t mStreamLength;
@ -467,8 +469,6 @@ private:
// The following fields are protected by the cache's monitor can can be written
// by any thread.
// The offset where the next data from the channel will arrive
int64_t mChannelOffset = 0;
// The offset where the reader is positioned in the stream
int64_t mStreamOffset;
// For each block in the stream data, maps to the cache entry for the