fftools/ffmpeg_sched: remove a triggerable assert in send_to_enc_sq()
It can be triggered when send_to_enc_thread() returns AVERROR(ENOMEM). Propagate the error to the caller instead. Reported-by: Andreas Rheinhardt
This commit is contained in:
parent
a00765fcbe
commit
c19c2078f3
@ -1541,31 +1541,34 @@ static int send_to_enc_sq(Scheduler *sch, SchEnc *enc, AVFrame *frame)
|
|||||||
// TODO: the SQ API should be extended to allow returning EOF
|
// TODO: the SQ API should be extended to allow returning EOF
|
||||||
// for individual streams
|
// for individual streams
|
||||||
ret = sq_receive(sq->sq, -1, SQFRAME(sq->frame));
|
ret = sq_receive(sq->sq, -1, SQFRAME(sq->frame));
|
||||||
if (ret == AVERROR(EAGAIN)) {
|
if (ret < 0) {
|
||||||
ret = 0;
|
ret = (ret == AVERROR(EAGAIN)) ? 0 : ret;
|
||||||
goto finish;
|
break;
|
||||||
} else if (ret < 0) {
|
|
||||||
// close all encoders fed from this sync queue
|
|
||||||
for (unsigned i = 0; i < sq->nb_enc_idx; i++) {
|
|
||||||
int err = send_to_enc_thread(sch, &sch->enc[sq->enc_idx[i]], NULL);
|
|
||||||
|
|
||||||
// if the sync queue error is EOF and closing the encoder
|
|
||||||
// produces a more serious error, make sure to pick the latter
|
|
||||||
ret = err_merge((ret == AVERROR_EOF && err < 0) ? 0 : ret, err);
|
|
||||||
}
|
|
||||||
goto finish;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enc = &sch->enc[sq->enc_idx[ret]];
|
enc = &sch->enc[sq->enc_idx[ret]];
|
||||||
ret = send_to_enc_thread(sch, enc, sq->frame);
|
ret = send_to_enc_thread(sch, enc, sq->frame);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_assert0(ret == AVERROR_EOF);
|
|
||||||
av_frame_unref(sq->frame);
|
av_frame_unref(sq->frame);
|
||||||
|
if (ret != AVERROR_EOF)
|
||||||
|
break;
|
||||||
|
|
||||||
sq_send(sq->sq, enc->sq_idx[1], SQFRAME(NULL));
|
sq_send(sq->sq, enc->sq_idx[1], SQFRAME(NULL));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
// close all encoders fed from this sync queue
|
||||||
|
for (unsigned i = 0; i < sq->nb_enc_idx; i++) {
|
||||||
|
int err = send_to_enc_thread(sch, &sch->enc[sq->enc_idx[i]], NULL);
|
||||||
|
|
||||||
|
// if the sync queue error is EOF and closing the encoder
|
||||||
|
// produces a more serious error, make sure to pick the latter
|
||||||
|
ret = err_merge((ret == AVERROR_EOF && err < 0) ? 0 : ret, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
pthread_mutex_unlock(&sq->lock);
|
pthread_mutex_unlock(&sq->lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user