From b14c9d6b907ad147d02e9de536e4d396e47af03e Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 23 Jul 2021 11:46:41 +0200 Subject: player: Replace deprecated ffmpeg function Use av_packet_alloc() instead of av_packet_init(). --- src/player.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/player.c b/src/player.c index b8eeead..875f473 100644 --- a/src/player.c +++ b/src/player.c @@ -401,12 +401,12 @@ BarPlayerMode BarPlayerGetMode (player_t * const player) { static int play (player_t * const player) { assert (player != NULL); const int64_t minBufferHealth = player->settings->bufferSecs; - - AVPacket pkt; AVCodecContext * const cctx = player->cctx; - av_init_packet (&pkt); - pkt.data = NULL; - pkt.size = 0; + + AVPacket *pkt = av_packet_alloc (); + assert (pkt != NULL); + pkt->data = NULL; + pkt->size = 0; AVFrame *frame = NULL; frame = av_frame_alloc (); @@ -418,15 +418,15 @@ static int play (player_t * const player) { const double timeBase = av_q2d (player->st->time_base); while (!shouldQuit (player) && drainMode != DONE) { if (drainMode == FILL) { - ret = av_read_frame (player->fctx, &pkt); + ret = av_read_frame (player->fctx, pkt); if (ret == AVERROR_EOF) { /* enter drain mode */ drainMode = DRAIN; avcodec_send_packet (cctx, NULL); debugPrint (DEBUG_AUDIO, "decoder entering drain mode after EOF\n"); - } else if (pkt.stream_index != player->streamIdx) { + } else if (pkt->stream_index != player->streamIdx) { /* unused packet */ - av_packet_unref (&pkt); + av_packet_unref (pkt); continue; } else if (ret < 0) { /* error, abort */ @@ -441,7 +441,7 @@ static int play (player_t * const player) { break; } else { /* fill buffer */ - avcodec_send_packet (cctx, &pkt); + avcodec_send_packet (cctx, pkt); } } @@ -490,9 +490,10 @@ static int play (player_t * const player) { } while (bufferHealth > minBufferHealth); } - av_packet_unref (&pkt); + av_packet_unref (pkt); } av_frame_free (&frame); + av_packet_free (&pkt); debugPrint (DEBUG_AUDIO, "decoder is done, waiting for ao player\n"); pthread_join (aoplaythread, NULL); -- cgit v1.2.3