SASANO, ports@,

I'd like to to commit a fix for emulators/dosbox-x which switches it away
from deprecated API in ffmpeg which prevents it to build against ffmpeg 9.0

Build tested against ffmpeg-9.0 and ffmpeg-8.1.2

Ok?

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/emulators/dosbox-x/Makefile,v
diff -u -p -r1.6 Makefile
--- Makefile    30 Jun 2025 21:51:32 -0000      1.6
+++ Makefile    12 Aug 2026 20:17:50 -0000
@@ -3,6 +3,7 @@ BROKEN-sparc64= error:union MMX_reg has 
 COMMENT=       x86 with DOS emulator targeted at playing games
 
 VERSION=       2025.05.03
+REVISION=      0
 DISTNAME=      dosbox-x-${VERSION}
 
 CATEGORIES=    games x11 emulators
Index: patches/patch-src_hardware_hardware_cpp
===================================================================
RCS file: 
/home/cvs/ports/emulators/dosbox-x/patches/patch-src_hardware_hardware_cpp,v
diff -u -p -r1.1 patch-src_hardware_hardware_cpp
--- patches/patch-src_hardware_hardware_cpp     21 Oct 2025 12:51:06 -0000      
1.1
+++ patches/patch-src_hardware_hardware_cpp     12 Aug 2026 20:13:11 -0000
@@ -1,5 +1,7 @@
 
https://github.com/joncampbell123/dosbox-x/commit/d1a6e4d79857455ffee77ed9ac48bff516504f8d
 
+Plus ffmpeg-9.0 fix
+
 Index: src/hardware/hardware.cpp
 --- src/hardware/hardware.cpp.orig
 +++ src/hardware/hardware.cpp
@@ -50,7 +52,18 @@ Index: src/hardware/hardware.cpp
                avcodec_free_context(&ffmpeg_vid_ctx);
                ffmpeg_vid_ctx = NULL;
        }
-@@ -1271,7 +1268,7 @@ skip_shot:
+@@ -813,6 +810,10 @@ void CAPTURE_AddImage(Bitu width, Bitu height, Bitu bp
+       Bitu i;
+       uint8_t doubleRow[SCALER_MAXWIDTH*4];
+       Bitu countWidth = width;
++#if (C_AVCODEC)
++      const enum AVSampleFormat *sample_fmts;
++      int num_sample_fmts, ret;
++#endif
+ 
+       if (flags & CAPTURE_FLAG_DBLH)
+               height *= 2;
+@@ -1271,7 +1272,7 @@ skip_shot:
                        ffmpeg_aud_ctx->sample_rate = 
(int)capture.video.audiorate;
                        ffmpeg_aud_ctx->flags = 0; // do not use global headers
                        ffmpeg_aud_ctx->bit_rate = 320000;
@@ -59,7 +72,25 @@ Index: src/hardware/hardware.cpp
  
                        #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
                        ffmpeg_aud_ctx->channels = 2;
-@@ -1531,7 +1528,7 @@ skip_shot:
+@@ -1280,8 +1281,15 @@ skip_shot:
+                       ffmpeg_aud_ctx->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
+                       #endif
+ 
+-                      if (ffmpeg_aud_codec->sample_fmts != NULL)
+-                              ffmpeg_aud_ctx->sample_fmt = 
(ffmpeg_aud_codec->sample_fmts)[0];
++                      ret = avcodec_get_supported_config(ffmpeg_aud_ctx, NULL,
++                                      AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
++                                      (const void **) &sample_fmts, 
&num_sample_fmts);
++                      if (ret < 0) {
++                              LOG_MSG("Failed to query audio codec sample 
formats");
++                              goto skip_video;
++                      }
++                      if (sample_fmts != NULL && num_sample_fmts > 0)
++                              ffmpeg_aud_ctx->sample_fmt = sample_fmts[0];
+                       else
+                               ffmpeg_aud_ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
+ 
+@@ -1531,7 +1539,7 @@ skip_shot:
  
                                // encode it
                                ffmpeg_vid_frame->pts = 
(int64_t)capture.video.frames; // or else libx264 complains about non-monotonic 
timestamps
@@ -68,7 +99,7 @@ Index: src/hardware/hardware.cpp
  
                                
r=avcodec_send_frame(ffmpeg_vid_ctx,ffmpeg_vid_frame);
                                if (r < 0 && r != AVERROR(EAGAIN))
-@@ -1768,7 +1765,7 @@ skip_mt_wav:
+@@ -1768,7 +1776,7 @@ skip_mt_wav:
  }
  
  #pragma pack(push,1)
@@ -77,7 +108,7 @@ Index: src/hardware/hardware.cpp
        uint32_t magic_number;   /* magic number */
        uint16_t version_major;  /* major version number */
        uint16_t version_minor;  /* minor version number */
-@@ -1776,14 +1773,14 @@ typedef struct pcap_hdr_struct_t {
+@@ -1776,14 +1784,14 @@ typedef struct pcap_hdr_struct_t {
        uint32_t sigfigs;        /* accuracy of timestamps */
        uint32_t snaplen;        /* max length of captured packets, in octets */
        uint32_t network;        /* data link type */
@@ -95,3 +126,8 @@ Index: src/hardware/hardware.cpp
  #pragma pack(pop)
  
  void Capture_WritePacket(bool /*send*/,const unsigned char *buf,size_t len) {
+@@ -2322,4 +2330,3 @@ bool capture_fmt_menu_callback(DOSBoxMenu * const menu
+ #endif
+     return true;
+ }
+-


-- 
wbr, Kirill

Reply via email to