mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-21 12:18:28 +00:00
Added SDL_HINT_AUDIO_DUMMY_TIMESCALE
This commit is contained in:
parent
5aa1a48ac3
commit
71574ac985
3 changed files with 38 additions and 20 deletions
|
@ -755,6 +755,23 @@ SDL_AddHintCallback() now returns a standard int result instead of void, returni
|
||||||
|
|
||||||
Calling SDL_GetHint() with the name of the hint being changed from within a hint callback will now return the new value rather than the old value. The old value is still passed as a parameter to the hint callback.
|
Calling SDL_GetHint() with the name of the hint being changed from within a hint callback will now return the new value rather than the old value. The old value is still passed as a parameter to the hint callback.
|
||||||
|
|
||||||
|
The environment variables SDL_VIDEODRIVER and SDL_AUDIODRIVER have been renamed to SDL_VIDEO_DRIVER and SDL_AUDIO_DRIVER.
|
||||||
|
|
||||||
|
The environment variables SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS have been removed and replaced by either using the appindentifier param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_IDENTIFIER_STRING with SDL_SetAppMetadataProperty()
|
||||||
|
|
||||||
|
The following hints have been renamed:
|
||||||
|
* SDL_HINT_VIDEODRIVER => SDL_VIDEO_DRIVER
|
||||||
|
* SDL_HINT_AUDIODRIVER => SDL_HINT_AUDIO_DRIVER
|
||||||
|
* SDL_HINT_ALLOW_TOPMOST => SDL_HINT_WINDOW_ALLOW_TOPMOST
|
||||||
|
* SDL_HINT_DIRECTINPUT_ENABLED => SDL_HINT_JOYSTICK_DIRECTINPUT
|
||||||
|
* SDL_HINT_GDK_TEXTINPUT_DEFAULT => SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT
|
||||||
|
* SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE => SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE
|
||||||
|
* SDL_HINT_LINUX_DIGITAL_HATS => SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS
|
||||||
|
* SDL_HINT_LINUX_HAT_DEADZONES => SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES
|
||||||
|
* SDL_HINT_LINUX_JOYSTICK_CLASSIC => SDL_HINT_JOYSTICK_LINUX_CLASSIC
|
||||||
|
* SDL_HINT_LINUX_JOYSTICK_DEADZONES => SDL_HINT_JOYSTICK_LINUX_DEADZONES
|
||||||
|
* SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP => SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE
|
||||||
|
|
||||||
The following hints have been removed:
|
The following hints have been removed:
|
||||||
* SDL_HINT_ACCELEROMETER_AS_JOYSTICK
|
* SDL_HINT_ACCELEROMETER_AS_JOYSTICK
|
||||||
* SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO - the audio will be paused when the application is paused, and SDL_HINT_ANDROID_BLOCK_ON_PAUSE can be used to control that
|
* SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO - the audio will be paused when the application is paused, and SDL_HINT_ANDROID_BLOCK_ON_PAUSE can be used to control that
|
||||||
|
@ -784,20 +801,8 @@ The following hints have been removed:
|
||||||
* SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING
|
* SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING
|
||||||
* SDL_HINT_AUDIO_DEVICE_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_NAME_STRING with SDL_SetAppMetadataProperty()
|
* SDL_HINT_AUDIO_DEVICE_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_NAME_STRING with SDL_SetAppMetadataProperty()
|
||||||
|
|
||||||
* Renamed hints SDL_HINT_VIDEODRIVER and SDL_HINT_AUDIODRIVER to SDL_HINT_VIDEO_DRIVER and SDL_HINT_AUDIO_DRIVER
|
The following environment variables have been removed:
|
||||||
* Renamed environment variables SDL_VIDEODRIVER and SDL_AUDIODRIVER to SDL_VIDEO_DRIVER and SDL_AUDIO_DRIVER
|
* SDL_DUMMYAUDIODELAY - replaced with the hint SDL_HINT_AUDIO_DUMMY_TIMESCALE which allows scaling the audio time rather than specifying an absolute delay.
|
||||||
* The environment variables SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS have been removed and replaced by either using the appindentifier param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_IDENTIFIER_STRING with SDL_SetAppMetadataProperty()
|
|
||||||
|
|
||||||
The following hints have been renamed:
|
|
||||||
* SDL_HINT_ALLOW_TOPMOST => SDL_HINT_WINDOW_ALLOW_TOPMOST
|
|
||||||
* SDL_HINT_DIRECTINPUT_ENABLED => SDL_HINT_JOYSTICK_DIRECTINPUT
|
|
||||||
* SDL_HINT_GDK_TEXTINPUT_DEFAULT => SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT
|
|
||||||
* SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE => SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE
|
|
||||||
* SDL_HINT_LINUX_DIGITAL_HATS => SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS
|
|
||||||
* SDL_HINT_LINUX_HAT_DEADZONES => SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES
|
|
||||||
* SDL_HINT_LINUX_JOYSTICK_CLASSIC => SDL_HINT_JOYSTICK_LINUX_CLASSIC
|
|
||||||
* SDL_HINT_LINUX_JOYSTICK_DEADZONES => SDL_HINT_JOYSTICK_LINUX_DEADZONES
|
|
||||||
* SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP => SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE
|
|
||||||
|
|
||||||
The following functions have been removed:
|
The following functions have been removed:
|
||||||
* SDL_ClearHints() - replaced with SDL_ResetHints()
|
* SDL_ClearHints() - replaced with SDL_ResetHints()
|
||||||
|
|
|
@ -338,6 +338,17 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER"
|
#define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A variable controlling the audio rate when using the dummy audio driver.
|
||||||
|
*
|
||||||
|
* The dummy audio driver normally simulates real-time for the audio rate that was specified, but you can use this variable to adjust this rate higher or lower down to 0. The default value is "1.0".
|
||||||
|
*
|
||||||
|
* This hint should be set before an audio device is opened.
|
||||||
|
*
|
||||||
|
* \since This hint is available since SDL 3.0.0.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_AUDIO_DUMMY_TIMESCALE "SDL_AUDIO_DUMMY_TIMESCALE"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variable controlling the default audio format.
|
* A variable controlling the default audio format.
|
||||||
*
|
*
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#include "../SDL_sysaudio.h"
|
#include "../SDL_sysaudio.h"
|
||||||
#include "SDL_dummyaudio.h"
|
#include "SDL_dummyaudio.h"
|
||||||
|
|
||||||
// !!! FIXME: this should be an SDL hint, not an environment variable.
|
|
||||||
#define DUMMYENVR_IODELAY "SDL_DUMMYAUDIODELAY"
|
|
||||||
|
|
||||||
static int DUMMYAUDIO_WaitDevice(SDL_AudioDevice *device)
|
static int DUMMYAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
SDL_Delay(device->hidden->io_delay);
|
SDL_Delay(device->hidden->io_delay);
|
||||||
|
@ -36,8 +33,6 @@ static int DUMMYAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||||
|
|
||||||
static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const char *envr = SDL_getenv(DUMMYENVR_IODELAY);
|
|
||||||
|
|
||||||
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
|
||||||
if (!device->hidden) {
|
if (!device->hidden) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -50,8 +45,15 @@ static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device->hidden->io_delay = (Uint32) (envr ? SDL_atoi(envr) : ((device->sample_frames * 1000) / device->spec.freq));
|
device->hidden->io_delay = ((device->sample_frames * 1000) / device->spec.freq);
|
||||||
|
|
||||||
|
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DUMMY_TIMESCALE);
|
||||||
|
if (hint) {
|
||||||
|
double scale = SDL_atof(hint);
|
||||||
|
if (scale >= 0.0) {
|
||||||
|
device->hidden->io_delay = (Uint32)SDL_round(device->hidden->io_delay * scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0; // we're good; don't change reported device format.
|
return 0; // we're good; don't change reported device format.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue