Bug 1388288 - Make Flac and Ogg decoders build in non-Unified mode. r=jya
FLAC_MAX_CHANNELS is used in FlacDemuxer and in FrameParser, so move it,
and all the other FLAC_{MIN,MAX}* #defines to FrameParser.h. The other
defines don't technically need to be there, but it's nicer to have them
all defined together.
MozReview-Commit-ID: LVZzXvBSvMq
--- a/dom/media/flac/FlacDemuxer.cpp
+++ b/dom/media/flac/FlacDemuxer.cpp
@@ -23,24 +23,16 @@ extern mozilla::LazyLogModule gMediaDemu
using namespace mozilla::media;
namespace mozilla {
namespace flac {
// flac::FrameHeader - Holds the flac frame header and its parsing
// state.
-#define FLAC_MAX_CHANNELS 8
-#define FLAC_MIN_BLOCKSIZE 16
-#define FLAC_MAX_BLOCKSIZE 65535
-#define FLAC_MIN_FRAME_SIZE 11
-#define FLAC_MAX_FRAME_HEADER_SIZE 16
-#define FLAC_MAX_FRAME_SIZE (FLAC_MAX_FRAME_HEADER_SIZE \
- +FLAC_MAX_BLOCKSIZE*FLAC_MAX_CHANNELS*3)
-
class FrameHeader
{
public:
const AudioInfo& Info() const { return mInfo; }
uint32_t Size() const { return mSize; }
bool IsValid() const { return mValid; }
--- a/dom/media/flac/FlacFrameParser.h
+++ b/dom/media/flac/FlacFrameParser.h
@@ -11,16 +11,24 @@
#include "nsAutoPtr.h"
#include "MediaDecoder.h" // For MetadataTags
#include "MediaInfo.h"
#include "MediaResource.h"
namespace mozilla
{
+#define FLAC_MAX_CHANNELS 8
+#define FLAC_MIN_BLOCKSIZE 16
+#define FLAC_MAX_BLOCKSIZE 65535
+#define FLAC_MIN_FRAME_SIZE 11
+#define FLAC_MAX_FRAME_HEADER_SIZE 16
+#define FLAC_MAX_FRAME_SIZE (FLAC_MAX_FRAME_HEADER_SIZE \
+ +FLAC_MAX_BLOCKSIZE*FLAC_MAX_CHANNELS*3)
+
class OpusParser;
// Decode a Flac Metadata block contained in either a ogg packet
// (https://xiph.org/flac/ogg_mapping.html) or in flac container
// (https://xiph.org/flac/format.html#frame_header)
class FlacFrameParser
{
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -670,18 +670,17 @@ OggDemuxer::ReadOggChain(const media::Ti
if ((newVorbisState &&
ReadHeaders(TrackInfo::kAudioTrack, newVorbisState)) &&
(mVorbisState->GetInfo()->GetAsAudioInfo()->mRate ==
newVorbisState->GetInfo()->GetAsAudioInfo()->mRate) &&
(mVorbisState->GetInfo()->GetAsAudioInfo()->mChannels ==
newVorbisState->GetInfo()->GetAsAudioInfo()->mChannels)) {
SetupTarget(&mVorbisState, newVorbisState);
- LOG(LogLevel::Debug,
- ("New vorbis ogg link, serial=%d\n", mVorbisState->mSerial));
+ OGG_DEBUG("New vorbis ogg link, serial=%d\n", mVorbisState->mSerial);
if (msgInfo) {
InitTrack(msgInfo, &mInfo.mAudio, true);
}
chained = true;
tags = newVorbisState->GetTags();
}
@@ -706,18 +705,17 @@ OggDemuxer::ReadOggChain(const media::Ti
if ((newFlacState &&
ReadHeaders(TrackInfo::kAudioTrack, newFlacState)) &&
(mFlacState->GetInfo()->GetAsAudioInfo()->mRate ==
newFlacState->GetInfo()->GetAsAudioInfo()->mRate) &&
(mFlacState->GetInfo()->GetAsAudioInfo()->mChannels ==
newFlacState->GetInfo()->GetAsAudioInfo()->mChannels)) {
SetupTarget(&mFlacState, newFlacState);
- LOG(LogLevel::Debug,
- ("New flac ogg link, serial=%d\n", mFlacState->mSerial));
+ OGG_DEBUG("New flac ogg link, serial=%d\n", mFlacState->mSerial);
if (msgInfo) {
InitTrack(msgInfo, &mInfo.mAudio, true);
}
chained = true;
tags = newFlacState->GetTags();
}
@@ -1173,18 +1171,18 @@ OggDemuxer::SeekToKeyframeUsingIndex(Tra
int64_t tell = Resource(aType)->Tell();
// Seek to the keypoint returned by the index.
if (keyframe.mKeyPoint.mOffset > Resource(aType)->GetLength() ||
keyframe.mKeyPoint.mOffset < 0) {
// Index must be invalid.
return RollbackIndexedSeek(aType, tell);
}
- LOG(LogLevel::Debug, ("Seeking using index to keyframe at offset %" PRId64 "\n",
- keyframe.mKeyPoint.mOffset));
+ OGG_DEBUG("Seeking using index to keyframe at offset %" PRId64 "\n",
+ keyframe.mKeyPoint.mOffset);
nsresult res = Resource(aType)->Seek(nsISeekableStream::NS_SEEK_SET,
keyframe.mKeyPoint.mOffset);
NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
// We've moved the read set, so reset decode.
res = Reset(aType);
NS_ENSURE_SUCCESS(res, SEEK_FATAL_ERROR);
@@ -1196,18 +1194,18 @@ OggDemuxer::SeekToKeyframeUsingIndex(Tra
OggSyncState(aType),
false,
keyframe.mKeyPoint.mOffset,
Resource(aType)->GetLength(),
&page,
skippedBytes);
NS_ENSURE_TRUE(syncres != PAGE_SYNC_ERROR, SEEK_FATAL_ERROR);
if (syncres != PAGE_SYNC_OK || skippedBytes != 0) {
- LOG(LogLevel::Debug, ("Indexed-seek failure: Ogg Skeleton Index is invalid "
- "or sync error after seek"));
+ OGG_DEBUG("Indexed-seek failure: Ogg Skeleton Index is invalid "
+ "or sync error after seek");
return RollbackIndexedSeek(aType, tell);
}
uint32_t serial = ogg_page_serialno(&page);
if (serial != keyframe.mSerial) {
// Serialno of page at offset isn't what the index told us to expect.
// Assume the index is invalid.
return RollbackIndexedSeek(aType, tell);
}