summaryrefslogtreecommitdiffstats
path: root/sound/shairport-sync/patches/100-Handle-new-libavcodec-version.patch
blob: 199143645451139d7f25bdc3077d266e1463e848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From d8734148cda1d53885429d8a40ded2cc8e21112d Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 25 Oct 2026 12:09:50 +0100
Subject: [PATCH] Handle new libavcodec version

New libavcodec version dropped sample_fmts with new API.

Support for new library was added with commit d043f9833050 that also
updated other stuff included in version 5.0+.

Pick that specific change and backport it.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 shairport.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

--- a/shairport.c
+++ b/shairport.c
@@ -157,17 +157,34 @@ int has_fltp_capable_aac_decoder(void) {
 
   // return 1 if the AAC decoder advertises fltp decoding capability, which
   // is needed for decoding Buffered Audio streams
+  debug(3, "checking availability of an  fltp-capable aac decoder");
   int has_capability = 0;
   const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_AAC);
   if (codec != NULL) {
-    const enum AVSampleFormat *p = codec->sample_fmts;
-    if (p != NULL) {
-      while ((has_capability == 0) && (*p != AV_SAMPLE_FMT_NONE)) {
-        if (*p == AV_SAMPLE_FMT_FLTP)
+    const enum AVSampleFormat *formats = NULL;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100)
+    // New API (FFmpeg 7.1+) for getting formats
+    debug(3, "getting sample formats the new way");
+    int format_count = 0;
+    if ((avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
+                                      (const void **)&formats, &format_count) < 0) ||
+        (format_count == 0))
+      formats = NULL; // not clear if the returned pointer is nulled on error or on zero items
+#else
+    debug(3, "getting sample formats the old way");
+    // older API
+    formats = codec->sample_fmts;
+#endif
+    if (formats != NULL) {
+      while ((has_capability == 0) && (*formats != AV_SAMPLE_FMT_NONE)) {
+        if (*formats == AV_SAMPLE_FMT_FLTP) {
           has_capability = 1;
-        p++;
+        }
+        formats++;
       }
     }
+  } else {
+    debug(3, "no AAC codec found.");
   }
   return has_capability;
 }