src/audio


Log

Author Commit Date CI Message
pionere bf66720a 2022-01-08T12:22:28 fix mixing of U16 audio
pionere 905e2e22 2022-01-08T12:15:53 cleanup of SDL_MixAudioFormat
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.
Ozkan Sezer ed6eb07e 2021-08-12T01:40:50 SDL_wasapi.c: fixed build against older SDKs.
Ozkan Sezer 44a76710 2021-08-11T12:55:50 Don't disable clang avx instrinsics on win32 if __AVX__ is defined. C.f.: https://github.com/libsdl-org/SDL/issues/4533
Sam Lantinga ac32c522 2021-08-10T18:11:09 Try using the built-in WASAPI audio rate conversion Fixes https://github.com/libsdl-org/SDL/issues/4608
Sam Lantinga a0af7ce7 2021-08-10T15:05:49 OSS is no longer the preferred audio backend on modern UNIX systems Fixes https://github.com/libsdl-org/SDL/issues/4207
Sebastian Krzyszkowiak 25f9ed87 2021-08-10T13:10:36 audio: Fix false positives in driver name comparison Without this change, driver names don't get matched correctly; for example "a" can get matched with "alsa" since it only checks whether the string matches up to the length of the requested driver name.
Sam Lantinga bec78357 2021-08-06T14:20:55 Better fix for compiling using clang on Windows This fixes https://github.com/libsdl-org/SDL/issues/4533
Sam Lantinga cae7bd9b 2021-08-06T12:01:24 Don't use AVX with clang if the compiler isn't building with AVX instructions Fixes https://github.com/libsdl-org/SDL/issues/4533
Ryan C. Gordon 659e1f0a 2021-07-29T17:49:52 audiocvt: The to-5.1 converters now soften FL and FR channels more. This is experimental and might be tweaked further. Reference #4104. Also reference: https://github.com/Keriew/augustus/issues/194#issuecomment-847655049
Jessica Clarke 8f38ba4d 2021-07-29T18:02:47 Fix casts that should be using uintptr_t This is needed to support CHERI, and thus Arm's experimental Morello prototype, where pointers are implemented using unforgeable capabilities that include bounds and permissions metadata to provide fine-grained spatial and referential memory safety, as well as revocation by sweeping memory to provide heap temporal memory safety. On most systems (anything with a flat memory hierarchy rather than using segment-based addressing), size_t and uintptr_t are the same type. However, on CHERI, size_t is just an integer offset, whereas uintptr_t is still a capability as described above. Casting a pointer to size_t will strip the metadata and validity tag, and casting from size_t to a pointer will result in a null-derived capability whose validity tag is not set, and thus cannot be dereferenced without faulting. The audio and cursor casts were harmless as they intend to stuff an integer into a pointer, but using uintptr_t is the idiomatic way to do that and silences our compiler warnings (which our build tool makes fatal by default as they often indicate real problems). The iconv and egl casts were true positives as SDL_iconv_t and iconv_t are pointer types, as is NativeDisplayType on most OSes, so this would have trapped at run time when using the round-tripped pointers. The gles2 casts were also harmless; the OpenGL API defines this argument to be a pointer type (and uses the argument name "pointer"), but it in fact represents an integer offset, so like audio and cursor the additional idiomatic cast is needed to silence the warning.
Brick 53987e9b 2021-07-28T21:03:42 Optimized SDL_Convert51ToStereo_AVX
Ozkan Sezer cf85710c 2021-07-28T22:55:10 SDL_audiocvt.c: disable AVX for clang < 5 and gcc < 4.9 See: https://github.com/libsdl-org/SDL/issues/4533
Splamy c72aef26 2021-05-01T23:56:23 Fixed microphone randomly stop working WASAPI_WaitDevice is used for audio playback and capture, but needs to behave slighty different. For playback `GetCurrentPadding` returns the padding which is already queued, so WaitDevice should return when buffer length falls below the buffer threshold (`maxpadding`). For capture `GetCurrentPadding` returns the available data which can be read, so WaitDevice can return as soon as any data is available. In the old implementation WaitDevice could suddenly hang. This is because on many capture devices the buffer (`padding`) wasn't filled fast enough to surpass `maxpadding`. But if at one point (due to unlucky timing) more than maxpadding frames were available, WaitDevice would not return anymore. Issue #3234 is probably related to this.
Ryan C. Gordon 4ef8674d 2021-07-27T14:18:44 Revert "wasapi: Open capture devices the way we used to." This reverts commit 0d0fee7569803ddc41985bfc249418b02dd8cd97.
Ryan C. Gordon 0d0fee75 2021-07-27T14:12:18 wasapi: Open capture devices the way we used to. This should work around the regression in #3234, since it basically reverts the problem change, but only for capture devices. Fixes #3234.
Ryan C. Gordon 736a424f 2021-07-27T13:12:57 pulseaudio: Optionally add "monitor" sources to device list. There's a new hint to enable this. Fixes #2917.
Ryan C. Gordon 8d790b10 2021-07-27T12:23:46 audiocvt: stereo-to-mono SSE3 now uses unaligned accesses. On modern CPUs, there's no penalty for using the unaligned instruction on aligned memory, but now it can vectorize unaligned data too, which even if it's not optimal, is still going to be faster than the scalar fallback. Fixes #4532.
Luis Cáceres 45de0a1d 2021-04-02T06:28:10 Support comma-separated lists in SDL_AUDIODRIVER
Joel Linn b2c8d3e9 2021-06-11T22:14:54 audiocvt: 5.1 to Stereo conversion utilizing AVX
Joel Linn 638befc1 2021-06-10T17:22:39 audiocvt: 5.1 to Stereo conversion utilizing SSE
Joel Linn db56526f 2021-06-10T13:07:27 audiocvt: Replace divisions Division is expensive and the compiler can not replace it themselves. Though we now we will be ok in terms of floating point edge behaviour.
Per Nyblom 86ee383f 2021-05-25T09:59:45 Removed duplicate SDL_AtomicGet()
Sam Lantinga db146e66 2021-05-25T10:34:04 Fixed warnings building with Visual Studio
Ozkan Sezer 58884e4c 2021-05-04T00:23:40 SDL_audiocvt.c: fixed MSVC double->float conversion warnings.
Sylvain 8ac0fb52 2021-04-29T09:29:02 OpenSLES: CloseDevice() is called at higher level, if OpenDevice() fails - explicit initialization of static variables
Sylvain fcbf19b7 2021-04-28T21:04:47 AAudio: make sure stream is not null to prevent crash in RequestStop (see #3710)
Sylvain f8695185 2021-04-27T11:07:51 Audio: normalize conversion Stereo to 5.1, Quad to 7.1, 5.1 to 7.1 (bug #4104)
Sylvain 21349901 2021-04-27T10:57:48 Audio: convert 5.1 to 7.1, use right-surround for r-front and r-back (see #4104)
Ivan Epifanov 058bbe02 2021-04-24T10:17:03 Set volume on device open
Sylvain f1fab24e 2021-04-15T21:00:00 AAudio: add bootstrap in SDL_audio.c
Sylvain 04b2f5f6 2021-04-15T20:54:58 Android: add AAudio back-end, with playback and capture (see #3710) https://developer.android.com/ndk/guides/audio/aaudio/aaudio
Sylvain 4118fe62 2021-04-15T20:52:43 Android: OpenSLES, explicitly initialise the global variable 'bqPlayerPlay', it may be read even if OpenSLES back-end hasn't been intialized
Ryan C. Gordon 0f4aba7b 2021-04-06T18:34:53 audio: Fixed assertion failure if trying to use dummy backend.
Ryan C. Gordon 64853b73 2021-04-06T18:34:17 audio: Changed a disk and dummy backends to use _this instead of this.
Ethan Lee 9d294f1f 2021-03-27T00:53:10 audio: Allow AudioStreamGet to return 0 in RunAudio. While we should normally expect _something_ from the stream based on the AudioStreamAvailable check, it's possible for a device change to flush the stream at an inconvenient time, causing this function to return 0. Thing is, this is harmless. Either data will be NULL and the result won't matter anyway, or the data buffer will be zeroed out and the output will just be silence for the brief moment that the device change is occurring. Both scenarios work themselves out, and testing on Windows shows that this behavior is safe.
Ethan Lee 9b7babf9 2021-03-27T00:47:54 wasapi: Remove assert added by 67e8522d
Frank Praznik 5f9effaa 2021-03-28T17:45:41 audio: pipewire: Block while waiting on stream state info Initializing streams, particularly capture streams, can take many milliseconds, which is a bit much for a busy wait. Use a blocking wait instead.
Frank Praznik 8deb4063 2021-03-28T17:22:59 audio: pipewire: Avoid redundant locking The pw_thread_loop already locks and unlocks the thread mutex at the start and end of each loop iteration, so these locks are unnecessary.
Frank Praznik 5bb2bbd4 2021-03-28T17:17:00 audio: pipewire: Don't use uninitialized variables in callbacks Some of the SDL_AudioDevice struct members aren't initialized until after returning from the OpenDevice function. Since Pipewire uses it's own processing threads, the callbacks can be entered before all members of SDL_AudioDevice are initialized, such as work_buffer, callbackspec and the processing stream, which creates a race condition. Don't use these members when in the paused state to avoid potentially using uninitialized values and memory.
Ryan C. Gordon e7e519a4 2021-03-17T13:04:05 dsp: Refuse to initialize if there aren't any Open Sound System devices. This prevents the dsp target from stealing the audio subsystem but not being able to produce sound, so other audio targets further down the list can make an attempt instead. Thanks to Frank Praznik who did a lot of the research on this problem!
Ryan C. Gordon b98b5adc 2021-03-15T10:21:36 wasapi: Don't use the system's resampler.
nia a5f3ea14 2021-03-10T09:36:46 netbsdaudio: Handle ioctls failing A user reported that the mpv video player hangs after attempting to set an unsupported number of channels with the SDL audio output, because it thinks it's successfully opened the device. This makes the failure graceful.
Frank Praznik 4fbd60b8 2021-03-09T12:22:48 audio: pipewire: Remove the nickname portion of sink/source names Removes the node nickname from sink/source nodes as it doesn't provide any useful information and names now match those used in Pulseaudio, so any stored configuration data will be compatible between the two audio backends.
Ivan Epifanov a4ddb175 2021-03-08T19:28:58 Formatting
Ivan Epifanov 7d89f09f 2020-12-18T14:28:09 ISO C90 fixes
Ivan Epifanov e7edb06e 2020-12-04T00:06:15 Audio fix
Ivan Epifanov 2d64e37e 2020-11-02T18:09:43 Initial rebase of xerpi's port
Cameron Cawley 391bb80b 2021-03-05T16:53:06 Replace duplicate functions and lstrlen/lstrcat with SDL string functions
Ethan Lee 67e8522d 2021-02-27T17:37:25 Add SDL_GetAudioDeviceSpec. This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
Ozkan Sezer ac8a3fda 2021-03-03T20:33:20 fix prepare_audiospec() possibly missing a bad SDL_AUDIO_CHANNELS env.
Frank Praznik 4de0c74a 2021-03-02T10:02:59 audio: pipewire: Add the application name to the stream properties
Frank Praznik 9ed01da7 2021-03-02T09:47:47 audio: pipewire: Constify and clarify period size calculations Constify the min/max period variables, use a #define for the base clock rate used in the calculations and note that changing the upper limit can have dire side effects as it's a hard limit in Pipewire.