Bug 960873: Part 8: Use AudioCompactor in android PluginMediaReader.cpp.

This commit is contained in:
Ben Kelly 2014-02-06 16:49:53 -05:00
Родитель 7065169ab3
Коммит 89fd1b1db1
1 изменённых файлов: 14 добавлений и 18 удалений

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

@ -294,32 +294,28 @@ bool MediaPluginReader::DecodeAudioData()
int64_t pos = mDecoder->GetResource()->Tell();
// Read next frame
MPAPI::AudioFrame frame;
if (!mPlugin->ReadAudio(mPlugin, &frame, mAudioSeekTimeUs)) {
MPAPI::AudioFrame source;
if (!mPlugin->ReadAudio(mPlugin, &source, mAudioSeekTimeUs)) {
return false;
}
mAudioSeekTimeUs = -1;
// Ignore empty buffers which stagefright media read will sporadically return
if (frame.mSize == 0)
if (source.mSize == 0)
return true;
nsAutoArrayPtr<AudioDataValue> 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 MPCopy;
return mAudioCompactor.Push(pos,
source.mTimeUs,
source.mAudioSampleRate,
frames,
source.mAudioChannels,
MPCopy(static_cast<uint8_t *>(source.mData),
source.mSize,
source.mAudioChannels));
}
nsresult MediaPluginReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime)