···
1
+
From b120f82f9809b98231188daacb94f22a9e69187a Mon Sep 17 00:00:00 2001
2
+
From: Gregor Riepl <onitake@gmail.com>
3
+
Date: Thu, 8 Aug 2024 23:56:16 +0200
4
+
Subject: [PATCH] Replace deprecated APIs when compiling against newer FFmpeg
7
+
module/ffmedia.c | 37 +++++++++++++++++++++++++++++++++++++
8
+
1 file changed, 37 insertions(+)
10
+
diff --git a/module/ffmedia.c b/module/ffmedia.c
11
+
index d4bb346ac35740711b8393e66d0bfc28c849ff0e..0f57e311f277359fad731e348531becbadbb06d4 100644
12
+
--- a/module/ffmedia.c
13
+
+++ b/module/ffmedia.c
14
+
@@ -71,7 +71,11 @@ static int rwops_read(void *opaque, uint8_t *buf, int buf_size) {
18
+
+#if (LIBAVFORMAT_VERSION_MAJOR < 61)
19
+
static int rwops_write(void *opaque, uint8_t *buf, int buf_size) {
21
+
+static int rwops_write(void *opaque, const uint8_t *buf, int buf_size) {
23
+
printf("Writing to an SDL_rwops is a really bad idea.\n");
26
+
@@ -690,9 +694,14 @@ static void decode_audio(MediaState *ms) {
29
+
converted_frame->sample_rate = audio_sample_rate;
30
+
+#if (LIBAVUTIL_VERSION_MAJOR < 59)
31
+
converted_frame->channel_layout = AV_CH_LAYOUT_STEREO;
33
+
+ converted_frame->ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO;
35
+
converted_frame->format = AV_SAMPLE_FMT_S16;
37
+
+#if (LIBAVUTIL_VERSION_MAJOR < 59)
38
+
if (!ms->audio_decode_frame->channel_layout) {
39
+
ms->audio_decode_frame->channel_layout = av_get_default_channel_layout(ms->audio_decode_frame->channels);
41
+
@@ -711,6 +720,26 @@ static void decode_audio(MediaState *ms) {
42
+
swr_set_matrix(ms->swr, stereo_matrix, 1);
46
+
+ if (ms->audio_decode_frame->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
47
+
+ av_channel_layout_default(&ms->audio_decode_frame->ch_layout, ms->audio_decode_frame->ch_layout.nb_channels);
49
+
+ if (audio_equal_mono && (ms->audio_decode_frame->ch_layout.nb_channels == 1)) {
50
+
+ swr_alloc_set_opts2(
52
+
+ &converted_frame->ch_layout,
53
+
+ converted_frame->format,
54
+
+ converted_frame->sample_rate,
55
+
+ &ms->audio_decode_frame->ch_layout,
56
+
+ ms->audio_decode_frame->format,
57
+
+ ms->audio_decode_frame->sample_rate,
61
+
+ swr_set_matrix(ms->swr, stereo_matrix, 1);
66
+
if(swr_convert_frame(ms->swr, converted_frame, ms->audio_decode_frame)) {
67
+
av_frame_free(&converted_frame);
68
+
@@ -1159,7 +1188,11 @@ static int decode_thread(void *arg) {
70
+
// Compute the number of samples we need to play back.
71
+
if (ms->audio_duration < 0) {
72
+
+#if (LIBAVFORMAT_VERSION_MAJOR < 62)
73
+
if (av_fmt_ctx_get_duration_estimation_method(ctx) != AVFMT_DURATION_FROM_BITRATE) {
75
+
+ if (ctx->duration_estimation_method != AVFMT_DURATION_FROM_BITRATE) {
78
+
long long duration = ((long long) ctx->duration) * audio_sample_rate;
79
+
ms->audio_duration = (unsigned int) (duration / AV_TIME_BASE);
80
+
@@ -1319,7 +1352,11 @@ static int decode_sync_start(void *arg) {
82
+
// Compute the number of samples we need to play back.
83
+
if (ms->audio_duration < 0) {
84
+
+#if (LIBAVFORMAT_VERSION_MAJOR < 62)
85
+
if (av_fmt_ctx_get_duration_estimation_method(ctx) != AVFMT_DURATION_FROM_BITRATE) {
87
+
+ if (ctx->duration_estimation_method != AVFMT_DURATION_FROM_BITRATE) {
90
+
long long duration = ((long long) ctx->duration) * audio_sample_rate;
91
+
ms->audio_duration = (unsigned int) (duration / AV_TIME_BASE);