]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Use (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO now in place of bit-mapped AV_CH_LAYOUT...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 16 Jul 2024 11:25:15 +0000 (12:25 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 16 Jul 2024 11:25:15 +0000 (12:25 +0100)
rtp.c

diff --git a/rtp.c b/rtp.c
index 0f35f0341a72045b31445b9db52c57383695d0c6..e44ff2531713da76433472886246cdd67cc51727 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -2097,7 +2097,7 @@ void avcodec_alloc_context3_cleanup_handler(void *arg) {
 void avcodec_open2_cleanup_handler(void *arg) {
   debug(3, "avcodec_open2_cleanup_handler");
   AVCodecContext *codec_context = arg;
-  avcodec_close(codec_context);
+  avcodec_free_context(&codec_context);
 }
 
 void av_parser_init_cleanup_handler(void *arg) {
@@ -2313,8 +2313,15 @@ void *rtp_buffered_audio_processor(void *arg) {
   // push a deallocator -- av_packet_free(pkt);
   pthread_cleanup_push(swr_alloc_cleanup_handler, &swr);
 
+
+// FFmpeg 5.1 or later...
+#if LIBAVUTIL_VERSION_MAJOR >= 57
+  av_opt_set_chlayout(swr, "in_chlayout", &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO, 0);
+  av_opt_set_chlayout(swr, "out_chlayout", &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO, 0);
+#else
   av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_STEREO, 0);
   av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
+#endif
   av_opt_set_int(swr, "in_sample_rate", conn->input_rate, 0);
   av_opt_set_int(swr, "out_sample_rate", conn->input_rate,
                  0); // must match or the timing will be wrong`