[Scummvm-git-logs] scummvm master -> 560c8ace922eed9cc03e6ad0557685e29c63f4a2

mikrosk noreply at scummvm.org
Tue Jul 28 04:43:17 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
560c8ace92 BACKENDS: ATARI: Update to uSound v2 API


Commit: 560c8ace922eed9cc03e6ad0557685e29c63f4a2
    https://github.com/scummvm/scummvm/commit/560c8ace922eed9cc03e6ad0557685e29c63f4a2
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2026-07-28T14:43:09+10:00

Commit Message:
BACKENDS: ATARI: Update to uSound v2 API

Changed paths:
  A backends/mixer/atari/usound_compat.h
    backends/mixer/atari/atari-mixer.cpp


diff --git a/backends/mixer/atari/atari-mixer.cpp b/backends/mixer/atari/atari-mixer.cpp
index e60f2b497e5..52428b6a1d7 100644
--- a/backends/mixer/atari/atari-mixer.cpp
+++ b/backends/mixer/atari/atari-mixer.cpp
@@ -27,7 +27,10 @@
 #include <mint/falcon.h>
 #include <mint/osbind.h>
 #include <mint/ostruct.h>
-#include <usound.h>	// https://github.com/mikrosk/usound
+// https://github.com/mikrosk/usound
+// Use usound_compat.h until SDL 1.2 + uSound have been upgraded in the build image.
+// Replace with #include <usound.h> once ihe image ships usound.h >= 2; it will #error in such case.
+#include "usound_compat.h"
 
 #include "common/config-manager.h"
 #include "common/debug.h"
@@ -42,9 +45,11 @@
 #define DEFAULT_OUTPUT_CHANNELS 2
 #define DEFAULT_SAMPLES 2048	// 83ms
 
+static USoundContext usoundContext;
+
 void AtariAudioShutdown() {
 	Jdisint(MFP_TIMERA);
-	AtariSoundSetupDeinitXbios();
+	USoundDeinitXbios(&usoundContext);
 }
 
 static volatile bool muted;
@@ -99,18 +104,18 @@ AtariMixerManager::~AtariMixerManager() {
 }
 
 void AtariMixerManager::init() {
-	AudioSpec desired, obtained;
+	USoundSpec desired, obtained;
 
 	desired.frequency = _outputRate;
 	desired.channels = _outputChannels;
-	desired.format = AudioFormatSigned16MSB;
+	desired.format = USoundFormatSigned16MSB;
 	desired.samples = _samples;
 
-	if (!AtariSoundSetupInitXbios(&desired, &obtained)) {
+	if (!USoundInitXbios(&desired, &obtained, &usoundContext)) {
 		error("Sound system is not available");
 	}
 
-	if (obtained.format != AudioFormatSigned8 && obtained.format != AudioFormatSigned16MSB) {
+	if (obtained.format != USoundFormatSigned8 && obtained.format != USoundFormatSigned16MSB) {
 		error("Sound system currently supports only 8/16-bit signed big endian samples");
 	}
 
@@ -121,14 +126,14 @@ void AtariMixerManager::init() {
 	_outputRate = obtained.frequency;
 	_outputChannels = obtained.channels;
 	_samples = obtained.samples;
-	_downsample = (obtained.format == AudioFormatSigned8);
+	_downsample = (obtained.format == USoundFormatSigned8);
 
 	ConfMan.setInt("output_rate", _outputRate, Common::ConfigManager::kApplicationDomain);
 	ConfMan.setInt("output_channels", _outputChannels, Common::ConfigManager::kApplicationDomain);
 	ConfMan.setInt("audio_buffer_size", _samples, Common::ConfigManager::kApplicationDomain);
 
 	debug("setting %d Hz mixing frequency (%d-bit, %s)",
-		  _outputRate, obtained.format == AudioFormatSigned8 ? 8 : 16, _outputChannels == 1 ? "mono" : "stereo");
+		  _outputRate, obtained.format == USoundFormatSigned8 ? 8 : 16, _outputChannels == 1 ? "mono" : "stereo");
 	debug("sample buffer size: %d", _samples);
 
 	ConfMan.flushToDisk();
diff --git a/backends/mixer/atari/usound_compat.h b/backends/mixer/atari/usound_compat.h
new file mode 100644
index 00000000000..b75edfa00c9
--- /dev/null
+++ b/backends/mixer/atari/usound_compat.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2023-2026 Miro Kropacek <miro.kropacek at gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the “Software”), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Presents the uSound 2 API (USoundSpec / USoundContext / USoundInitXbios())
+ * on top of any installed usound.h, including the pre-2 one which had
+ * AudioSpec, AtariSoundSetup*() and no context.
+ *
+ * Include this instead of <usound.h> and copy it into your own source tree --
+ * a sysroot with a pre-2 usound.h will not have it.
+ *
+ * Nothing here is needed once the oldest usound.h you care about is >= 2 --
+ * including it against such a header is a hard error telling you to remove it.
+ */
+
+#ifndef USOUND_COMPAT_H
+#define USOUND_COMPAT_H
+
+/*
+ * Pre-2 entry points have external linkage and some libSDL builds export the
+ * very same symbols, so keep ours out of their way. Rename unconditionally:
+ * usound >= 2 has no such identifiers, which is what lets us decide everything
+ * else *after* the #include, where USOUND_VERSION finally becomes visible.
+ */
+#ifndef USOUND_COMPAT_INIT
+#define USOUND_COMPAT_INIT		USoundCompatInitXbios
+#endif
+#ifndef USOUND_COMPAT_DEINIT
+#define USOUND_COMPAT_DEINIT	USoundCompatDeinitXbios
+#endif
+#define AtariSoundSetupInitXbios	USOUND_COMPAT_INIT
+#define AtariSoundSetupDeinitXbios	USOUND_COMPAT_DEINIT
+
+#include <usound.h>
+
+#ifndef USOUND_VERSION
+/*
+ * Pre-2 usound.h. Layout of AudioSpec is identical to USoundSpec, only the
+ * names differ, so plain typedefs do the job.
+ */
+typedef AudioFormat	USoundFormat;
+typedef AudioSpec	USoundSpec;
+
+#define USoundFormatSigned8			AudioFormatSigned8
+#define USoundFormatSigned16LSB		AudioFormatSigned16LSB
+#define USoundFormatSigned16MSB		AudioFormatSigned16MSB
+#define USoundFormatUnsigned8		AudioFormatUnsigned8
+#define USoundFormatUnsigned16LSB	AudioFormatUnsigned16LSB
+#define USoundFormatUnsigned16MSB	AudioFormatUnsigned16MSB
+#define USoundFormatCount			AudioFormatCount
+
+/*
+ * Pre-2 keeps its state in the header itself, so this is a placeholder --
+ * pass it around exactly as you would with usound >= 2. Note that it cannot
+ * give you the one property the real context adds: with a pre-2 header the
+ * state is still per-translation-unit, so init and deinit have to stay in the
+ * same file.
+ */
+typedef struct {
+	int unused;
+} USoundContext;
+
+#ifndef USOUND_DEF
+#ifdef __GNUC__
+/* a translation unit doesn't have to use both of them */
+#define USOUND_DEF	static __attribute__((__unused__))
+#else
+#define USOUND_DEF	static
+#endif
+#endif	/* USOUND_DEF */
+
+USOUND_DEF int USoundInitXbios(const USoundSpec* desired, USoundSpec* obtained, USoundContext* context)
+{
+	(void)context;
+	return AtariSoundSetupInitXbios(desired, obtained);
+}
+
+USOUND_DEF int USoundDeinitXbios(USoundContext* context)
+{
+	(void)context;
+	return AtariSoundSetupDeinitXbios();
+}
+
+#else
+#error "usound.h >= 2 is installed: drop usound_compat.h and #include <usound.h> directly"
+#endif	/* !USOUND_VERSION */
+
+#endif	/* USOUND_COMPAT_H */




More information about the Scummvm-git-logs mailing list