diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/decode/ad_lavc.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index fbd6ad32ac..a420021f4a 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -48,7 +48,7 @@ struct priv { bool preroll_done; double next_pts; AVRational codec_timebase; - bool eof_returned; + struct lavc_state state; struct mp_decoder public; }; @@ -159,10 +159,10 @@ static void reset(struct mp_filter *da) ctx->trim_samples = 0; ctx->preroll_done = false; ctx->next_pts = MP_NOPTS_VALUE; - ctx->eof_returned = false; + ctx->state = (struct lavc_state){0}; } -static bool send_packet(struct mp_filter *da, struct demux_packet *mpkt) +static int send_packet(struct mp_filter *da, struct demux_packet *mpkt) { struct priv *priv = da->priv; AVCodecContext *avctx = priv->avctx; @@ -177,16 +177,12 @@ static bool send_packet(struct mp_filter *da, struct demux_packet *mpkt) mp_set_av_packet(&pkt, mpkt, &priv->codec_timebase); int ret = avcodec_send_packet(avctx, mpkt ? &pkt : NULL); - - if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - return false; - if (ret < 0) MP_ERR(da, "Error decoding audio.\n"); - return true; + return ret; } -static bool receive_frame(struct mp_filter *da, struct mp_frame *out) +static int receive_frame(struct mp_filter *da, struct mp_frame *out) { struct priv *priv = da->priv; AVCodecContext *avctx = priv->avctx; @@ -198,7 +194,7 @@ static bool receive_frame(struct mp_filter *da, struct mp_frame *out) // over in case we get new packets at some point in the future. // (Dont' reset the filter itself, we want to keep other state.) avcodec_flush_buffers(priv->avctx); - return false; + return ret; } else if (ret < 0 && ret != AVERROR(EAGAIN)) { MP_ERR(da, "Error decoding audio.\n"); } @@ -209,14 +205,14 @@ static bool receive_frame(struct mp_filter *da, struct mp_frame *out) #endif if (!priv->avframe->buf[0]) - return true; + return ret; double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase); struct mp_aframe *mpframe = mp_aframe_from_avframe(priv->avframe); if (!mpframe) { MP_ERR(da, "Converting libavcodec frame to mpv frame failed.\n"); - return true; + return ret; } if (priv->force_channel_map.num) @@ -264,14 +260,14 @@ static bool receive_frame(struct mp_filter *da, struct mp_frame *out) av_frame_unref(priv->avframe); - return true; + return ret; } static void process(struct mp_filter *ad) { struct priv *priv = ad->priv; - lavc_process(ad, &priv->eof_returned, send_packet, receive_frame); + lavc_process(ad, &priv->state, send_packet, receive_frame); } static const struct mp_filter_info ad_lavc_filter = { |