Backed out changeset 5ff88bfd0718 (
bug 1060179) for suspicion of causing B2G ICS Emulator opt M4 Test failures
--- a/content/media/FileBlockCache.cpp
+++ b/content/media/FileBlockCache.cpp
@@ -137,22 +137,22 @@ nsresult FileBlockCache::ReadFromFile(in
uint8_t* aDest,
int32_t aBytesToRead,
int32_t& aBytesRead)
{
mFileMonitor.AssertCurrentThreadOwns();
nsresult res = Seek(aOffset);
if (NS_FAILED(res)) return res;
-
+
aBytesRead = PR_Read(mFD, aDest, aBytesToRead);
if (aBytesRead <= 0)
return NS_ERROR_FAILURE;
mFDCurrentPos += aBytesRead;
-
+
return NS_OK;
}
nsresult FileBlockCache::WriteBlockToFile(int32_t aBlockIndex,
const uint8_t* aBlockData)
{
mFileMonitor.AssertCurrentThreadOwns();
@@ -322,17 +322,17 @@ nsresult FileBlockCache::MoveBlock(int32
// Only add another entry to the change index list if we don't already
// have one for this block. We won't have an entry when either there's
// no pending change for this block, or if there is a pending change for
// this block and we're in the process of writing it (we've popped the
// block's index out of mChangeIndexList in Run() but not finished writing
// the block to file yet.
mChangeIndexList.PushBack(aDestBlockIndex);
}
-
+
// If the source block hasn't yet been written to file then the dest block
// simply contains that same write. Resolve this as a write instead.
if (sourceBlock && sourceBlock->IsWrite()) {
mBlockChanges[aDestBlockIndex] = new BlockChange(sourceBlock->mData.get());
} else {
mBlockChanges[aDestBlockIndex] = new BlockChange(sourceIndex);
}
--- a/content/media/FileBlockCache.h
+++ b/content/media/FileBlockCache.h
@@ -16,17 +16,17 @@
struct PRFileDesc;
namespace mozilla {
// Manages file I/O for the media cache. Data comes in over the network
// via callbacks on the main thread, however we don't want to write the
// incoming data to the media cache on the main thread, as this could block
-// causing UI jank.
+// causing UI jank.
//
// So FileBlockCache provides an abstraction for a temporary file accessible
// as an array of blocks, which supports a block move operation, and
// allows synchronous reading and writing from any thread, with writes being
// buffered so as not to block.
//
// Writes and cache block moves (which require reading) are deferred to
// their own non-main thread. This object also ensures that data which has
--- a/content/media/MediaCache.h
+++ b/content/media/MediaCache.h
@@ -26,17 +26,17 @@ class ReentrantMonitorAutoEnter;
* for pausing, seeking, etc. But we are primarily interested
* in transporting media data using HTTP over the Internet, which has
* high latency to open a connection, requires a new connection for every
* seek, may not even support seeking on some connections (especially
* live streams), and uses a push model --- data comes from the server
* and you don't have much control over the rate. Also, transferring data
* over the Internet can be slow and/or unpredictable, so we want to read
* ahead to buffer and cache as much data as possible.
- *
+ *
* The job of the media cache is to resolve this impedance mismatch.
* The media cache reads data from Necko channels into file-backed storage,
* and offers a random-access file-like API to the stream data
* (MediaCacheStream). Along the way it solves several problems:
* -- The cache intelligently reads ahead to prefetch data that may be
* needed in the future
* -- The size of the cache is bounded so that we don't fill up
* storage with read-ahead data
@@ -51,35 +51,35 @@ class ReentrantMonitorAutoEnter;
* (seeking to EOF and then seeking back to the previous offset does not
* trigger any Necko activity)
* -- The cache also handles the case where the server does not support
* seeking
* -- Necko can only send data to the main thread, but MediaCacheStream
* can distribute data to any thread
* -- The cache exposes APIs so clients can detect what data is
* currently held
- *
+ *
* Note that although HTTP is the most important transport and we only
* support transport-level seeking via HTTP byte-ranges, the media cache
* works with any kind of Necko channels and provides random access to
* cached data even for, e.g., FTP streams.
- *
+ *
* The media cache is not persistent. It does not currently allow
* data from one load to be used by other loads, either within the same
* browser session or across browser sessions. The media cache file
* is marked "delete on close" so it will automatically disappear in the
* event of a browser crash or shutdown.
- *
+ *
* The media cache is block-based. Streams are divided into blocks of a
* fixed size (currently 4K) and we cache blocks. A single cache contains
* blocks for all streams.
- *
+ *
* The cache size is controlled by the media.cache_size preference
* (which is in KB). The default size is 500MB.
- *
+ *
* The replacement policy predicts a "time of next use" for each block
* in the cache. When we need to free a block, the block with the latest
* "time of next use" will be evicted. Blocks are divided into
* different classes, each class having its own predictor:
* FREE_BLOCK: these blocks are effectively infinitely far in the future;
* a free block will always be chosen for replacement before other classes
* of blocks.
* METADATA_BLOCK: these are blocks that contain data that has been read
@@ -103,87 +103,87 @@ class ReentrantMonitorAutoEnter;
* read point by the decoder's estimate of its playback rate in bytes
* per second. This ensures that the blocks farthest ahead are considered
* least valuable.
* For efficient prediction of the "latest time of next use", we maintain
* linked lists of blocks in each class, ordering blocks by time of
* next use. READAHEAD_BLOCKS have one linked list per stream, since their
* time of next use depends on stream parameters, but the other lists
* are global.
- *
+ *
* A block containing a current decoder read point can contain data
* both behind and ahead of the read point. It will be classified as a
* PLAYED_BLOCK but we will give it special treatment so it is never
* evicted --- it actually contains the highest-priority readahead data
* as well as played data.
- *
+ *
* "Time of next use" estimates are also used for flow control. When
* reading ahead we can predict the time of next use for the data that
* will be read. If the predicted time of next use is later then the
* prediction for all currently cached blocks, and the cache is full, then
* we should suspend reading from the Necko channel.
- *
+ *
* Unfortunately suspending the Necko channel can't immediately stop the
* flow of data from the server. First our desire to suspend has to be
* transmitted to the server (in practice, Necko stops reading from the
* socket, which causes the kernel to shrink its advertised TCP receive
* window size to zero). Then the server can stop sending the data, but
* we will receive data roughly corresponding to the product of the link
* bandwidth multiplied by the round-trip latency. We deal with this by
* letting the cache overflow temporarily and then trimming it back by
* moving overflowing blocks back into the body of the cache, replacing
* less valuable blocks as they become available. We try to avoid simply
* discarding overflowing readahead data.
- *
+ *
* All changes to the actual contents of the cache happen on the main
* thread, since that's where Necko's notifications happen.
*
* The media cache maintains at most one Necko channel for each stream.
* (In the future it might be advantageous to relax this, e.g. so that a
* seek to near the end of the file can happen without disturbing
* the loading of data from the beginning of the file.) The Necko channel
* is managed through ChannelMediaResource; MediaCache does not
* depend on Necko directly.
- *
+ *
* Every time something changes that might affect whether we want to
* read from a Necko channel, or whether we want to seek on the Necko
* channel --- such as data arriving or data being consumed by the
* decoder --- we asynchronously trigger MediaCache::Update on the main
* thread. That method implements most cache policy. It evaluates for
* each stream whether we want to suspend or resume the stream and what
* offset we should seek to, if any. It is also responsible for trimming
* back the cache size to its desired limit by moving overflowing blocks
* into the main part of the cache.
- *
+ *
* Streams can be opened in non-seekable mode. In non-seekable mode,
* the cache will only call ChannelMediaResource::CacheClientSeek with
* a 0 offset. The cache tries hard not to discard readahead data
* for non-seekable streams, since that could trigger a potentially
* disastrous re-read of the entire stream. It's up to cache clients
* to try to avoid requesting seeks on such streams.
- *
+ *
* MediaCache has a single internal monitor for all synchronization.
* This is treated as the lowest level monitor in the media code. So,
* we must not acquire any MediaDecoder locks or MediaResource locks
* while holding the MediaCache lock. But it's OK to hold those locks
* and then get the MediaCache lock.
- *
+ *
* MediaCache associates a principal with each stream. CacheClientSeek
* can trigger new HTTP requests; due to redirects to other domains,
* each HTTP load can return data with a different principal. This
* principal must be passed to NotifyDataReceived, and MediaCache
* will detect when different principals are associated with data in the
* same stream, and replace them with a null principal.
*/
class MediaCache;
/**
* If the cache fails to initialize then Init will fail, so nonstatic
* methods of this class can assume gMediaCache is non-null.
- *
+ *
* This class can be directly embedded as a value.
*/
class MediaCacheStream {
public:
enum {
// This needs to be a power of two
BLOCK_SIZE = 32768
};
@@ -352,17 +352,17 @@ public:
private:
friend class MediaCache;
/**
* A doubly-linked list of blocks. Add/Remove/Get methods are all
* constant time. We declare this here so that a stream can contain a
* BlockList of its read-ahead blocks. Blocks are referred to by index
* into the MediaCache::mIndex array.
- *
+ *
* Blocks can belong to more than one list at the same time, because
* the next/prev pointers are not stored in the block.
*/
class BlockList {
public:
BlockList() : mFirstBlock(-1), mCount(0) {}
~BlockList() {
NS_ASSERTION(mFirstBlock == -1 && mCount == 0,
--- a/content/media/android/AndroidMediaReader.cpp
+++ b/content/media/android/AndroidMediaReader.cpp
@@ -237,17 +237,17 @@ bool AndroidMediaReader::DecodeVideoFram
pos,
frame.mTimeUs,
1, // We don't know the duration yet.
b,
frame.mKeyFrame,
-1,
picture);
}
-
+
if (!v) {
return false;
}
parsed++;
decoded++;
NS_ASSERTION(decoded <= parsed, "Expect to decode fewer frames than parsed in AndroidMedia...");
// Since MPAPI doesn't give us the end time of frames, we keep one frame
--- a/content/media/gmp/PGMPStorage.ipdl
+++ b/content/media/gmp/PGMPStorage.ipdl
@@ -1,34 +1,34 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PGMP;
-include GMPTypes;
-
-using GMPErr from "gmp-errors.h";
-
-namespace mozilla {
-namespace gmp {
-
-async protocol PGMPStorage
-{
- manager PGMP;
-
-child:
- OpenComplete(nsCString aRecordName, GMPErr aStatus);
- ReadComplete(nsCString aRecordName, GMPErr aStatus, uint8_t[] aBytes);
- WriteComplete(nsCString aRecordName, GMPErr aStatus);
- Shutdown();
-
-parent:
- Open(nsCString aRecordName);
- Read(nsCString aRecordName);
- Write(nsCString aRecordName, uint8_t[] aBytes);
- Close(nsCString aRecordName);
- __delete__();
-
-};
-
-} // namespace gmp
-} // namespace mozilla
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+include protocol PGMP;
+include GMPTypes;
+
+using GMPErr from "gmp-errors.h";
+
+namespace mozilla {
+namespace gmp {
+
+async protocol PGMPStorage
+{
+ manager PGMP;
+
+child:
+ OpenComplete(nsCString aRecordName, GMPErr aStatus);
+ ReadComplete(nsCString aRecordName, GMPErr aStatus, uint8_t[] aBytes);
+ WriteComplete(nsCString aRecordName, GMPErr aStatus);
+ Shutdown();
+
+parent:
+ Open(nsCString aRecordName);
+ Read(nsCString aRecordName);
+ Write(nsCString aRecordName, uint8_t[] aBytes);
+ Close(nsCString aRecordName);
+ __delete__();
+
+};
+
+} // namespace gmp
+} // namespace mozilla
--- a/content/media/ogg/OggCodecState.cpp
+++ b/content/media/ogg/OggCodecState.cpp
@@ -292,17 +292,17 @@ bool
TheoraState::DecodeHeader(ogg_packet* aPacket)
{
nsAutoRef<ogg_packet> autoRelease(aPacket);
mPacketCount++;
int ret = th_decode_headerin(&mInfo,
&mComment,
&mSetup,
aPacket);
-
+
// We must determine when we've read the last header packet.
// th_decode_headerin() does not tell us when it's read the last header, so
// we must keep track of the headers externally.
//
// There are 3 header packets, the Identification, Comment, and Setup
// headers, which must be in that order. If they're out of order, the file
// is invalid. If we've successfully read a header, and it's the setup
// header, then we're done reading headers. The first byte of each packet
@@ -345,17 +345,17 @@ TheoraState::IsHeader(ogg_packet* aPacke
int64_t TheoraState::Time(th_info* aInfo, int64_t aGranulepos)
{
if (aGranulepos < 0 || aInfo->fps_numerator == 0) {
return -1;
}
// Implementation of th_granule_frame inlined here to operate
// on the th_info structure instead of the theora_state.
- int shift = aInfo->keyframe_granule_shift;
+ int shift = aInfo->keyframe_granule_shift;
ogg_int64_t iframe = aGranulepos >> shift;
ogg_int64_t pframe = aGranulepos - (iframe << shift);
int64_t frameno = iframe + pframe - TH_VERSION_CHECK(aInfo, 3, 2, 1);
CheckedInt64 t = ((CheckedInt64(frameno) + 1) * USECS_PER_S) * aInfo->fps_denominator;
if (!t.isValid())
return -1;
t /= aInfo->fps_numerator;
return t.isValid() ? t.value() : -1;
@@ -375,17 +375,17 @@ int64_t
TheoraState::MaxKeyframeOffset()
{
// Determine the maximum time in microseconds by which a key frame could
// offset for the theora bitstream. Theora granulepos encode time as:
// ((key_frame_number << granule_shift) + frame_offset).
// Therefore the maximum possible time by which any frame could be offset
// from a keyframe is the duration of (1 << granule_shift) - 1) frames.
int64_t frameDuration;
-
+
// Max number of frames keyframe could possibly be offset.
int64_t keyframeDiff = (1 << mInfo.keyframe_granule_shift) - 1;
// Length of frame in usecs.
frameDuration = (mInfo.fps_denominator * USECS_PER_S) / mInfo.fps_numerator;
// Total time in usecs keyframe can be offset from any given frame.
return frameDuration * keyframeDiff;
@@ -487,17 +487,17 @@ void TheoraState::ReconstructTheoraGranu
// granulepos, so we take "keyframe" to be the max possible offset
// frame instead.
ogg_int64_t k = std::max(frame - (((ogg_int64_t)1 << shift) - 1), version_3_2_1);
granulepos = (k << shift) + (frame - k);
}
// Theora 3.2.1+ granulepos store frame number [1..N], so granulepos
// should be > 0.
// Theora 3.2.0 granulepos store the frame index [0..(N-1)], so
- // granulepos should be >= 0.
+ // granulepos should be >= 0.
NS_ASSERTION(granulepos >= version_3_2_1,
"Invalid granulepos for Theora version");
// Check that the frame's granule number is one more than the
// previous frame's.
NS_ASSERTION(i == 0 ||
th_granule_frame(mCtx, granulepos) ==
th_granule_frame(mCtx, mUnstamped[i-1]->granulepos) + 1,
@@ -719,17 +719,17 @@ nsresult VorbisState::ReconstructVorbisG
if (packet->granulepos == -1) {
packet->granulepos = mGranulepos + samples;
}
// Account for a partial last frame
if (packet->e_o_s && packet->granulepos >= mGranulepos) {
samples = packet->granulepos - mGranulepos;
}
-
+
mGranulepos = packet->granulepos;
RecordVorbisPacketSamples(packet, samples);
return NS_OK;
}
bool unknownGranulepos = last->granulepos == -1;
int totalSamples = 0;
for (int32_t i = mUnstamped.Length() - 1; i > 0; i--) {
@@ -1083,17 +1083,17 @@ bool OpusState::ReconstructOpusGranulepo
SkeletonState::SkeletonState(ogg_page* aBosPage) :
OggCodecState(aBosPage, true),
mVersion(0),
mPresentationTime(0),
mLength(0)
{
MOZ_COUNT_CTOR(SkeletonState);
}
-
+
SkeletonState::~SkeletonState()
{
MOZ_COUNT_DTOR(SkeletonState);
}
// Support for Ogg Skeleton 4.0, as per specification at:
// http://wiki.xiph.org/Ogg_Skeleton_4
@@ -1218,38 +1218,38 @@ bool SkeletonState::DecodeIndex(ogg_pack
// Check the numKeyPoints value read, ensure we're not going to run out of
// memory while trying to decode the index packet.
CheckedInt64 minPacketSize = (CheckedInt64(numKeyPoints) * MIN_KEY_POINT_SIZE) + INDEX_KEYPOINT_OFFSET;
if (!minPacketSize.isValid())
{
return (mActive = false);
}
-
+
int64_t sizeofIndex = aPacket->bytes - INDEX_KEYPOINT_OFFSET;
int64_t maxNumKeyPoints = sizeofIndex / MIN_KEY_POINT_SIZE;
if (aPacket->bytes < minPacketSize.value() ||
- numKeyPoints > maxNumKeyPoints ||
+ numKeyPoints > maxNumKeyPoints ||
numKeyPoints < 0)
{
// Packet size is less than the theoretical minimum size, or the packet is
// claiming to store more keypoints than it's capable of storing. This means
// that the numKeyPoints field is too large or small for the packet to
// possibly contain as many packets as it claims to, so the numKeyPoints
// field is possibly malicious. Don't try decoding this index, we may run
// out of memory.
LOG(PR_LOG_DEBUG, ("Possibly malicious number of key points reported "
"(%lld) in index packet for stream %u.",
numKeyPoints,
serialno));
return (mActive = false);
}
nsAutoPtr<nsKeyFrameIndex> keyPoints(new nsKeyFrameIndex(startTime, endTime));
-
+
p = aPacket->packet + INDEX_KEYPOINT_OFFSET;
const unsigned char* limit = aPacket->packet + aPacket->bytes;
int64_t numKeyPointsRead = 0;
CheckedInt64 offset = 0;
CheckedInt64 time = 0;
while (p < limit &&
numKeyPointsRead < numKeyPoints)
{
--- a/content/media/raw/RawReader.cpp
+++ b/content/media/raw/RawReader.cpp
@@ -60,17 +60,17 @@ nsresult RawReader::ReadMetadata(MediaIn
static_cast<uint32_t>(mMetadata.frameHeight);
NS_ENSURE_TRUE(dummy.isValid(), NS_ERROR_FAILURE);
if (mMetadata.aspectDenominator == 0 ||
mMetadata.framerateDenominator == 0)
return NS_ERROR_FAILURE; // Invalid data
// Determine and verify frame display size.
- float pixelAspectRatio = static_cast<float>(mMetadata.aspectNumerator) /
+ float pixelAspectRatio = static_cast<float>(mMetadata.aspectNumerator) /
mMetadata.aspectDenominator;
nsIntSize display(mMetadata.frameWidth, mMetadata.frameHeight);
ScaleDisplayByAspectRatio(display, pixelAspectRatio);
mPicture = nsIntRect(0, 0, mMetadata.frameWidth, mMetadata.frameHeight);
nsIntSize frameSize(mMetadata.frameWidth, mMetadata.frameHeight);
if (!IsValidVideoRegion(frameSize, mPicture, display)) {
// Video track's frame sizes will overflow. Fail.
return NS_ERROR_FAILURE;
@@ -121,17 +121,17 @@ RawReader::IsMediaSeekable()
bool RawReader::DecodeAudioData()
{
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine thread or decode thread.");
return false;
}
-// Helper method that either reads until it gets aLength bytes
+// Helper method that either reads until it gets aLength bytes
// or returns false
bool RawReader::ReadFromResource(MediaResource *aResource, uint8_t* aBuf,
uint32_t aLength)
{
while (aLength > 0) {
uint32_t bytesRead = 0;
nsresult rv;
--- a/content/media/wave/WaveReader.cpp
+++ b/content/media/wave/WaveReader.cpp
@@ -260,17 +260,17 @@ bool WaveReader::DecodeVideoFrame(bool &
nsresult WaveReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime)
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
LOG(PR_LOG_DEBUG, ("%p About to seek to %lld", mDecoder, aTarget));
if (NS_FAILED(ResetDecode())) {
return NS_ERROR_FAILURE;
}
double d = BytesToTime(GetDataLength());
- NS_ASSERTION(d < INT64_MAX / USECS_PER_S, "Duration overflow");
+ NS_ASSERTION(d < INT64_MAX / USECS_PER_S, "Duration overflow");
int64_t duration = static_cast<int64_t>(d * USECS_PER_S);
double seekTime = std::min(aTarget, duration) / static_cast<double>(USECS_PER_S);
int64_t position = RoundDownToFrame(static_cast<int64_t>(TimeToBytes(seekTime)));
NS_ASSERTION(INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
position += mWavePCMOffset;
return mDecoder->GetResource()->Seek(nsISeekableStream::NS_SEEK_SET, position);
}
@@ -286,17 +286,17 @@ nsresult WaveReader::GetBuffered(dom::Ti
int64_t startOffset = mDecoder->GetResource()->GetNextCachedData(mWavePCMOffset);
while (startOffset >= 0) {
int64_t endOffset = mDecoder->GetResource()->GetCachedDataEnd(startOffset);
// Bytes [startOffset..endOffset] are cached.
NS_ASSERTION(startOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
NS_ASSERTION(endOffset >= mWavePCMOffset, "Integer underflow in GetBuffered");
// We need to round the buffered ranges' times to microseconds so that they
- // have the same precision as the currentTime and duration attribute on
+ // have the same precision as the currentTime and duration attribute on
// the media element.
aBuffered->Add(RoundToUsecs(BytesToTime(startOffset - mWavePCMOffset)),
RoundToUsecs(BytesToTime(endOffset - mWavePCMOffset)));
startOffset = mDecoder->GetResource()->GetNextCachedData(endOffset);
}
return NS_OK;
}
--- a/content/media/webm/WebMReader.h
+++ b/content/media/webm/WebMReader.h
@@ -66,39 +66,39 @@ class PacketQueueDeallocator : public ns
// Typesafe queue for holding nestegg packets. It has
// ownership of the items in the queue and will free them
// when destroyed.
class WebMPacketQueue : private nsDeque {
public:
WebMPacketQueue()
: nsDeque(new PacketQueueDeallocator())
{}
-
+
~WebMPacketQueue() {
Reset();
}
- inline int32_t GetSize() {
+ inline int32_t GetSize() {
return nsDeque::GetSize();
}
-
+
inline void Push(NesteggPacketHolder* aItem) {
NS_ASSERTION(aItem, "NULL pushed to WebMPacketQueue");
nsDeque::Push(aItem);
}
-
+
inline void PushFront(NesteggPacketHolder* aItem) {
NS_ASSERTION(aItem, "NULL pushed to WebMPacketQueue");
nsDeque::PushFront(aItem);
}
inline NesteggPacketHolder* PopFront() {
return static_cast<NesteggPacketHolder*>(nsDeque::PopFront());
}
-
+
void Reset() {
while (GetSize() > 0) {
delete PopFront();
}
}
};
class WebMReader : public MediaDecoderReader
@@ -111,17 +111,17 @@ protected:
public:
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual nsresult ResetDecode();
virtual bool DecodeAudioData();
// If the Theora granulepos has not been captured, it may read several packets
// until one with a granulepos has been captured, to ensure that all packets
- // read have valid time info.
+ // read have valid time info.
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
int64_t aTimeThreshold);
virtual bool HasAudio()
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
return mHasAudio;
}