diff --git a/content/media/omx/MediaOmxReader.cpp b/content/media/omx/MediaOmxReader.cpp index d8342e4c17a..db4e2de1a63 100644 --- a/content/media/omx/MediaOmxReader.cpp +++ b/content/media/omx/MediaOmxReader.cpp @@ -312,33 +312,29 @@ bool MediaOmxReader::DecodeAudioData() int64_t pos = mDecoder->GetResource()->Tell(); // Read next frame - MPAPI::AudioFrame frame; - if (!mOmxDecoder->ReadAudio(&frame, mAudioSeekTimeUs)) { + MPAPI::AudioFrame source; + if (!mOmxDecoder->ReadAudio(&source, mAudioSeekTimeUs)) { return false; } mAudioSeekTimeUs = -1; // Ignore empty buffer which stagefright media read will sporadically return - if (frame.mSize == 0) { + if (source.mSize == 0) { return true; } - nsAutoArrayPtr buffer(new AudioDataValue[frame.mSize/2] ); - memcpy(buffer.get(), frame.mData, frame.mSize); + uint32_t frames = source.mSize / (source.mAudioChannels * + sizeof(AudioDataValue)); - uint32_t frames = frame.mSize / (2 * frame.mAudioChannels); - CheckedInt64 duration = FramesToUsecs(frames, frame.mAudioSampleRate); - if (!duration.isValid()) { - return false; - } - - mAudioQueue.Push(new AudioData(pos, - frame.mTimeUs, - duration.value(), - frames, - buffer.forget(), - frame.mAudioChannels)); - return true; + typedef AudioCompactor::NativeCopy OmxCopy; + return mAudioCompactor.Push(pos, + source.mTimeUs, + source.mAudioSampleRate, + frames, + source.mAudioChannels, + OmxCopy(static_cast(source.mData), + source.mSize, + source.mAudioChannels)); } nsresult MediaOmxReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime)