зеркало из https://github.com/mozilla/gecko-dev.git
Bug 783927 - Handle zero length audio reads in stagefright backend to fix audio issues - r=cpeterson
This commit is contained in:
Родитель
de98e3c2b9
Коммит
4c372a8b86
|
@ -72,6 +72,15 @@ struct AudioFrame {
|
|||
int32_t mAudioChannels;
|
||||
int32_t mAudioSampleRate;
|
||||
|
||||
AudioFrame() :
|
||||
mTimeUs(0),
|
||||
mData(0),
|
||||
mSize(0),
|
||||
mAudioChannels(0),
|
||||
mAudioSampleRate(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Set(int64_t aTimeUs,
|
||||
void *aData, size_t aSize,
|
||||
int32_t aAudioChannels, int32_t aAudioSampleRate)
|
||||
|
|
|
@ -256,13 +256,17 @@ bool nsMediaPluginReader::DecodeAudioData()
|
|||
}
|
||||
mAudioSeekTimeUs = -1;
|
||||
|
||||
// Ignore empty buffers which stagefright media read will sporadically return
|
||||
if (frame.mSize == 0)
|
||||
return true;
|
||||
|
||||
nsAutoArrayPtr<AudioDataValue> buffer(new AudioDataValue[frame.mSize/2] );
|
||||
memcpy(buffer.get(), frame.mData, frame.mSize);
|
||||
|
||||
PRUint32 frames = frame.mSize / (2 * frame.mAudioChannels);
|
||||
CheckedInt64 duration = FramesToUsecs(frames, frame.mAudioSampleRate);
|
||||
if (!duration.isValid()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
mAudioQueue.Push(new AudioData(pos,
|
||||
|
|
|
@ -528,20 +528,9 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aSeekTimeUs)
|
|||
unreadable = 0;
|
||||
}
|
||||
|
||||
LOG("data: %p size: %u offset: %u length: %u unreadable: %d",
|
||||
mVideoBuffer->data(),
|
||||
mVideoBuffer->size(),
|
||||
mVideoBuffer->range_offset(),
|
||||
mVideoBuffer->range_length(),
|
||||
unreadable);
|
||||
|
||||
char *data = reinterpret_cast<char *>(mVideoBuffer->data()) + mVideoBuffer->range_offset();
|
||||
size_t length = mVideoBuffer->range_length();
|
||||
|
||||
if (unreadable) {
|
||||
LOG("video frame is unreadable");
|
||||
}
|
||||
|
||||
if (!ToVideoFrame(aFrame, timeUs, data, length, keyFrame)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -563,7 +552,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aSeekTimeUs)
|
|||
bool OmxDecoder::ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs)
|
||||
{
|
||||
status_t err;
|
||||
|
||||
if (mAudioMetadataRead && aSeekTimeUs == -1) {
|
||||
// Use the data read into the buffer during metadata time
|
||||
err = OK;
|
||||
|
@ -600,10 +588,8 @@ bool OmxDecoder::ReadAudio(AudioFrame *aFrame, int64_t aSeekTimeUs)
|
|||
else
|
||||
return ReadAudio(aFrame, aSeekTimeUs);
|
||||
}
|
||||
else if (err == ERROR_END_OF_STREAM)
|
||||
return false;
|
||||
else
|
||||
return false;
|
||||
|
||||
return err == OK;
|
||||
}
|
||||
|
||||
static OmxDecoder *cast(Decoder *decoder) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче