src/audio


Log

Author Commit Date CI Message
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.
Frank Praznik d7ca855c 2021-03-02T09:33:11 audio: pipewire: Add missing static qualifiers to globals
Oschowa 84c44e01 2021-03-01T12:39:52 audio: pipewire: fix uninitialized variable warnings
Frank Praznik 7001b531 2021-02-27T12:53:08 audio: pipewire: Add vim format lines to files and fix indentation Increase indentation spacing from 2 to 4 to comply with style standards.
Frank Praznik 2fcba50e 2021-02-27T12:08:15 audio: pipewire: Code and comment cleanups Replace "magic numbers" with #defines, explain the requirements when using the userdata pointer in the node_object struct and a few other minor code and comment cleanups.
Frank Praznik 4eadd147 2021-02-25T14:00:23 audio: pipewire: Fix outdated comment
Frank Praznik cd56f1b3 2021-02-24T14:36:58 audio: pipewire: Use "rear" designation for rear channels Use the 'R' (rear) prefixed designations for the rear audio channels instead of 'S' (surround). Surround designated channels are only used in the 8 channel configuration.
Frank Praznik adc0a931 2021-02-24T14:08:08 audio: Move Pipewire bootstrap after Jack Move the Pipewire audio driver below others in the list so it won't be mistakenly initialized when it's not the system mixer.
Frank Praznik 21adec93 2021-02-24T12:02:54 audio: pipewire: Make enumeration structure and function names more descriptive Rename the add/remove/clear list functions and rename connected_device to io_node, as a sink/source node isn't necessarily a device.
Frank Praznik a07f5434 2021-02-21T13:24:20 audio: pipewire: Report default devices first Further refactor the device enumeration code to retrieve the default sink/source node IDs from the metadata node. Use the retrieved IDs to sort the device list so that the default devices are at the beginning and thus are the first reported to SDL.
Frank Praznik 9afd7570 2021-02-20T13:33:12 audio: pipewire: Always buffer source audio The latency of source nodes can change depending on the overall latency of the processing graph. Incoming audio must therefore always be buffered to ensure uninterrupted delivery. The SDL_AudioStream path was removed in the input callback as the only thing it was used for was buffering audio outside of Pipewire's min/max period sizes, and that case is now handled by the omnipresent buffer.
Frank Praznik 106dc009 2021-02-19T17:18:36 audio: pipewire: Pass proper parameter to user audio callback The audio callbacks should pass the callbackspec.userdata parameter to the callback, not spec.userdata Co-authored-by: Oschowa <Oschowa@web.de>
Frank Praznik f3ebbc06 2021-02-19T16:02:20 audio: pipewire: Retrieve the channel count and default sample rate for sinks/sources Extend device enumeration to retrieve the channel count and default sample rate for sink and source nodes. This required a fairly significant rework of the enumeration procedure as multiple callbacks are involved now. Sink/source nodes are tracked in a separate list during the enumeration process so they can be cleaned up if a device is removed before completion. These changes also simplify any future efforts that may be needed to retrieve additional configuration information from the nodes.
Frank Praznik 2f0b99a7 2021-02-13T11:56:05 audio: Add Pipewire playback/capture sink
Oschowa 08547adb 2021-02-20T09:28:03 pulseaudio: Add "zerocopy" playback path
Romain Roffé ef85ed93 2021-02-17T20:53:35 pulseaudio: Initialize fragsize to fix mic recording fragsize wasn't initialized, and it is used for recording. If the value was 0 or -1, pulseaudio configures it itself. But sometimes we can get a random (and large) value that makes pulseaudio give us large sample at a very low frequency. https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/pulse/def.h#L453 https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/v13.0/src/pulsecore/protocol-native.c#L409
Alon Zakai 20be1d63 2020-07-15T09:13:03 emscripten: Automatically resume audio contexts This uses the mechanism added in emscripten-core/emscripten#10843 which was applied to SDL1 and OpenAL. This adds the same for SDL2. This also reverts commit 865eaddffed50dbd13e6564c3f73902472cf74e8 which did something similar, but the new mechanism is more effective.
Jay Petacat f443a6fc 2021-02-11T02:05:02 Fix format string warnings for width-based integers The DJGPP compiler emits many warnings for conflicts between print format specifiers and argument types. To fix the warnings, I added `SDL_PRIx32` macros for use with `Sint32` and `Uint32` types. The macros alias those found in <inttypes.h> or fallback to a reasonable default. As an alternative, print arguments could be cast to plain old integers. I opted slightly for the current solution as it felt more technically correct, despite making the format strings more verbose.
Ozkan Sezer b852590b 2021-01-24T17:02:40 minor clean-up in SDL_os2audio.c
Ozkan Sezer 8f102589 2021-01-23T17:28:10 os2audio: changed backend name from MMOS2 to DART (like SDL-1.2)
Sam Lantinga 50ea3b77 2021-01-08T10:09:37 Fixed bug 5080 - SDL_netbsdaudio: Always use the device's preferred frequency Nia Alarie The NetBSD kernel's audio resampling code is much simpler and lower quality than libsamplerate. Presumably, if SDL always performs I/O on the audio device in its native frequency, we can avoid resampling audio in the kernel and let SDL do it with libsamplerate instead.
Ozkan Sezer 265a1cc9 2021-01-05T15:50:02 use WIN_StringToUTF8W instead of WIN_StringToUTF8 where needed (#2) cf. bug #5435. - SDL_wasapi_win32.c (GetWasapiDeviceName): pwszVal is WCHAR* - windows/SDL_sysfilesystem.c (SDL_GetBasePath, SDL_GetPrefPath) - windows/SDL_sysurl.c (SDL_SYS_OpenURL): wurl is WCHAR* - SDL_windowssensor.c (ConnectSensor): bstr_name is WCHAR* - windows/SDL_systhread.c (SDL_SYS_SetupThread): strw is WCHAR*
Ozkan Sezer ed39f2f3 2021-01-04T01:23:50 SDL_wasapi_win32.c (WASAPI_PlatformThreadInit): use L instead of TEXT() because AvSetMmThreadCharacteristicsW specifically accepts WCHAR* input cf. bug #5435.
Ozkan Sezer 01a2f276 2021-01-04T01:23:50 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Ozkan Sezer 8476df3e 2020-12-30T23:55:10 SDL_mixer.c: remove calls to non-existing m68k asm code.
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Ozkan Sezer 53b16679 2020-11-11T12:33:55 SIZE_MAX need not be defined in limits.h it can be in limits.h (windows) or stdint.h.
Ryan C. Gordon 1b8dee7c 2020-10-31T11:32:40 coreaudio: Remove unnecessary include of CoreServices.h
Ozkan Sezer a4040293 2020-10-25T10:10:02 os2: misc build fixes
Ozkan Sezer bfc80d83 2020-10-25T03:55:02 minor coding style cleanup
Ozkan Sezer a90f0400 2020-10-15T21:37:30 os2: a _lot_ of coding style cleanup, sot that they match the SDL style. also renamed the 'debug' macro to debug_os2: the former was dangerously a common name. the binary (dll) output is precisely the same as before.
Ozkan Sezer d2723875 2020-10-14T23:01:06 os2: integrate the port into main tree.
Ozkan Sezer 1d9cf23e 2020-10-14T23:01:05 os2: updated copyright dates for 2020. header guard fixes.
Ozkan Sezer a3d7913c 2020-10-14T23:01:05 SDL_os2audio.c (OS2_OpenDevice): change spec->samples assignment: Original code assigned MCIMixSetup.ulSamplesPerSec value to it, but it is just the freq... We now change spec->samples only either if it is 0 or we changed the frequency, by picking a default of ~46 ms at desired frequency (code taken from SDL_audio.c:prepare_audiospec()). With this, the crashes I have been experiencing are gone.