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. --- audio/out/push.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'audio/out/push.c') diff --git a/audio/out/push.c b/audio/out/push.c index b198afef91..470f521c68 100644 --- a/audio/out/push.c +++ b/audio/out/push.c @@ -56,6 +56,7 @@ struct ao_push_state { bool still_playing; bool need_wakeup; bool paused; + bool initial_unblocked; // Whether the current buffer contains the complete audio. bool final_chunk; @@ -357,7 +358,8 @@ static void *playthread(void *arg) mpthread_set_name("ao"); pthread_mutex_lock(&p->lock); while (!p->terminate) { - bool playing = !p->paused || ao->stream_silence; + bool blocked = ao->driver->initially_blocked && !p->initial_unblocked; + bool playing = (!p->paused || ao->stream_silence) && !blocked; if (playing) ao_play_data(ao); @@ -502,6 +504,19 @@ int ao_play_silence(struct ao *ao, int samples) return ao->driver->play(ao, (void **)p->silence, samples, 0); } +void ao_unblock(struct ao *ao) +{ + if (ao->api == &ao_api_push) { + struct ao_push_state *p = ao->api_priv; + pthread_mutex_lock(&p->lock); + p->need_wakeup = true; + p->initial_unblocked = true; + wakeup_playthread(ao); + pthread_cond_signal(&p->wakeup); + pthread_mutex_unlock(&p->lock); + } +} + #ifndef __MINGW32__ #include -- cgit v1.2.3