зеркало из https://github.com/mozilla/gecko-dev.git
Bug 960873: Part 4: Make OMX use AudioCompactor. r=cpearce
This commit is contained in:
Родитель
0723cf47be
Коммит
afd768e3f3
|
@ -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<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 OmxCopy;
|
||||
return mAudioCompactor.Push(pos,
|
||||
source.mTimeUs,
|
||||
source.mAudioSampleRate,
|
||||
frames,
|
||||
source.mAudioChannels,
|
||||
OmxCopy(static_cast<uint8_t *>(source.mData),
|
||||
source.mSize,
|
||||
source.mAudioChannels));
|
||||
}
|
||||
|
||||
nsresult MediaOmxReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime)
|
||||
|
|
Загрузка…
Ссылка в новой задаче