From 0ab3184526e7b9b95c06a3ec7a6674283a5922d0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 29 Apr 2018 19:42:18 +0200 Subject: encode: get rid of the output packet queue Until recently, ao_lavc and vo_lavc started encoding whenever the core happened to send them data. Since audio and video are not initialized at the same time, and the muxer was not necessarily opened when the first encoder started to produce data, the resulting packets were put into a queue. As soon as the muxer was opened, the queue was flushed. Change this to make the core wait with sending data until all encoders are initialized. This has the advantage that we don't need to queue up the packets. --- common/encode_lavc.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common/encode_lavc.h') diff --git a/common/encode_lavc.h b/common/encode_lavc.h index a689b1ea47..97c2cf01f1 100644 --- a/common/encode_lavc.h +++ b/common/encode_lavc.h @@ -101,7 +101,12 @@ struct encoder_context *encoder_context_alloc(struct encode_lavc_context *ctx, // After setting your codec parameters on p->encoder, you call this to "open" // the encoder. This also initializes p->mux_stream. Returns false on failure. -bool encoder_init_codec_and_muxer(struct encoder_context *p); +// on_ready is called as soon as the muxer has been initialized. Then you are +// allowed to write packets with encoder_encode(). +// Warning: the on_ready callback is called asynchronously, so you need to +// make sure to properly synchronize everything. +bool encoder_init_codec_and_muxer(struct encoder_context *p, + void (*on_ready)(void *ctx), void *ctx); // Encode the frame and write the packet. frame is ref'ed as need. bool encoder_encode(struct encoder_context *p, AVFrame *frame); -- cgit v1.2.3