You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
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.
This commit is contained in:
@@ -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) {
|
if (ost->sq_idx_mux >= 0) {
|
||||||
int ret = sq_send(of->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
|
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);
|
av_packet_unref(pkt);
|
||||||
if (ret == AVERROR_EOF) {
|
if (ret == AVERROR_EOF) {
|
||||||
ost->finished |= MUXER_FINISHED;
|
ost->finished |= MUXER_FINISHED;
|
||||||
return;
|
return 0;
|
||||||
} else
|
} else
|
||||||
exit_program(1);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = sq_receive(of->sq_mux, -1, SQPKT(of->mux->sq_pkt));
|
ret = sq_receive(of->sq_mux, -1, SQPKT(of->mux->sq_pkt));
|
||||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
||||||
return;
|
return 0;
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
exit_program(1);
|
return ret;
|
||||||
|
|
||||||
write_packet(of, output_streams[of->ost_index + ret],
|
write_packet(of, output_streams[of->ost_index + ret],
|
||||||
of->mux->sq_pkt);
|
of->mux->sq_pkt);
|
||||||
@@ -230,6 +230,8 @@ static void submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
|
|||||||
else
|
else
|
||||||
ost->finished |= MUXER_FINISHED;
|
ost->finished |= MUXER_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
|
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;
|
int ret;
|
||||||
|
|
||||||
if (of->mux->header_written) {
|
if (of->mux->header_written) {
|
||||||
submit_packet(of, ost, pkt);
|
return submit_packet(of, ost, pkt);
|
||||||
} else {
|
} else {
|
||||||
/* the muxer is not initialized yet, buffer the packet */
|
/* the muxer is not initialized yet, buffer the packet */
|
||||||
ret = queue_packet(of, ost, pkt);
|
ret = queue_packet(of, ost, pkt);
|
||||||
@@ -348,11 +350,13 @@ int of_check_init(OutputFile *of)
|
|||||||
ost->mux_timebase = ost->st->time_base;
|
ost->mux_timebase = ost->st->time_base;
|
||||||
|
|
||||||
while (av_fifo_read(ms->muxing_queue, &pkt, 1) >= 0) {
|
while (av_fifo_read(ms->muxing_queue, &pkt, 1) >= 0) {
|
||||||
submit_packet(of, ost, pkt);
|
ret = submit_packet(of, ost, pkt);
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
ms->muxing_queue_data_size -= pkt->size;
|
ms->muxing_queue_data_size -= pkt->size;
|
||||||
av_packet_free(&pkt);
|
av_packet_free(&pkt);
|
||||||
}
|
}
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user