encode: restore audio muxer timebase use

Seems to crash hard if an error happens somewhere at init. Who cares.

Part of #7524.
This commit is contained in:
wm4 2020-03-22 13:06:59 +01:00
parent b572f116da
commit de53155971
3 changed files with 12 additions and 0 deletions

View File

@ -87,6 +87,9 @@ static void select_format(struct ao *ao, const AVCodec *codec)
static void on_ready(void *ptr)
{
struct ao *ao = ptr;
struct priv *ac = ao->priv;
ac->worst_time_base = encoder_get_mux_timebase_unlocked(ac->enc);
ao_add_events(ao, AO_EVENT_INITIAL_UNBLOCK);
}

View File

@ -491,6 +491,11 @@ done:
av_packet_unref(pkt);
}
AVRational encoder_get_mux_timebase_unlocked(struct encoder_context *p)
{
return p->mux_stream->st->time_base;
}
void encode_lavc_discontinuity(struct encode_lavc_context *ctx)
{
if (!ctx)

View File

@ -111,6 +111,10 @@ bool encoder_init_codec_and_muxer(struct encoder_context *p,
// Encode the frame and write the packet. frame is ref'ed as need.
bool encoder_encode(struct encoder_context *p, AVFrame *frame);
// Return muxer timebase (only available after on_ready() has been called).
// Caller needs to acquire encode_lavc_context.lock (or call it from on_ready).
AVRational encoder_get_mux_timebase_unlocked(struct encoder_context *p);
double encoder_get_offset(struct encoder_context *p);
#endif