- properly handle the badly decoded audio (which can happen due to payload type <-> codec inconsistency)
This commit is contained in:
parent
9afbd9e0fd
commit
4d7ca3e4f3
|
|
@ -519,6 +519,8 @@ int OpusCodec::decode(const void* input, int inputBytes, void* output, int outpu
|
||||||
|
|
||||||
int nr_of_frames = opus_decoder_get_nb_samples(mDecoderCtx, (const unsigned char *) input,
|
int nr_of_frames = opus_decoder_get_nb_samples(mDecoderCtx, (const unsigned char *) input,
|
||||||
inputBytes);
|
inputBytes);
|
||||||
|
if (nr_of_frames <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// We support stereo and mono here.
|
// We support stereo and mono here.
|
||||||
int buffer_capacity = nr_of_frames * sizeof(opus_int16) * nr_of_channels;
|
int buffer_capacity = nr_of_frames * sizeof(opus_int16) * nr_of_channels;
|
||||||
|
|
|
||||||
|
|
@ -638,8 +638,7 @@ AudioReceiver::DecodeResult AudioReceiver::getAudio(Audio::DataWindow& output, i
|
||||||
// Decode frame by frame
|
// Decode frame by frame
|
||||||
mDecodedLength = mCodec->decode(p->rtp()->GetPayloadData() + i * mCodec->rtpLength(),
|
mDecodedLength = mCodec->decode(p->rtp()->GetPayloadData() + i * mCodec->rtpLength(),
|
||||||
frameLength, mDecodedFrame, sizeof mDecodedFrame);
|
frameLength, mDecodedFrame, sizeof mDecodedFrame);
|
||||||
// mDecodedLength = 3840; // Opus 20 ms stereo
|
if (mDecodedLength > 0)
|
||||||
if (mDecodedLength)
|
|
||||||
processDecoded(output, options);
|
processDecoded(output, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue