From 2d7f8d7d51214b981d216e631f20ee1e74e7e8f8 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 5 Jan 2023 09:57:14 +0100
Subject: [PATCH] Remove legacy SDL_Audio functions that acts on device id == 1
---
docs/README-migration.md | 12 ++
include/SDL3/SDL_audio.h | 210 +-----------------------------
include/SDL3/SDL_test_common.h | 1 +
src/audio/SDL_audio.c | 72 ----------
src/dynapi/SDL_dynapi.sym | 7 -
src/dynapi/SDL_dynapi_overrides.h | 7 -
src/dynapi/SDL_dynapi_procs.h | 7 -
src/test/SDL_test_common.c | 3 +-
test/loopwavequeue.c | 18 ++-
test/testautomation_audio.c | 61 +++++----
10 files changed, 64 insertions(+), 334 deletions(-)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 6b1dfc55ab6e..d2839cc6d39a 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -58,6 +58,18 @@ The following functions have been renamed:
* SDL_FreeAudioStream() => SDL_DestroyAudioStream()
* SDL_NewAudioStream() => SDL_CreateAudioStream()
+
+The following functions have been removed:
+* SDL_OpenAudio()
+* SDL_CloseAudio()
+* SDL_PauseAudio()
+* SDL_GetAudioStatus()
+* SDL_LockAudio()
+* SDL_UnlockAudio()
+* SDL_MixAudio()
+
+Use the SDL_AudioDevice functions instead.
+
## SDL_cpuinfo.h
SDL_Has3DNow() has been removed; there is no replacement.
diff --git a/include/SDL3/SDL_audio.h b/include/SDL3/SDL_audio.h
index 169b3d763e15..cd4260c36b2b 100644
--- a/include/SDL3/SDL_audio.h
+++ b/include/SDL3/SDL_audio.h
@@ -166,7 +166,7 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
int len);
/**
- * The calculated values in this structure are calculated by SDL_OpenAudio().
+ * The calculated values in this structure are calculated by SDL_OpenAudioDevice().
*
* For multi-channel audio, the default SDL channel mapping is:
* 2: FL FR (stereo)
@@ -314,64 +314,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
*/
extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
-/**
- * This function is a legacy means of opening the audio device.
- *
- * This function remains for compatibility with SDL 1.2, but also because it's
- * slightly easier to use than the new functions in SDL 2.0. The new, more
- * powerful, and preferred way to do this is SDL_OpenAudioDevice().
- *
- * This function is roughly equivalent to:
- *
- * ```c
- * SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
- * ```
- *
- * With two notable exceptions:
- *
- * - If `obtained` is NULL, we use `desired` (and allow no changes), which
- * means desired will be modified to have the correct values for silence,
- * etc, and SDL will convert any differences between your app's specific
- * request and the hardware behind the scenes.
- * - The return value is always success or failure, and not a device ID, which
- * means you can only have one device open at a time with this function.
- *
- * \param desired an SDL_AudioSpec structure representing the desired output
- * format. Please refer to the SDL_OpenAudioDevice
- * documentation for details on how to prepare this structure.
- * \param obtained an SDL_AudioSpec structure filled in with the actual
- * parameters, or NULL.
- * \returns 0 if successful, placing the actual hardware parameters in the
- * structure pointed to by `obtained`.
- *
- * If `obtained` is NULL, the audio data passed to the callback
- * function will be guaranteed to be in the requested format, and
- * will be automatically converted to the actual hardware audio
- * format if necessary. If `obtained` is NULL, `desired` will have
- * fields modified.
- *
- * This function returns a negative error code on failure to open the
- * audio device or failure to set up the audio thread; call
- * SDL_GetError() for more information.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_CloseAudio
- * \sa SDL_LockAudio
- * \sa SDL_PauseAudio
- * \sa SDL_UnlockAudio
- */
-extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
- SDL_AudioSpec * obtained);
-
/**
* SDL Audio Device IDs.
- *
- * A successful call to SDL_OpenAudio() is always device id 1, and legacy
- * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
- * always returns devices >= 2 on success. The legacy calls are good both
- * for backwards compatibility and when you don't care about multiple,
- * specific, or capture devices.
*/
typedef Uint32 SDL_AudioDeviceID;
@@ -515,17 +459,8 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
/**
* Open a specific audio device.
*
- * SDL_OpenAudio(), unlike this function, always acts on device ID 1. As such,
- * this function will never return a 1 so as not to conflict with the legacy
- * function.
- *
- * Please note that SDL 2.0 before 2.0.5 did not support recording; as such,
- * this function would fail if `iscapture` was not zero. Starting with SDL
- * 2.0.5, recording is implemented and this value can be non-zero.
- *
- * Passing in a `device` name of NULL requests the most reasonable default
- * (and is equivalent to what SDL_OpenAudio() does to choose a device). The
- * `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
+ * Passing in a `device` name of NULL requests the most reasonable default.
+ * The `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
* some drivers allow arbitrary and driver-specific strings, such as a
* hostname/IP address for a remote audio server, or a filename in the
* diskaudio driver.
@@ -604,9 +539,9 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* \param iscapture non-zero to specify a device should be opened for
* recording, not playback
* \param desired an SDL_AudioSpec structure representing the desired output
- * format; see SDL_OpenAudio() for more information
+ * format
* \param obtained an SDL_AudioSpec structure filled in with the actual output
- * format; see SDL_OpenAudio() for more information
+ * format
* \param allowed_changes 0, or one or more flags OR'd together
* \returns a valid device ID that is > 0 on success or 0 on failure; call
* SDL_GetError() for more information.
@@ -619,7 +554,6 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* \sa SDL_CloseAudioDevice
* \sa SDL_GetAudioDeviceName
* \sa SDL_LockAudioDevice
- * \sa SDL_OpenAudio
* \sa SDL_PauseAudioDevice
* \sa SDL_UnlockAudioDevice
*/
@@ -645,26 +579,6 @@ typedef enum
SDL_AUDIO_PAUSED
} SDL_AudioStatus;
-/**
- * This function is a legacy means of querying the audio device.
- *
- * New programs might want to use SDL_GetAudioDeviceStatus() instead. This
- * function is equivalent to calling...
- *
- * ```c
- * SDL_GetAudioDeviceStatus(1);
- * ```
- *
- * ...and is only useful if you used the legacy SDL_OpenAudio() function.
- *
- * \returns the SDL_AudioStatus of the audio device opened by SDL_OpenAudio().
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetAudioDeviceStatus
- */
-extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
-
/**
* Use this function to get the current audio state of an audio device.
*
@@ -679,38 +593,6 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
/* @} *//* Audio State */
-/**
- * \name Pause audio functions
- *
- * These functions pause and unpause the audio callback processing.
- * They should be called with a parameter of 0 after opening the audio
- * device to start playing sound. This is so you can safely initialize
- * data for your callback function after opening the audio device.
- * Silence will be written to the audio device during the pause.
- */
-/* @{ */
-
-/**
- * This function is a legacy means of pausing the audio device.
- *
- * New programs might want to use SDL_PauseAudioDevice() instead. This
- * function is equivalent to calling...
- *
- * ```c
- * SDL_PauseAudioDevice(1, pause_on);
- * ```
- *
- * ...and is only useful if you used the legacy SDL_OpenAudio() function.
- *
- * \param pause_on non-zero to pause, 0 to unpause
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetAudioStatus
- * \sa SDL_PauseAudioDevice
- */
-extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
-
/**
* Use this function to pause and unpause audio playback on a specified
* device.
@@ -741,7 +623,6 @@ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
*/
extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
int pause_on);
-/* @} *//* Pause audio functions */
/**
* Load the audio data of a WAVE file into memory.
@@ -1060,31 +941,6 @@ extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
#define SDL_MIX_MAXVOLUME 128
-/**
- * This function is a legacy means of mixing audio.
- *
- * This function is equivalent to calling...
- *
- * ```c
- * SDL_MixAudioFormat(dst, src, format, len, volume);
- * ```
- *
- * ...where `format` is the obtained format of the audio device from the
- * legacy SDL_OpenAudio() function.
- *
- * \param dst the destination for the mixed audio
- * \param src the source audio buffer to be mixed
- * \param len the length of the audio buffer in bytes
- * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
- * for full audio volume
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_MixAudioFormat
- */
-extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
- Uint32 len, int volume);
-
/**
* Mix audio data in a specified format.
*
@@ -1295,26 +1151,6 @@ extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
*/
/* @{ */
-/**
- * This function is a legacy means of locking the audio device.
- *
- * New programs might want to use SDL_LockAudioDevice() instead. This function
- * is equivalent to calling...
- *
- * ```c
- * SDL_LockAudioDevice(1);
- * ```
- *
- * ...and is only useful if you used the legacy SDL_OpenAudio() function.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_LockAudioDevice
- * \sa SDL_UnlockAudio
- * \sa SDL_UnlockAudioDevice
- */
-extern DECLSPEC void SDLCALL SDL_LockAudio(void);
-
/**
* Use this function to lock out the audio callback function for a specified
* device.
@@ -1354,25 +1190,6 @@ extern DECLSPEC void SDLCALL SDL_LockAudio(void);
*/
extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
-/**
- * This function is a legacy means of unlocking the audio device.
- *
- * New programs might want to use SDL_UnlockAudioDevice() instead. This
- * function is equivalent to calling...
- *
- * ```c
- * SDL_UnlockAudioDevice(1);
- * ```
- *
- * ...and is only useful if you used the legacy SDL_OpenAudio() function.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_LockAudio
- * \sa SDL_UnlockAudioDevice
- */
-extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
-
/**
* Use this function to unlock the audio callback function for a specified
* device.
@@ -1388,23 +1205,6 @@ extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
/* @} *//* Audio lock functions */
-/**
- * This function is a legacy means of closing the audio device.
- *
- * This function is equivalent to calling...
- *
- * ```c
- * SDL_CloseAudioDevice(1);
- * ```
- *
- * ...and is only useful if you used the legacy SDL_OpenAudio() function.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_OpenAudio
- */
-extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
-
/**
* Use this function to shut down audio processing and close the audio device.
*
diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h
index de82bd5b440a..b0b82d227a08 100644
--- a/include/SDL3/SDL_test_common.h
+++ b/include/SDL3/SDL_test_common.h
@@ -92,6 +92,7 @@ typedef struct
/* Audio info */
const char *audiodriver;
SDL_AudioSpec audiospec;
+ SDL_AudioDeviceID audio_id;
/* GL settings */
int gl_red_size;
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index aee7d8420ec0..39232ae6814e 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1492,40 +1492,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
return device->id;
}
-int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
-{
- SDL_AudioDeviceID id = 0;
-
- /* Start up the audio driver, if necessary. This is legacy behaviour! */
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
- return -1;
- }
- }
-
- /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */
- if (open_devices[0] != NULL) {
- return SDL_SetError("Audio device is already opened");
- }
-
- if (obtained) {
- id = open_audio_device(NULL, 0, desired, obtained,
- SDL_AUDIO_ALLOW_ANY_CHANGE, 1);
- } else {
- SDL_AudioSpec _obtained;
- SDL_zero(_obtained);
- id = open_audio_device(NULL, 0, desired, &_obtained, 0, 1);
- /* On successful open, copy calculated values into 'desired'. */
- if (id > 0) {
- desired->size = _obtained.size;
- desired->silence = _obtained.silence;
- }
- }
-
- SDL_assert((id == 0) || (id == 1));
- return (id == 0) ? -1 : 0;
-}
-
SDL_AudioDeviceID
SDL_OpenAudioDevice(const char *device, int iscapture,
const SDL_AudioSpec *desired, SDL_AudioSpec *obtained,
@@ -1550,12 +1516,6 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
return status;
}
-SDL_AudioStatus
-SDL_GetAudioStatus(void)
-{
- return SDL_GetAudioDeviceStatus(1);
-}
-
void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
{
SDL_AudioDevice *device = get_audio_device(devid);
@@ -1566,11 +1526,6 @@ void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
}
}
-void SDL_PauseAudio(int pause_on)
-{
- SDL_PauseAudioDevice(1, pause_on);
-}
-
void SDL_LockAudioDevice(SDL_AudioDeviceID devid)
{
/* Obtain a lock on the mixing buffers */
@@ -1580,11 +1535,6 @@ void SDL_LockAudioDevice(SDL_AudioDeviceID devid)
}
}
-void SDL_LockAudio(void)
-{
- SDL_LockAudioDevice(1);
-}
-
void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
{
/* Obtain a lock on the mixing buffers */
@@ -1594,21 +1544,11 @@ void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
}
}
-void SDL_UnlockAudio(void)
-{
- SDL_UnlockAudioDevice(1);
-}
-
void SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
{
close_audio_device(get_audio_device(devid));
}
-void SDL_CloseAudio(void)
-{
- SDL_CloseAudioDevice(1);
-}
-
void SDL_QuitAudio(void)
{
SDL_AudioDeviceID i;
@@ -1710,15 +1650,3 @@ void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
spec->size *= spec->samples;
}
-/*
- * Moved here from SDL_mixer.c, since it relies on internals of an opened
- * audio device (and is deprecated, by the way!).
- */
-void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
-{
- /* Mix the user-level audio format */
- SDL_AudioDevice *device = get_audio_device(1);
- if (device != NULL) {
- SDL_MixAudioFormat(dst, src, device->callbackspec.format, len, volume);
- }
-}
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index f780c5c5fb0a..ba9584811533 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -38,7 +38,6 @@ SDL3_0.0.0 {
SDL_ClearError;
SDL_ClearHints;
SDL_ClearQueuedAudio;
- SDL_CloseAudio;
SDL_CloseAudioDevice;
SDL_CloseGamepad;
SDL_CloseJoystick;
@@ -150,7 +149,6 @@ SDL3_0.0.0 {
SDL_GetAudioDeviceSpec;
SDL_GetAudioDeviceStatus;
SDL_GetAudioDriver;
- SDL_GetAudioStatus;
SDL_GetAudioStreamAvailable;
SDL_GetAudioStreamData;
SDL_GetBasePath;
@@ -448,7 +446,6 @@ SDL3_0.0.0 {
SDL_LoadFunction;
SDL_LoadObject;
SDL_LoadWAV_RW;
- SDL_LockAudio;
SDL_LockAudioDevice;
SDL_LockJoysticks;
SDL_LockMutex;
@@ -480,7 +477,6 @@ SDL3_0.0.0 {
SDL_Metal_GetDrawableSize;
SDL_Metal_GetLayer;
SDL_MinimizeWindow;
- SDL_MixAudio;
SDL_MixAudioFormat;
SDL_MouseIsHaptic;
SDL_NumHaptics;
@@ -491,13 +487,11 @@ SDL3_0.0.0 {
SDL_OnApplicationWillEnterForeground;
SDL_OnApplicationWillResignActive;
SDL_OnApplicationWillTerminate;
- SDL_OpenAudio;
SDL_OpenAudioDevice;
SDL_OpenGamepad;
SDL_OpenJoystick;
SDL_OpenSensor;
SDL_OpenURL;
- SDL_PauseAudio;
SDL_PauseAudioDevice;
SDL_PeepEvents;
SDL_PollEvent;
@@ -665,7 +659,6 @@ SDL3_0.0.0 {
SDL_ThreadID;
SDL_TryLockMutex;
SDL_UnloadObject;
- SDL_UnlockAudio;
SDL_UnlockAudioDevice;
SDL_UnlockJoysticks;
SDL_UnlockMutex;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index b322d3822bd2..71e0719008f2 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -64,7 +64,6 @@
#define SDL_ClearError SDL_ClearError_REAL
#define SDL_ClearHints SDL_ClearHints_REAL
#define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
-#define SDL_CloseAudio SDL_CloseAudio_REAL
#define SDL_CloseAudioDevice SDL_CloseAudioDevice_REAL
#define SDL_CloseGamepad SDL_CloseGamepad_REAL
#define SDL_CloseJoystick SDL_CloseJoystick_REAL
@@ -176,7 +175,6 @@
#define SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec_REAL
#define SDL_GetAudioDeviceStatus SDL_GetAudioDeviceStatus_REAL
#define SDL_GetAudioDriver SDL_GetAudioDriver_REAL
-#define SDL_GetAudioStatus SDL_GetAudioStatus_REAL
#define SDL_GetAudioStreamAvailable SDL_GetAudioStreamAvailable_REAL
#define SDL_GetAudioStreamData SDL_GetAudioStreamData_REAL
#define SDL_GetBasePath SDL_GetBasePath_REAL
@@ -474,7 +472,6 @@
#define SDL_LoadFunction SDL_LoadFunction_REAL
#define SDL_LoadObject SDL_LoadObject_REAL
#define SDL_LoadWAV_RW SDL_LoadWAV_RW_REAL
-#define SDL_LockAudio SDL_LockAudio_REAL
#define SDL_LockAudioDevice SDL_LockAudioDevice_REAL
#define SDL_LockJoysticks SDL_LockJoysticks_REAL
#define SDL_LockMutex SDL_LockMutex_REAL
@@ -506,7 +503,6 @@
#define SDL_Metal_GetDrawableSize SDL_Metal_GetDrawableSize_REAL
#define SDL_Metal_GetLayer SDL_Metal_GetLayer_REAL
#define SDL_MinimizeWindow SDL_MinimizeWindow_REAL
-#define SDL_MixAudio SDL_MixAudio_REAL
#define SDL_MixAudioFormat SDL_MixAudioFormat_REAL
#define SDL_MouseIsHaptic SDL_MouseIsHaptic_REAL
#define SDL_NumHaptics SDL_NumHaptics_REAL
@@ -517,13 +513,11 @@
#define SDL_OnApplicationWillEnterForeground SDL_OnApplicationWillEnterForeground_REAL
#define SDL_OnApplicationWillResignActive SDL_OnApplicationWillResignActive_REAL
#define SDL_OnApplicationWillTerminate SDL_OnApplicationWillTerminate_REAL
-#define SDL_OpenAudio SDL_OpenAudio_REAL
#define SDL_OpenAudioDevice SDL_OpenAudioDevice_REAL
#define SDL_OpenGamepad SDL_OpenGamepad_REAL
#define SDL_OpenJoystick SDL_OpenJoystick_REAL
#define SDL_OpenSensor SDL_OpenSensor_REAL
#define SDL_OpenURL SDL_OpenURL_REAL
-#define SDL_PauseAudio SDL_PauseAudio_REAL
#define SDL_PauseAudioDevice SDL_PauseAudioDevice_REAL
#define SDL_PeepEvents SDL_PeepEvents_REAL
#define SDL_PollEvent SDL_PollEvent_REAL
@@ -691,7 +685,6 @@
#define SDL_ThreadID SDL_ThreadID_REAL
#define SDL_TryLockMutex SDL_TryLockMutex_REAL
#define SDL_UnloadObject SDL_UnloadObject_REAL
-#define SDL_UnlockAudio SDL_UnlockAudio_REAL
#define SDL_UnlockAudioDevice SDL_UnlockAudioDevice_REAL
#define SDL_UnlockJoysticks SDL_UnlockJoysticks_REAL
#define SDL_UnlockMutex SDL_UnlockMutex_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index ff3276eb7727..fb7c9f3d35cc 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -145,7 +145,6 @@ SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ClearError,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ClearHints,(void),(),)
SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
-SDL_DYNAPI_PROC(void,SDL_CloseAudio,(void),(),)
SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseGamepad,(SDL_Gamepad *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),)
@@ -250,7 +249,6 @@ SDL_DYNAPI_PROC(const char*,SDL_GetAudioDeviceName,(int a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceSpec,(int a, int b, SDL_AudioSpec *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_AudioStatus,SDL_GetAudioDeviceStatus,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetAudioDriver,(int a),(a),return)
-SDL_DYNAPI_PROC(SDL_AudioStatus,SDL_GetAudioStatus,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamAvailable,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamData,(SDL_AudioStream *a, void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return)
@@ -541,7 +539,6 @@ SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),r
SDL_DYNAPI_PROC(void*,SDL_LoadFunction,(void *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_AudioSpec*,SDL_LoadWAV_RW,(SDL_RWops *a, int b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(void,SDL_LockAudio,(void),(),)
SDL_DYNAPI_PROC(void,SDL_LockAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_LockJoysticks,(void),(),)
SDL_DYNAPI_PROC(int,SDL_LockMutex,(SDL_mutex *a),(a),return)
@@ -565,7 +562,6 @@ SDL_DYNAPI_PROC(void,SDL_Metal_DestroyView,(SDL_MetalView a),(a),)
SDL_DYNAPI_PROC(void,SDL_Metal_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),)
SDL_DYNAPI_PROC(void*,SDL_Metal_GetLayer,(SDL_MetalView a),(a),return)
SDL_DYNAPI_PROC(void,SDL_MinimizeWindow,(SDL_Window *a),(a),)
-SDL_DYNAPI_PROC(void,SDL_MixAudio,(Uint8 *a, const Uint8 *b, Uint32 c, int d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_MixAudioFormat,(Uint8 *a, const Uint8 *b, SDL_AudioFormat c, Uint32 d, int e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(int,SDL_MouseIsHaptic,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_NumHaptics,(void),(),return)
@@ -575,13 +571,11 @@ SDL_DYNAPI_PROC(void,SDL_OnApplicationDidReceiveMemoryWarning,(void),(),)
SDL_DYNAPI_PROC(void,SDL_OnApplicationWillEnterForeground,(void),(),)
SDL_DYNAPI_PROC(void,SDL_OnApplicationWillResignActive,(void),(),)
SDL_DYNAPI_PROC(void,SDL_OnApplicationWillTerminate,(void),(),)
-SDL_DYNAPI_PROC(int,SDL_OpenAudio,(SDL_AudioSpec *a, SDL_AudioSpec *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_OpenAudioDevice,(const char *a, int b, const SDL_AudioSpec *c, SDL_AudioSpec *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_OpenGamepad,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_OpenJoystick,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_Sensor*,SDL_OpenSensor,(SDL_SensorID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_OpenURL,(const char *a),(a),return)
-SDL_DYNAPI_PROC(void,SDL_PauseAudio,(int a),(a),)
SDL_DYNAPI_PROC(void,SDL_PauseAudioDevice,(SDL_AudioDeviceID a, int b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_PeepEvents,(SDL_Event *a, int b, SDL_eventaction c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_PollEvent,(SDL_Event *a),(a),return)
@@ -745,7 +739,6 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_TextInputShown,(void),(),return)
SDL_DYNAPI_PROC(SDL_threadID,SDL_ThreadID,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_TryLockMutex,(SDL_mutex *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_UnloadObject,(void *a),(a),)
-SDL_DYNAPI_PROC(void,SDL_UnlockAudio,(void),(),)
SDL_DYNAPI_PROC(void,SDL_UnlockAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),)
SDL_DYNAPI_PROC(int,SDL_UnlockMutex,(SDL_mutex *a),(a),return)
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index eccebf8e7ab8..88ec87d9a2d5 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1350,7 +1350,8 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_GetCurrentAudioDriver());
}
- if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
+ state->audio_id = SDL_OpenAudioDevice(NULL, 0, &state->audiospec, NULL, 0);
+ if (state->audio_id <= 0) {
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
return SDL_FALSE;
}
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 25fce1ec5002..6c1c6a475d41 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -48,19 +48,21 @@ void poked(int sig)
done = 1;
}
+static SDL_AudioDeviceID g_audio_id = 0;
+
void loop()
{
#ifdef __EMSCRIPTEN__
- if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) {
+ if (done || (SDL_GetAudioDeviceStatus(g_audio_id) != SDL_AUDIO_PLAYING)) {
emscripten_cancel_main_loop();
} else
#endif
{
/* The device from SDL_OpenAudio() is always device #1. */
- const Uint32 queued = SDL_GetQueuedAudioSize(1);
+ const Uint32 queued = SDL_GetQueuedAudioSize(g_audio_id);
SDL_Log("Device has %u bytes queued.\n", (unsigned int)queued);
if (queued <= 8192) { /* time to requeue the whole thing? */
- if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) {
+ if (SDL_QueueAudio(g_audio_id, wave.sound, wave.soundlen) == 0) {
SDL_Log("Device queued %u more bytes.\n", (unsigned int)wave.soundlen);
} else {
SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int)wave.soundlen, SDL_GetError());
@@ -110,7 +112,9 @@ int main(int argc, char *argv[])
#endif /* HAVE_SIGNAL_H */
/* Initialize fillerup() variables */
- if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
+ g_audio_id = SDL_OpenAudioDevice(NULL, 0, &wave.spec, NULL, 0);
+
+ if (g_audio_id <= 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_free(wave.sound);
quit(2);
@@ -119,7 +123,7 @@ int main(int argc, char *argv[])
/*static x[99999]; SDL_QueueAudio(1, x, sizeof (x));*/
/* Let the audio run */
- SDL_PauseAudio(0);
+ SDL_PauseAudioDevice(g_audio_id, 0);
done = 0;
@@ -130,7 +134,7 @@ int main(int argc, char *argv[])
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
- while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) {
+ while (!done && (SDL_GetAudioDeviceStatus(g_audio_id) == SDL_AUDIO_PLAYING)) {
loop();
SDL_Delay(100); /* let it play for awhile. */
@@ -138,7 +142,7 @@ int main(int argc, char *argv[])
#endif
/* Clean up on signal */
- SDL_CloseAudio();
+ SDL_CloseAudioDevice(g_audio_id);
SDL_free(wave.sound);
SDL_free(filename);
SDL_Quit();
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index bd35872ea868..c6d3df318f95 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -50,6 +50,8 @@ static void SDLCALL audio_testCallback(void *userdata, Uint8 *stream, int len)
g_audio_testCallbackLength += len;
}
+static SDL_AudioDeviceID g_audio_id = -1;
+
/* Test case functions */
/**
@@ -130,13 +132,13 @@ int audio_initQuitAudio()
* \brief Start, open, close and stop audio
*
* \sa https://wiki.libsdl.org/SDL_InitAudio
- * \sa https://wiki.libsdl.org/SDL_OpenAudio
- * \sa https://wiki.libsdl.org/SDL_CloseAudio
+ * \sa https://wiki.libsdl.org/SDL_OpenAudioDevice
+ * \sa https://wiki.libsdl.org/SDL_CloseAudioDevice
* \sa https://wiki.libsdl.org/SDL_QuitAudio
*/
int audio_initOpenCloseQuitAudio()
{
- int result, expectedResult;
+ int result;
int i, iMax, j, k;
const char *audioDriver;
SDL_AudioSpec desired;
@@ -189,16 +191,18 @@ int audio_initOpenCloseQuitAudio()
/* Call Open (maybe multiple times) */
for (k = 0; k <= j; k++) {
- result = SDL_OpenAudio(&desired, NULL);
- SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k + 1);
- expectedResult = (k == 0) ? 0 : -1;
- SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result);
+ result = SDL_OpenAudioDevice(NULL, 0, &desired, NULL, 0);
+ if (k == 0) {
+ g_audio_id = result;
+ }
+ SDLTest_AssertPass("Call to SDL_OpenAudioDevice(NULL, 0, desired_spec_%d, NULL, 0), call %d", j, k + 1);
+ SDLTest_AssertCheck(result > 0, "Verify return value; expected: > 0, got: %d", result);
}
/* Call Close (maybe multiple times) */
for (k = 0; k <= j; k++) {
- SDL_CloseAudio();
- SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k + 1);
+ SDL_CloseAudioDevice(g_audio_id);
+ SDLTest_AssertPass("Call to SDL_CloseAudioDevice(), call %d", k + 1);
}
/* Call Quit (maybe multiple times) */
@@ -219,7 +223,7 @@ int audio_initOpenCloseQuitAudio()
/**
* \brief Pause and unpause audio
*
- * \sa https://wiki.libsdl.org/SDL_PauseAudio
+ * \sa https://wiki.libsdl.org/SDL_PauseAudioDevice
*/
int audio_pauseUnpauseAudio()
{
@@ -278,9 +282,10 @@ int audio_pauseUnpauseAudio()
}
/* Call Open */
- result = SDL_OpenAudio(&desired, NULL);
- SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
- SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
+ g_audio_id = SDL_OpenAudioDevice(NULL, 0, &desired, NULL, 0);
+ result = g_audio_id;
+ SDLTest_AssertPass("Call to SDL_OpenAudioDevice(NULL, 0, desired_spec_%d, NULL, 0)", j);
+ SDLTest_AssertCheck(result > 0, "Verify return value; expected > 0 got: %d", result);
/* Start and stop audio multiple times */
for (l = 0; l < 3; l++) {
@@ -293,8 +298,8 @@ int audio_pauseUnpauseAudio()
/* Un-pause audio to start playing (maybe multiple times) */
pause_on = 0;
for (k = 0; k <= j; k++) {
- SDL_PauseAudio(pause_on);
- SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k + 1);
+ SDL_PauseAudioDevice(g_audio_id, pause_on);
+ SDLTest_AssertPass("Call to SDL_PauseAudioDevice(g_audio_id, %d), call %d", pause_on, k + 1);
}
/* Wait for callback */
@@ -309,8 +314,8 @@ int audio_pauseUnpauseAudio()
/* Pause audio to stop playing (maybe multiple times) */
for (k = 0; k <= j; k++) {
pause_on = (k == 0)
(Patch may be truncated, please check the link at the top of this post.)