From a9c0ad149f707adf8ba34c8fe1ce5859f30b0852 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 7 Aug 2023 23:08:32 +0200 Subject: ad_spdif: fix this not working at all fixes 4c3ed843dc8bde419d8c08565159a83cee9e3b9b closes #12102 --- audio/decode/ad_spdif.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'audio/decode/ad_spdif.c') diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 19a9b7d2f6..393af8a2a3 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -153,8 +153,7 @@ static int init_filter(struct mp_filter *da) { struct spdifContext *spdif_ctx = da->priv; - AVPacket *pkt = spdif_ctx->avpkt = av_packet_alloc(); - MP_HANDLE_OOM(spdif_ctx->avpkt); + AVPacket *pkt = spdif_ctx->avpkt; int profile = FF_PROFILE_UNKNOWN; int c_rate = 0; @@ -299,14 +298,18 @@ static void process(struct mp_filter *da) struct mp_aframe *out = NULL; double pts = mpkt->pts; + if (!spdif_ctx->avpkt) { + spdif_ctx->avpkt = av_packet_alloc(); + MP_HANDLE_OOM(spdif_ctx->avpkt); + } + mp_set_av_packet(spdif_ctx->avpkt, mpkt, NULL); + spdif_ctx->avpkt->pts = spdif_ctx->avpkt->dts = 0; if (!spdif_ctx->lavf_ctx) { if (init_filter(da) < 0) goto done; assert(spdif_ctx->avpkt); } - mp_set_av_packet(spdif_ctx->avpkt, mpkt, NULL); - spdif_ctx->avpkt->pts = spdif_ctx->avpkt->dts = 0; spdif_ctx->out_buffer_len = 0; int ret = av_write_frame(spdif_ctx->lavf_ctx, spdif_ctx->avpkt); avio_flush(spdif_ctx->lavf_ctx->pb); -- cgit v1.2.3