Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1113271 - Fix stagefright FLACParser #20

Merged
merged 1 commit into from
Dec 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions media/libstagefright/FLACExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class FLACParser : public RefBase {
bool mWriteRequested;
bool mWriteCompleted;
FLAC__FrameHeader mWriteHeader;
const FLAC__int32 * const *mWriteBuffer;
const FLAC__int32 * mWriteBuffer[FLAC__MAX_CHANNELS];

// most recent error reported by libFLAC parser
FLAC__StreamDecoderErrorStatus mErrorStatus;
Expand Down Expand Up @@ -323,7 +323,9 @@ FLAC__StreamDecoderWriteStatus FLACParser::writeCallback(
mWriteRequested = false;
// FLAC parser doesn't free or realloc buffer until next frame or finish
mWriteHeader = frame->header;
mWriteBuffer = buffer;
for(unsigned channel = 0; channel < frame->header.channels; channel++) {
mWriteBuffer[channel] = buffer[channel];
}
mWriteCompleted = true;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
} else {
Expand Down Expand Up @@ -478,7 +480,6 @@ FLACParser::FLACParser(
mStreamInfoValid(false),
mWriteRequested(false),
mWriteCompleted(false),
mWriteBuffer(NULL),
mErrorStatus((FLAC__StreamDecoderErrorStatus) -1)
{
ALOGV("FLACParser::FLACParser");
Expand Down Expand Up @@ -667,7 +668,7 @@ MediaBuffer *FLACParser::readBuffer(bool doSeek, FLAC__uint64 sample)
short *data = (short *) buffer->data();
buffer->set_range(0, bufferSize);
// copy PCM from FLAC write buffer to our media buffer, with interleaving
(*mCopy)(data, mWriteBuffer, blocksize, getChannels());
(*mCopy)(data, (const FLAC__int32 * const *)(&mWriteBuffer), blocksize, getChannels());
// fill in buffer metadata
CHECK(mWriteHeader.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
FLAC__uint64 sampleNumber = mWriteHeader.number.sample_number;
Expand Down