From a8139210147e2fd4c6e36b9cf58901ad853b6a44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?=
 <jeanmichael.celerier@gmail.com>
Date: Wed, 10 Apr 2024 16:20:45 -0400
Subject: [PATCH] [media] Support for ffmpeg 7

---
 src/ossia/detail/libav.hpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/ossia/detail/libav.hpp b/src/ossia/detail/libav.hpp
index a25d9c49c9c..531be37b5fd 100644
--- a/src/ossia/detail/libav.hpp
+++ b/src/ossia/detail/libav.hpp
@@ -59,6 +59,15 @@ inline bool seek_to_flick(
   return true;
 }
 
+static inline int avstream_get_audio_channels(AVStream& stream) noexcept
+{
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
+  return stream.codecpar->ch_layout.nb_channels;
+#else
+  return stream.codecpar->channels;
+#endif
+}
+
 struct libav_handle
 {
   AVFormatContext* format{};
@@ -185,14 +194,7 @@ struct libav_handle
   }
 
   int rate() const noexcept { return stream->codecpar->sample_rate; }
-  int channels() const noexcept
-  {
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 24, 100)
-    return stream->codecpar->ch_layout.nb_channels;
-#else
-    return stream->codecpar->channels;
-#endif
-  }
+  int channels() const noexcept { return avstream_get_audio_channels(*stream); }
 
   int64_t totalPCMFrameCount() const noexcept
   {