summaryrefslogtreecommitdiffstats
path: root/audio/decode/ad_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-19 22:24:26 +0100
committerwm4 <wm4@nowhere>2016-01-19 22:24:38 +0100
commit30031edce3bb79051a125183c8dc152ba4e78e66 (patch)
treeb041672d79d6e93423a65e33260ba13eca23695d /audio/decode/ad_lavc.c
parentc365b44e19e1ab1cdb0d2aaca5360108d6da862a (diff)
downloadmpv-30031edce3bb79051a125183c8dc152ba4e78e66.tar.bz2
mpv-30031edce3bb79051a125183c8dc152ba4e78e66.tar.xz
audio: move direct packet reading from decoders to common code
Another bit of preparation.
Diffstat (limited to 'audio/decode/ad_lavc.c')
-rw-r--r--audio/decode/ad_lavc.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 7e5c8d5aa5..f7304353af 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -42,7 +42,6 @@ struct priv {
AVFrame *avframe;
struct mp_audio frame;
bool force_channel_map;
- struct demux_packet *packet;
uint32_t skip_samples;
};
@@ -165,27 +164,18 @@ static int control(struct dec_audio *da, int cmd, void *arg)
switch (cmd) {
case ADCTRL_RESET:
avcodec_flush_buffers(ctx->avctx);
- talloc_free(ctx->packet);
- ctx->packet = NULL;
ctx->skip_samples = 0;
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}
-static int decode_packet(struct dec_audio *da, struct mp_audio **out)
+static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
+ struct mp_audio **out)
{
struct priv *priv = da->priv;
AVCodecContext *avctx = priv->avctx;
- struct demux_packet *mpkt = priv->packet;
- if (!mpkt) {
- if (demux_read_packet_async(da->header, &mpkt) == 0)
- return AD_WAIT;
- }
-
- priv->packet = talloc_steal(priv, mpkt);
-
int in_len = mpkt ? mpkt->len : 0;
AVPacket pkt;
@@ -203,13 +193,11 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
mpkt->len -= ret;
mpkt->pts = MP_NOPTS_VALUE; // don't reset PTS next time
}
- if (mpkt->len == 0 || ret < 0) {
- talloc_free(mpkt);
- priv->packet = NULL;
- }
// LATM may need many packets to find mux info
- if (ret == AVERROR(EAGAIN))
+ if (ret == AVERROR(EAGAIN)) {
+ mpkt->len = 0;
return AD_OK;
+ }
}
if (ret < 0) {
MP_ERR(da, "Error decoding audio.\n");