Skip to content

Commit

Permalink
do not decode invalid packets(not eof) to avoid crash
Browse files Browse the repository at this point in the history
demuxer thread does not block queue empty at eof, so avthreads may gets
lots of invalid packets
TODO: do in videothread
  • Loading branch information
wang-bin committed Jan 15, 2016
1 parent 395b168 commit c957663
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ void AudioThread::run()
continue;
}
}
if (!pkt.isValid() && !pkt.isEOF()) // decode it will cause crash
continue;
qreal dts = pkt.dts; //FIXME: pts and dts
// no key frame for audio. so if pts reaches, try decode and skip render if got frame pts does not reach
bool skip_render = pkt.pts >= 0 && pkt.pts < d.render_pts0; // if audio stream is too short, seeking will fail and d.render_pts0 keeps >0
Expand Down Expand Up @@ -291,9 +293,7 @@ void AudioThread::run()
int decodedSize = decoded.size();
int decodedPos = 0;
qreal delay = 0;
//AudioFormat.durationForBytes() calculates int type internally. not accurate
const AudioFormat &af = dec->resampler()->outAudioFormat();
const qreal byte_rate = af.bytesPerSecond();
const qreal byte_rate = frame.format().bytesPerSecond();
while (decodedSize > 0) {
if (d.stop) {
qDebug("audio thread stop after decode()");
Expand Down

0 comments on commit c957663

Please sign in to comment.