Skip to content

Commit 70c0a4c

Browse files
committed
encode: respect quit variable in more places
1 parent 063d848 commit 70c0a4c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/cyanrip_encode.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx,
492492
if (!dec_ctx->filt.buffersrc_ctx)
493493
return push_frame_to_encs(ctx, enc_ctx, num_enc, frame);
494494

495-
496495
ret = av_buffersrc_add_frame_flags(dec_ctx->filt.buffersrc_ctx, frame,
497496
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
498497
AV_BUFFERSRC_FLAG_KEEP_REF);
@@ -879,17 +878,14 @@ static void *cyanrip_track_encoding(void *ctx)
879878
goto fail;
880879
}
881880

882-
while (1) {
881+
while (!atomic_load(&s->quit)) {
883882
AVFrame *out_frame = NULL;
884883

885884
if (!flushing) {
886885
out_frame = cr_frame_fifo_pop(s->fifo);
887886
flushing = !out_frame;
888887
}
889888

890-
if (atomic_load(&s->quit))
891-
goto fail;
892-
893889
ret = audio_process_frame(ctx, &out_frame, flushing);
894890
if (ret == AVERROR(EAGAIN))
895891
continue;
@@ -905,7 +901,7 @@ static void *cyanrip_track_encoding(void *ctx)
905901
}
906902

907903
/* Return loop */
908-
while (1) {
904+
while (!atomic_load(&s->quit)) {
909905
ret = avcodec_receive_packet(s->out_avctx, out_pkt);
910906
if (ret == AVERROR_EOF) {
911907
ret = 0;
@@ -972,7 +968,7 @@ static void *cyanrip_track_encoding(void *ctx)
972968
goto fail;
973969
}
974970

975-
while ((out_pkt = cr_packet_fifo_pop(s->packet_fifo))) {
971+
while (!atomic_load(&s->quit) && (out_pkt = cr_packet_fifo_pop(s->packet_fifo))) {
976972
/* Send frames to lavf */
977973
ret = av_interleaved_write_frame(s->avf, out_pkt);
978974
av_packet_free(&out_pkt);

0 commit comments

Comments
 (0)