summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-04-01 10:03:46 +0200
committerAnton Khirnov <anton@khirnov.net>2022-07-23 11:53:19 +0200
commit279214dd517f6c58e43a4d6e8beb09accbaf3d4b (patch)
treeba01167bf8e0dd8cf2fd504ccb78152bd4a2688e /fftools
parent52bc8a842e037214e1644f61962982c73a175eca (diff)
fftools/ffmpeg_mux: return errors from submit_packet()
Do not call exit_program(), as that would conflict with moving this code into a separate thread.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_mux.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 490e0e54eb..98d3adaeac 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -200,7 +200,7 @@ static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
}
}
-static void submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
+static int submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
{
if (ost->sq_idx_mux >= 0) {
int ret = sq_send(of->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
@@ -209,17 +209,17 @@ static void submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
av_packet_unref(pkt);
if (ret == AVERROR_EOF) {
ost->finished |= MUXER_FINISHED;
- return;
+ return 0;
} else
- exit_program(1);
+ return ret;
}
while (1) {
ret = sq_receive(of->sq_mux, -1, SQPKT(of->mux->sq_pkt));
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
- return;
+ return 0;
else if (ret < 0)
- exit_program(1);
+ return ret;
write_packet(of, output_streams[of->ost_index + ret],
of->mux->sq_pkt);
@@ -230,6 +230,8 @@ static void submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
else
ost->finished |= MUXER_FINISHED;
}
+
+ return 0;
}
int of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
@@ -237,7 +239,7 @@ int of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
int ret;
if (of->mux->header_written) {
- submit_packet(of, ost, pkt);
+ return submit_packet(of, ost, pkt);
} else {
/* the muxer is not initialized yet, buffer the packet */
ret = queue_packet(of, ost, pkt);
@@ -348,11 +350,13 @@ int of_check_init(OutputFile *of)
ost->mux_timebase = ost->st->time_base;
while (av_fifo_read(ms->muxing_queue, &pkt, 1) >= 0) {
- submit_packet(of, ost, pkt);
+ ret = submit_packet(of, ost, pkt);
if (pkt) {
ms->muxing_queue_data_size -= pkt->size;
av_packet_free(&pkt);
}
+ if (ret < 0)
+ return ret;
}
}