Re: emulators/dosbox-x: compatibility with ffmpeg 9.0

Kirill A. Korinsky <[email protected]>
Newsgroups gmane.os.openbsd.ports
Message-ID <[email protected]>
On Thu, 13 Aug 2026 15:31:17 +0200,
SASANO Takayoshi <[email protected]> wrote:
> 
> Hello,
> 
> > 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?
> 
> I found recently posted dosbox-x pull request at
> https://github.com/joncampbell123/dosbox-x/pull/6467/changes/18062c0ffb33db35fa52ce937ce25223140c0293
> 
> to update dosbox-x ports easy in the future,
> can you rewrite the diff based on this PR?
> 

Sure, here it is:

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	13 Aug 2026 14:03:17 -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	13 Aug 2026 14:07:33 -0000
@@ -1,4 +1,5 @@
 https://github.com/joncampbell123/dosbox-x/commit/d1a6e4d79857455ffee77ed9ac48bff516504f8d
+https://github.com/joncampbell123/dosbox-x/pull/6467/changes/18062c0ffb33db35fa52ce937ce25223140c0293
 
 Index: src/hardware/hardware.cpp
 --- src/hardware/hardware.cpp.orig
@@ -59,7 +60,37 @@ 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:
+@@ -1279,10 +1276,27 @@ skip_shot:
+ 			#else
+ 			ffmpeg_aud_ctx->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
+ 			#endif
+-
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 13, 100)
++            // Legacy support for FFmpeg not supporting avcodec_get_supported_config()
+ 			if (ffmpeg_aud_codec->sample_fmts != NULL)
+ 				ffmpeg_aud_ctx->sample_fmt = (ffmpeg_aud_codec->sample_fmts)[0];
+-			else
++#else
++            // For FFmpeg supporting avcodec_get_supported_config()
++            const enum AVSampleFormat* formats = NULL;
++
++            const int ret = avcodec_get_supported_config(
++                NULL,
++                ffmpeg_aud_codec,
++                AV_CODEC_CONFIG_SAMPLE_FORMAT,
++                0,
++                reinterpret_cast<const void**>(&formats),
++                NULL
++            );
++
++            if(ret >= 0 && formats != NULL)
++                ffmpeg_aud_ctx->sample_fmt = formats[0];
++#endif
++            else
+ 				ffmpeg_aud_ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
+ 
+ 			if (avcodec_open2(ffmpeg_aud_ctx,ffmpeg_aud_codec,NULL) < 0) {
+@@ -1531,7 +1545,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 +1782,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 +1790,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 */


-- 
wbr, Kirill
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.