From b74c09efbf7c6969fc053265f72cc0501b840ce1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Aug 2020 20:23:54 +0200 Subject: audio: refactor how data is passed to AO This replaces the two buffers (ao_chain.ao_buffer in the core, and buffer_state.buffers in the AO) with a single queue. Instead of having a byte based buffer, the queue is simply a list of audio frames, as output by the decoder. This should make dataflow simpler and reduce copying. It also attempts to simplify fill_audio_out_buffers(), the function I always hated most, because it's full of subtle and buggy logic. Unfortunately, I got assaulted by corner cases, dumb features (attempt at seamless looping, really?), and other crap, so it got pretty complicated again. fill_audio_out_buffers() is still full of subtle and buggy logic. Maybe it got worse. On the other hand, maybe there really is some progress. Who knows. Originally, the data flow parts was meant to be in f_output_chain, but due to tricky interactions with the playloop code, it's now in the dummy filter in audio.c. At least this improves the way the audio PTS is passed to the encoder in encoding mode. Now it attempts to pass frames directly, along with the pts, which should minimize timestamp problems. But to be honest, encoder mode is one big kludge that shouldn't exist in this way. This commit should be considered pre-alpha code. There are lots of bugs still hiding. --- common/encode.h | 1 - common/encode_lavc.c | 13 ------------- common/encode_lavc.h | 6 ------ 3 files changed, 20 deletions(-) (limited to 'common') diff --git a/common/encode.h b/common/encode.h index 62a8b094e9..2803cde4de 100644 --- a/common/encode.h +++ b/common/encode.h @@ -60,7 +60,6 @@ void encode_lavc_stream_eof(struct encode_lavc_context *ctx, enum stream_type type); void encode_lavc_set_metadata(struct encode_lavc_context *ctx, struct mp_tags *metadata); -void encode_lavc_set_audio_pts(struct encode_lavc_context *ctx, double pts); bool encode_lavc_didfail(struct encode_lavc_context *ctx); // check if encoding failed #endif diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 94428c6733..e57c3b9d38 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -243,16 +243,6 @@ bool encode_lavc_free(struct encode_lavc_context *ctx) return res; } -void encode_lavc_set_audio_pts(struct encode_lavc_context *ctx, double pts) -{ - if (ctx) { - pthread_mutex_lock(&ctx->lock); - ctx->last_audio_in_pts = pts; - ctx->samples_since_last_pts = 0; - pthread_mutex_unlock(&ctx->lock); - } -} - // called locked static void maybe_init_muxer(struct encode_lavc_context *ctx) { @@ -503,10 +493,7 @@ void encode_lavc_discontinuity(struct encode_lavc_context *ctx) return; pthread_mutex_lock(&ctx->lock); - - ctx->audio_pts_offset = MP_NOPTS_VALUE; ctx->discontinuity_pts_offset = MP_NOPTS_VALUE; - pthread_mutex_unlock(&ctx->lock); } diff --git a/common/encode_lavc.h b/common/encode_lavc.h index 390aabd1f8..06e7254e86 100644 --- a/common/encode_lavc.h +++ b/common/encode_lavc.h @@ -49,12 +49,6 @@ struct encode_lavc_context { // must lock manually before accessing state. pthread_mutex_t lock; - // sync to audio mode - double audio_pts_offset; - - double last_audio_in_pts; - int64_t samples_since_last_pts; - // anti discontinuity mode double next_in_pts; double discontinuity_pts_offset; -- cgit v1.2.3