src/audio


Log

Author Commit Date CI Message
Pierre Wendling 6c536afd 2022-06-27T15:43:17 Fix C89 declaration for macOS modules. Since Clang 14, `-Wdeclaration-after-statement` is enforced on every standard.
Francisco Javier Trujillo Mata e4a80875 2022-06-24T16:43:20 Initial Audio driver
chalonverse 3b191580 2022-06-27T17:19:39 Windows GDK Support (#5830) * Added GDK * Simplfied checks in SDL_config_wingdk.h * Added testgdk sample * Added GDK readme * Fixed error in merge of SDL_windows.h * Additional GDK fixes * OpenWatcom should not export _SDL_GDKGetTaskQueue * Formatting fixes * Moved initialization code into SDL_GDKRunApp
Sam Lantinga abe38bca 2022-06-18T13:08:58 Support SDL_AUDIODRIVER set to "dsound", which was used by SDL 1.2 Fixes https://github.com/libsdl-org/SDL/issues/5818
Sam Lantinga adc68758 2022-06-17T10:22:28 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!) Closes https://github.com/libsdl-org/SDL/pull/5811
Ryan C. Gordon dc62fec5 2022-05-20T21:07:25 audio: Fix locking in backends that manage their own callback threads. Otherwise you might get a race where an app pauses the device, but the audio callback still manages to run after the pause is in place.
Pierre Wendling 501a4991 2022-05-05T18:44:32 Add clang-format on/off comments where necessary. Comments were added in places where INDENT-ON/OFF comments are. Places like stdlib's asm don't need it as clang-format doesn't try to indent it.
Cameron Cawley 0cca71a8 2022-05-18T22:12:05 Use SDLCALL for callbacks in public APIs
Ryan C. Gordon 29694869 2022-04-28T15:56:52 audio: Revert one of the resampler optimizations. This is the one that splits the "left wing" into two for loops to bubble out the conditional that decides if it should read from the left padding or the input buffer. I still believe the optimization is good, but the basic logic of it was incorrect, and needs to be reexamined and fixed before going back into revision control.
Ryan C. Gordon 5066910b 2022-04-10T13:44:01 audio: Make pregenerated resampler kaiser filter more precise.
Ryan C. Gordon 111c3add 2022-04-10T13:23:51 audio: Resampler optimizations. - Calculate `j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING` once per loop iteration since we use it multiple times. - Do the left-wing loop in two sections: while `srcframe < 0` and then the remaining calculations when `srcframe >= 0`. This bubbles a conditional out of every iteration of a tight loop, giving us a boost. We could _probably_ do this to the right-wing loop too, but it's less straightforward there. - The real win: Use floats instead of doubles. This almost doubles the speed of the entire function on Intel CPUs, and for embedded things without hardware-level support for doubles, the speedup is enormous. This in theory might reduce audio quality, though, and I had to put a check in place to avoid a division-by-zero that we avoided at higher precision, but this is likely to be worth keeping for at least the Sony PSP and other smaller platforms, if not everyone.
Ryan C. Gordon de019568 2022-04-09T23:43:57 audio: Prebake the resampler's kaiser table instead of doing it at runtime.
Ryan C. Gordon f6eb4b07 2022-04-26T13:14:15 pulseaudio: Feed audio data in response to write callbacks. Instead of waiting until the entire buffer from the SDL callback is ready to be accepted by PulseAudio, we use pa_stream_set_write_callback and feed some portion of the buffer as callbacks come in asking for more. This lets us remove the halving of the buffer size during device open, and also (hopefully) solves several strange hangs that happen in unusual circumstances. Fixes #4387 Fixes #2262
Sam Lantinga 9e264b92 2022-04-18T09:20:47 Certain audio drivers, like the RME "Pro" Audio driver, have resampling quality issues when using WASAPI. We'll use SDL's resampling algorithm so we have consistent quality between platforms and drivers. Fixes https://github.com/libsdl-org/SDL/issues/5538
Ryan C. Gordon c1336b21 2022-04-17T12:43:32 hints: Make SDL_VIDEODRIVER and SDL_AUDIODRIVER formal hints. They were just environment variables before. Fixes #5528.
Ryan C. Gordon 727eef70 2022-04-09T10:12:49 audio: SDL_ConvertStereoToMono_SSE3 missed an unaligned load.
Ivan Epifanov 178ac196 2022-03-29T23:48:08 Vita: add audio capture support
Connor Clark aec86ba8 2022-03-26T15:31:33 emscriptenaudio: proxy calls to main thread
Ryan C. Gordon 4fe7b2cb 2022-03-24T11:00:43 static analysis: Fixed several complaints from codechecker. There are still some pending Objective-C specific issues. Reference issue #4600.
Ivan Epifanov 0af2db6f 2022-03-23T19:04:29 Vita: support audio format fallback
Eddy Jansson 24ffcbd9 2022-03-20T17:23:34 audio: Set error message on dsp init failure. if SDL_EnumUnixAudioDevices() fails to find any devices, set an error message on the exit path. Without this, SDL_Init() could fail without any message available in SDL_GetError().
Sam Lantinga a485ffc3 2022-03-19T09:50:22 Fix "SDL_FALSE is not defined" runtime error for emscripten.
Christian Kündig fbbd0270 2022-03-18T23:10:19 Fix "SDL_TRUE is not defined" runtime error for emscripten.
pionere 01bfde45 2022-03-17T12:22:18 simplify SetDSerror - no need to keep the error in a static variable - always print the error code - reduce the required stack-size - reduce the number of snprintf calls (and code size)
pionere 2c6a9c51 2022-03-16T09:36:43 minor optimization (SDL_audiocvt.c)
Ozkan Sezer 5905696e 2022-03-15T23:10:04 SDL_audiocvt.c: minor cleanup.
Wohlstand 7c421fec 2022-03-14T05:55:41 SDL_audiocvt.c: Don't byteswap 8-bit streams Otherwise, this results an assert on big endian machines when attenpting to use SDL_LoadWAV_RW function to load 8-bit WAV files.
Wohlstand 08d27dfd 2022-02-22T15:27:30 SDL_openslES.c: Detect float support in runtime and use it Allow using of the float output type on newer Android devices, but keep PCM16 output on older Closes #5358
Frank Praznik 228db352 2022-02-08T13:29:40 audio: pipewire: Tidy up formatting
Frank Praznik 9da9e85c 2022-02-08T12:59:01 audio: pipewire: Reset all hotplug values and pointers on shutdown Ensure that all hotplug variables and pointers are reset to NULL or their original value when shutting down.
Frank Praznik 5b36a527 2022-02-08T12:30:28 audio: pipewire: Remove redundant locks The io_list_check_add() and io_list_remove() functions are only ever called from within the Pipewire thread loop, so the locks are redundant. io_list_sort() is called from within a lock in the device detection function, so those additional locks are redundant as well.
Frank Praznik 48b4d1c4 2022-02-08T12:20:52 audio: pipewire: Convert atomic hotplug conditional variables to SDL_bool The hotplug loop condition variables are always guarded by the loop mutex while the loop is running, so they don't need to be atomic.
Frank Praznik 53091e36 2022-02-02T12:30:34 audio: pipewire: Remove the hard upper bound on rates and buffer sizes Remove the hard upper limit of 8192 samples and instead use the buffer sizes provided by Pipewire to determine the size of the intermediate input buffer and whether double buffering is required for output streams. This allows for higher latency streams to potentially avoid double-buffering in the output case, and we can guarantee that the intermediate input buffer will always be large enough to handle whatever Pipewire may deliver. As the buffer size calculations occur in a callback in the Pipewire processing thread itself, the stream readiness check has been modified to wait on two distinct flags set when the buffers have been configured and when the stream is ready and running.
Frank Praznik 66866249 2022-02-02T11:09:02 audio: pipewire: Condition variable doesn't need to be atomic The condition variable is guarded by a mutex, so no need for it to be atomic.
Frank Praznik 0b34f180 2022-01-30T12:00:55 audio: pipewire: Don't double free properties on init failure The context and stream creation functions will destroy the passed properties object on failure, so no need to do it manually. The pw_properties_free() function pointer is no longer needed, so it can be removed.
pionere bf66720a 2022-01-08T12:22:28 fix mixing of U16 audio
pionere 905e2e22 2022-01-08T12:15:53 cleanup of SDL_MixAudioFormat
pionere a5c610b0 2022-01-08T12:28:02 revert 'Changed to use 0xFE instead of 0xFF for better sound quality.'
pionere a70bb259 2022-01-20T13:16:03 drop handle parameter of OpenDevice
pionere 47ddb04e 2022-01-20T12:31:02 cleanup/sync the main loop of *_OpenDevice functions to pick audio format II.
pionere 2eafe434 2022-01-20T12:18:59 cleanup/sync the main loop of *_OpenDevice functions to pick audio format
pionere 3939ef72 2022-01-19T17:23:53 cleanup SDL_GetAudioDeviceSpec - drop unnecessary hascapture check - call SDL_InvalidParamError and return -1 in case the index is out of range - do not zfill SDL_AudioSpec - adjust documentation to reflect the behavior
pionere 113109f8 2022-01-19T17:18:47 cleanup SDL_GetAudioDeviceName - drop unnecessary hascapture check - call SDL_InvalidParamError in case the index is out of range
pionere f91211eb 2022-01-19T14:51:42 cleanup WASAPI_PrepDevice - reorganize the loop which checks for the right wave-format - use the return value of UpdateAudioStream - ensure SetError is called in SDL_NewAudioStream
pionere c9e8d157 2022-01-19T12:59:35 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory II.
pionere 1043dd8c 2022-01-19T12:58:04 adjust handling of iscapture - drop iscapture parameter of OpenDevice - use SDL_bool for iscapture
pionere 60deadba 2022-01-17T17:22:30 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory
pionere ebdd5366 2022-01-17T16:26:02 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError
pionere 4a17612b 2022-01-17T12:04:32 get rid of BeginLoopIteration
pionere 0770c582 2022-01-17T11:48:26 get rid of PrepareToClose
Ryan C. Gordon e0236c02 2022-01-23T01:28:36 audio: Removed an unnecessary commented-out line.
pionere 0dda8a7f 2022-01-17T11:21:01 cleanup init functions of audio - use SDL_bool if possible - assume NULL/SDL_FALSE filled impl - skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
pionere 6fcfcc3d 2022-01-17T11:00:03 get rid of SkipMixerLock
Frank Praznik b3984df1 2022-01-19T13:14:54 audio: pipewire: Use client config files instead of module names Pipewire, as of 0.3.22, uses client config files to load modules instead of explicitly specifying them (PW_KEY_CONTEXT_PROFILE_MODULES is deprecated). Use the new method to load the realtime module to boost the audio thread priority.
Ryan C. Gordon 5d07c036 2022-01-09T08:13:34 psp: Force channels to stereo if user requested anything other than mono. Before it would only clamp to stereo if it also had to resample, which would fail if the app specified 44100Hz and surround sound.
Francisco Javier Trujillo Mata f3255df9 2021-11-17T23:50:41 Improve audio compatibility in PSP. Now it supports more formats and frequencies
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
e d0de4c62 2021-12-31T14:36:32 Android: fixes build NDK 21d
thfrwn 2b6b69fb 2021-12-12T10:08:11 fix assertion failure in sndio audio caused by the recent hotplugging support
Ozkan Sezer 9409642e 2021-12-07T21:24:24 fix some warnings from vita builds (missing includes) also some tidy-up to whitespace.
Ozkan Sezer 00014dc2 2021-12-07T18:47:10 fix some warnings from psp builds (missing includes.)
ALittleDruid 2f0edc29 2021-12-04T09:23:19 IAudioClient::SetEventHandle Parameter eventHandle Should not be NULL
Ryan C. Gordon d713a680 2021-11-25T22:32:40 pulseaudio: wait until at least 1/8th (!) of the mixbuffer is available. This is to workaround systems where we hang in playback because the buffer does not report the space for whatever reason. The system will instead block in PlayDevice, which always immediately follows WaitDevice in modern times so this works out, and it seems to keep the device moving forward. For a future revision, we are either going to clean this up more properly, or attempt to move to PulseAudio's pa_stream_set_write_callback() API, but this will do for SDL 2.0.18. Reference #4387 for discussion and further information.
Sylvain 2004aaf3 2021-11-22T16:54:17 SDL_wave: use SDL_free
Sylvain 155db97d 2021-11-22T16:48:13 Remove 'malloc' from comment
Sylvain 38cfe25b 2021-11-22T16:39:56 Remove 'malloc' from comment
Sylvain 8fb19d21 2021-11-22T16:29:24 Vita: unneeded include
Sylvain e702a4e5 2021-11-22T16:28:49 PSP: un needed include
Sylvain d31251b0 2021-11-21T22:30:48 use SDL's functions version inplace of libc version
Sylvain a0cb079a 2021-11-21T15:45:08 Fixed bug #4982 - Failed to open audio_device on OpenSLES / Android 5.x with freq 96khz+
Sylvain b6e8651a 2021-11-20T15:31:21 Audio 6.1 should be allowed now (see #4974)
Sylvain 5be8a221 2021-11-17T20:37:51 Add audio conversion from/to 61
Sylvain b649314d 2021-11-15T13:43:40 Add comment to audio clipping (see bug #4104)
Ozkan Sezer 5c067906 2021-11-15T00:55:04 wasapi: AvSetMmThreadCharacteristicsW takes an LPCWSTR param, not LPWSTR
Ozkan Sezer be7b663c 2021-11-14T02:30:56 audio/winmm/SDL_winmm.c (SetMMerror): constify.
Cameron Gutman c8061ed2 2021-11-13T10:33:37 alsa: Fix possible uninitialized string
Cameron Gutman 704edf63 2021-11-12T17:07:22 audio: Fix crash calling SDL_OpenAudio() after SDL_AudioInit() fails The SDL_WasInit() checks don't work when using SDL_AudioInit() directly, which is exactly what audio_initOpenCloseQuitAudio() in testautomation does.
Cameron Gutman 78013aee 2021-11-12T16:57:24 alsa: Fix use-after-free when reinitializing
Sam Lantinga c2dd50a9 2021-11-12T08:28:02 Fixed whitespace
Misa 3bf7994f 2021-09-27T14:38:12 Add and use `SDL_FALLTHROUGH` for fallthroughs Case fallthrough warnings can be suppressed using the __fallthrough__ compiler attribute. Unfortunately, not all compilers have this attribute, or even have __has_attribute to check if they have the __fallthrough__ attribute. [[fallthrough]] is also available in C++17 and the next C2x, but not everyone uses C++17 or C2x. So define the SDL_FALLTHROUGH macro to deal with those problems - if we are using C++17 or C2x, it expands to [[fallthrough]]; else if the compiler has __has_attribute and has the __fallthrough__ attribute, then it expands to __attribute__((__fallthrough__)); else it expands to an empty statement, with a /* fallthrough */ comment (it's a do {} while (0) statement, because users of this macro need to use a semicolon, because [[fallthrough]] and __attribute__((__fallthrough__)) require a semicolon). Clang before Clang 10 and GCC before GCC 7 have problems with using __attribute__ as a sole statement and warn about a "declaration not declaring anything", so fall back to using the /* fallthrough */ comment if we are using those older compiler versions. Applications using SDL are also free to use this macro (because it is defined in begin_code.h). All existing /* fallthrough */ comments have been replaced with this macro. Some of them were unnecessary because they were the last case in a switch; using SDL_FALLTHROUGH in those cases would result in a compile error on compilers that support __fallthrough__, for having a __attribute__((__fallthrough__)) statement that didn't immediately precede a case label.
Sam Lantinga abc12a83 2021-11-11T15:58:44 Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs" This reverts commit 66a08aa3914a98667f212e79b4f0b9453203d656. This causes problems with older compilers: https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
Misa 66a08aa3 2021-09-27T14:38:12 Add and use `SDL_FALLTHROUGH` for fallthroughs Case fallthrough warnings can be suppressed using the __fallthrough__ compiler attribute. Unfortunately, not all compilers have this attribute, or even have __has_attribute to check if they have the __fallthrough__ attribute. [[fallthrough]] is also available in C++17 and the next C2x, but not everyone uses C++17 or C2x. So define the SDL_FALLTHROUGH macro to deal with those problems - if we are using C++17 or C2x, it expands to [[fallthrough]]; else if the compiler has __has_attribute and has the __fallthrough__ attribute, then it expands to __attribute__((__fallthrough__)); else it expands to an empty statement, with a /* fallthrough */ comment (it's a do {} while (0) statement, because users of this macro need to use a semicolon, because [[fallthrough]] and __attribute__((__fallthrough__)) require a semicolon). Applications using SDL are also free to use this macro (because it is defined in begin_code.h). All existing /* fallthrough */ comments have been replaced with this macro. Some of them were unnecessary because they were the last case in a switch; using SDL_FALLTHROUGH in those cases would result in a compile error on compilers that support __fallthrough__, for having a __attribute__((__fallthrough__)) statement that didn't immediately precede a case label.
Sam Lantinga 6d5edfa7 2021-11-02T15:59:26 Fixed crash on Android 8, due to bugs in AAudio implementation
Cameron Gutman c97c4687 2021-10-30T15:56:54 core: Convert SDL_IOReady()'s 2nd parameter to flags
Ryan C. Gordon 8a4a282a 2021-10-30T16:02:12 alsa: Make hotplug thread optional. Even without the thread, it'll do an initial hardware detection at startup, but there won't be any further hotplug events after that. But for many cases, that is likely complete sufficient. In either case, this cleaned up the code to no longer need a semaphore at startup. Fixes #4862.
Sylvain 072e3fdf 2021-10-14T23:17:08 Fixed bug #4534: NEON implementation of Convert51ToStereo (Thanks Ryan!)
Sam Lantinga 2423c514 2021-10-13T09:33:51 Work around hang in AAudioStream_write() during extended shared object loading while running in a debugger. Observed on a OnePlus 8T (KB2005) running Oxygen OS 11.0.10.10.KB05AA. The observed behavior is that any nonzero timeout value would hang until the device was paused and resumed. And a zero timeout value would always return 0 frames written even when audio fragments could be heard. Making a manual timeout system unworkable. None of the straightforward systems imply that there's a detectable problem before the call to AAudioStream_write(). And the callback set within AAudioStreamBuilder_setErrorCallback() does not get called as we enter the hang state. I've found that AAudioStream_getTimestamp() will report an error state from another thread. So this change codifies that behavior a bit until a better fix or more root cause can be found.
Ozkan Sezer e92a639b 2021-10-04T23:00:28 replaced many uses of libc calls with SDL_ counterparts in os2 sources. TODO: core/os2 and geniconv sources _must_ be updated, as well..
Sam Lantinga 345c161f 2021-09-22T09:06:45 Fixed some accidental uses of external C runtime functions
Ryan C. Gordon ce11caa8 2021-09-21T16:41:29 alsa: Map 7.1 audio channels to match what Windows and macOS expect. This matches what we did a long time ago for 5.1 audio. Fixes #55. (FIFTY FIVE. Bug reported 15 years, 3 months, and 11 days ago! lol)
Ryan C. Gordon c45facf2 2021-09-21T11:13:46 alsa: clean up macro salsa a little.
Sam Lantinga bf97c5a2 2021-09-08T14:47:40 Make sure SDL file descriptors don't leak into child processes
David Gow a1ffeda0 2021-08-28T22:52:13 Add SDL_HINT_APP_NAME and DBUS inhibition hint See SDL bug #4703. This implements two new hints: - SDL_APP_NAME - SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME The former is the successor to SDL_HINT_AUDIO_DEVICE_APP_NAME, and acts as a generic "application name" used both by audio drivers and DBUS screensaver inhibition. If SDL_AUDIO_DEVICE_APP_NAME is set, it will still take priority over SDL_APP_NAME. The second allows the "activity name" used by org.freedesktop.ScreenSavver's Inhibit method, which are often shown in the UI as the reason the screensaver (and/or suspend/other power-managment features) are disabled.
Lee Salzman 7d90df0e 2021-08-29T15:24:23 Restore previous behavior of empty SDL_AUDIODRIVER trying all drivers. The recent change to make SDL_AUDIODRIVER support comma-separated lists broke the previous behavior where an SDL_AUDIODRIVER that was empty behaved the same as if it was not set at all. This old behavior was necessary to paper over differences in platforms where SDL_setenv may or may not actually delete the env var if an empty string is specified. This patch just adds a simple check to ensure SDL_AUDIODRIVER is not empty before using it, restoring the old interpretation of the empty var.
David Gow 3261f7f6 2021-08-26T16:15:30 audio: Support "pulse" as an alias for "pulseaudio" Originally, SDL 1.2 used "pulse" as the name for its PulseAudio driver. While it now supports "pulseaudio" as well for compatibility with SDL 2.0 [1], there are still scripts and distro packages which set SDL_AUDIODRIVER=pulse [2]. While it's possible to remove this in most circumstances or replace it with "pulseaudio" or a comma-separated list, this may still conflict if the environment variable is set globally and old binary builds of SDL 1.2 (e.g. packaged with older games) are being used. To fix this on SDL 2.0, add a hardcoded check for "pulse" as an audio driver name, and replace it with "pulseaudio". This mimics what SDL 1.2 does (but in reverse). Note that setting driver_attempt{,_len} is safe here as they're reset correctly based on driver_attempt_end on the next loop. [1] https://github.com/libsdl-org/SDL-1.2/commit/d9514097846381cd30fe08df65dbdd48de92a058 [2] https://bugzilla.opensuse.org/show_bug.cgi?id=1189778
Ryan C. Gordon 9504bb12 2021-08-23T00:47:25 pulseaudio: Fix some function signatures that expect const pointers. This might have changed at some point in the Pulse API, or this might have always been wrong, but we didn't notice because the dynamic loading code hides it by casting things to void *. The static path, where it assigns the function pointer directly, puts out a clear compiler warning, though.
Oschowa 70c23b25 2021-08-18T13:18:11 audio: pipewire: Reset hotplug atomic variables on deinit.
Oschowa bfa15931 2021-08-18T12:04:38 audio: pipewire: Set PW_KEY_NODE_RATE to suggest a rate. This can be used by recent pipewire to avoid resampling.
Charlie Birks 07a2d71e 2021-03-30T11:56:38 emscripten: Feed silence to device when paused
Joshua Root 1e921352 2021-08-13T07:58:48 Improve portability of SDL_Convert51ToStereo_AVX Don't rely on checking __clang_major__ since it is not comparable between different vendors. Don't use "#pragma clang attribute" since it is only available in relatively recent versions, there's no obvious way to check if it's supported, and just using __attribute__ directly (for gcc as well) results in simpler code anyway.