diff options
Diffstat (limited to 'audio/out/ao_lavc.c')
-rw-r--r-- | audio/out/ao_lavc.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index cb53407eb6..4bae4389e8 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -26,6 +26,7 @@ #include <limits.h> #include <libavutil/common.h> +#include <libavutil/samplefmt.h> #include "config.h" #include "options/options.h" @@ -173,7 +174,7 @@ static int init(struct ao *ao) return 0; fail: - pthread_mutex_unlock(&ao->encode_lavc_ctx->lock); + mp_mutex_unlock(&ao->encode_lavc_ctx->lock); ac->shutdown = true; return -1; } @@ -182,18 +183,8 @@ fail: static void uninit(struct ao *ao) { struct priv *ac = ao->priv; - struct encode_lavc_context *ectx = ao->encode_lavc_ctx; if (!ac->shutdown) { - double outpts = ac->expected_next_pts; - - pthread_mutex_lock(&ectx->lock); - if (!ac->enc->options->rawts) - outpts += ectx->discontinuity_pts_offset; - pthread_mutex_unlock(&ectx->lock); - - outpts += encoder_get_offset(ac->enc); - if (!write_frame(ao, MP_EOF_FRAME)) MP_WARN(ao, "could not flush last frame\n"); encoder_encode(ac->enc, NULL); @@ -210,8 +201,7 @@ static void encode(struct ao *ao, struct mp_aframe *af) double outpts = mp_aframe_get_pts(af); AVFrame *frame = mp_aframe_to_avframe(af); - if (!frame) - abort(); + MP_HANDLE_OOM(frame); frame->pts = rint(outpts * av_q2d(av_inv_q(encoder->time_base))); @@ -272,7 +262,7 @@ static bool audio_write(struct ao *ao, void **data, int samples) double outpts = pts; // for ectx PTS fields - pthread_mutex_lock(&ectx->lock); + mp_mutex_lock(&ectx->lock); if (!ectx->options->rawts) { // Fix and apply the discontinuity pts offset. @@ -291,9 +281,6 @@ static bool audio_write(struct ao *ao, void **data, int samples) outpts = pts + ectx->discontinuity_pts_offset; } - // Shift pts by the pts offset first. - outpts += encoder_get_offset(ac->enc); - // Calculate expected pts of next audio frame (input side). ac->expected_next_pts = pts + mp_aframe_get_size(af) / (double) ao->samplerate; @@ -304,7 +291,7 @@ static bool audio_write(struct ao *ao, void **data, int samples) ectx->next_in_pts = nextpts; } - pthread_mutex_unlock(&ectx->lock); + mp_mutex_unlock(&ectx->lock); mp_aframe_set_pts(af, outpts); |