src/audio


Log

Author Commit Date CI Message
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Markus Mittendrein 81452121 2022-11-27T22:46:54 SDL_ResampleAudio: Fix float accumulation error While 78f97108f9dad22db6708f28322561eb9828fc36 reduced the accumulation error, it was still big enough to cause distortions. Fixes #6196.
Sylvain 89572af6 2022-11-17T11:43:46 Fixed bug #6537 - AIX: use PAUDIO_WaitDevice
Sylvain ce5da5d5 2022-11-16T21:47:43 Don't compare pointer against '0', but NULL
ulatekh ec58a817 2022-10-05T19:26:09 Fixes made in response to running a static code analyzer under MS Windows. Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs. SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision. SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer. SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used. SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range. SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it. SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691). SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen. SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL. SDL_pixels.c: Looks like the switch is genuinely missing a break! SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons. SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
Ryan C. Gordon 6801d676 2022-11-16T09:52:33 Revert "pulseaudio: Only use PA_STREAM_ADJUST_LATENCY if buffer isn't super small." This reverts commit d8b1ef42aee52dad4ac3de69795ca2e8d2fd7704. This turned out to be unnecessary (it was a problem on the user's system, not an SDL bug). Reference Issue #6121.
Ryan C. Gordon d8b1ef42 2022-11-15T22:18:51 pulseaudio: Only use PA_STREAM_ADJUST_LATENCY if buffer isn't super small. Fixes #6121.
Ryan C. Gordon 85aa9b8b 2022-11-11T13:47:36 wasapi: Favor the system resampler again, for now. Reference Issue #5538.
Ryan C. Gordon b0dc6709 2022-11-07T14:26:48 coreaudio: Don't use deprecated kAudioObjectPropertyElementMaster symbol. Fixes #6449.
Hubert Maier 5dc93451 2022-11-06T20:49:37 JANITORIAL : Correct some more spelling mistakes (#6489)
Ryan C. Gordon 78f97108 2022-11-05T10:38:33 audio: Avoid accumulation errors in resampler. Fixes #6391.
Hubert Maier 61f3662c 2022-10-30T08:34:47 SDL_QSA_AUDIO.C: Correct spelling mistake occured -> occurred
Ryan C. Gordon e7ab581d 2022-10-19T09:14:16 coreaudio: Dispose of AudioQueue before waiting on the thread. Otherwise the thread might block for a long time (more than 10 seconds!). It's not clear to me why this happens, or why its safe to do this with a resource that's still in use, but we have, until recently, always disposed of the AudioQueue first, so changing back is probably okay. Also changed the disposal to allow in-flight buffers to reach hardware; otherwise you lose the last little bit of audio that's already been queued but not played, which you can hear clearly in the loopwave test program. Fixes #6377.
Brad Smith f4e3af15 2022-10-17T07:23:40 Simplify OSS test by removing OpenBSD specific location of the soundcard.h header OpenBSD has long since stopped using OSS. Remove checking for OpenBSD specific header.
Daniel Bomar 22461383 2022-10-15T15:54:12 SDL_audiocvt: Respct the SDL_HINT_AUDIO_RESAMPLING_MODE hint This implements using libsamplerate for the SDL_AudioCVT API. This library was already being used for audio streams when this hint is set.
Pierre Wendling 65527537 2021-03-30T04:32:39 N3DS port (squashed) A dedicated renderer using Citro3D would likely allow for better much better graphical performances.
Nicolas Cian 484d5fd6 2022-10-05T13:19:38 audio open: ensure 2 devices don't get the same id
daniel e41942e8 2022-10-05T13:36:25 fix compilation error SDL_coreaudio mixing declarations and code
Ryan C. Gordon e6640ef2 2022-09-30T14:53:07 coreaudio: Possibly fixed another shutdown race condition. Reference Issue #6159.
Jarod Hillman 40893821 2022-09-29T10:33:07 coreaudio: Add support for SDL_GetDefaultAudioInfo (#6277) Co-authored-by: Ethan Lee <flibitijibibo@gmail.com> Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
Ryan C. Gordon f6565c32 2022-09-28T09:27:45 coreaudio: Remove redundant variable.
Ryan C. Gordon 411582c7 2022-09-28T09:22:17 coreaudio: Don't crash on shutdown in a race condition. Fixed #6159.
Francisco Javier Trujillo Mata b9e3cae5 2022-08-26T16:58:21 Add more valid configurations to PS2 audio driver
Francisco Javier Trujillo Mata 5b4b4fa1 2022-08-14T12:01:56 Decrease audio thread priority when created
Mathieu Eyraud f1390780 2022-08-02T15:25:44 Fix use after free when removing Windows audio device
Ryan C. Gordon 8ff738f2 2022-07-26T12:40:47 audio: Report SDL_AUDIODEVICEREMOVED for unopened devices. Unopened devices, if removed, now send SDL_AUDIODEVICEREMOVED events with a `which` field set to zero. Apps can use this to decide if they need to refresh a list of devices being shown in an options menu, etc. It's safe to call SDL_CloseAudioDevice(0), so even if they try to clean up this bogus id, it should be safe. Fixes #5199.
Ozkan Sezer 8c51cae7 2022-07-23T14:56:04 audio/aaudio, audio/openslES: fix -Wdeclaration-after-statement errors Fixes https://github.com/libsdl-org/SDL/issues/5950
Ethan Lee f3008e4a 2022-07-20T19:08:31 audio: 3- and 5-channel formats are now supported
Ryan C. Gordon 45c3b59d 2022-07-20T17:23:42 audio: Turn off DEBUG_CONFIG logging again.
Ryan C. Gordon bec721f0 2022-07-20T17:22:41 audio: Fixed dst pointer on channel conversions that grow in-place.
Ryan C. Gordon 9f56c7cf 2022-07-20T16:39:19 audio: Remove 5.1->X SIMD converters, add SSE mono->stereo. The 5.1 versions didn't use the new algorithm, and making that new algorithm work took so many permutes that it was significantly slower than just using the scalar versions. However, mono-to-stereo is an extremely common conversion, and it's trivial to accelerate it with plain SSE, so that was added!
Ryan C. Gordon b83ae9f2 2022-07-19T22:40:51 audio: Replaced some debug-printfs with debug-SDL_Logs. :)
Ryan C. Gordon 49ec8db5 2022-07-19T22:04:49 audio: Generate the channel converter code from a program.
Ryan C. Gordon f06cc3e9 2022-07-19T22:03:56 audio: "SL" means "surround left" not "side left", etc.
Ryan C. Gordon 5a0c8198 2022-07-19T22:03:02 audio: Add channel convert filter _after_ choosing an SIMD version.
Ryan C. Gordon fe160840 2022-07-19T16:04:48 audio: LOG_DEBUG_CONVERT should use SDL_Log, not fprintf(stderr).
Ryan C. Gordon 25727790 2022-07-19T02:16:08 audio: first attempt at rewriting the channel converters. This is not ready for production use!
Ozkan Sezer b700a326 2022-07-20T07:01:10 audio, pipewire: fix signatures of pw_get_library_version and pw_init. Reference issue: https://github.com/libsdl-org/SDL/issues/5938
Ozkan Sezer 6e210d37 2022-07-20T07:01:10 audio, pipewire: pipewire_version_xx globals out of dynamic loading Fixes build with --disable-pipewire-shared Reference issue: https://github.com/libsdl-org/SDL/issues/5938
Sam Lantinga b299cb3d 2022-07-17T08:31:16 Added a utility function to calculate the next power of 2 for a value
Ethan Lee 90b86b13 2022-07-17T10:35:09 audio: Handle non-power-of-two spec.samples when unsupported Fixes #3685
Ethan Lee a09d62e4 2022-07-15T23:45:56 directsound: Remove redundant SubFormat copy
Ethan Lee c5e408ae 2022-07-15T11:31:59 directsound: For channel counts > 2, generate a dwChannelMask for CreateSoundBuffer
Ethan Lee fff34f63 2022-07-15T09:46:53 windows: SDL_IMMDevice needed more deinit code from the Win32 path. Fixes #5919
Frank Praznik 37aecda2 2022-07-14T11:38:51 pipewire: Use PW_KEY_TARGET_OBJECT to specify stream connection nodes Pipewire 0.3.44 introduced PW_KEY_TARGET_OBJECT, which is to be used to specify target connection nodes for streams. This parameter takes either a node path (PW_KEY_NODE_NAME) or serial number (PW_KEY_OBJECT_SERIAL) to specify a target node. The former is used in this case since the path is already being retrieved and stored for other purposes. The target_id parameter in pw_stream_connect() is now deprecated and should always be PW_ID_ANY when PW_KEY_TARGET_OBJECT is used.
Frank Praznik 36d8460c 2022-07-11T16:59:23 pipewire: Dynamically allocate the buffer for node strings Calculate and allocate the buffer for the IO node name and path strings dynamically instead of using arbitrary sized static buffers.
Frank Praznik 996cea31 2022-07-11T15:15:48 pipewire: Update default audio devices during runtime Make the default device metadata node persist for the lifetime of the hotplug loop so the default source/sink devices will be updated if they change during runtime.
Frank Praznik 60da11f0 2022-07-11T14:31:20 pipewire: Remove deprecated configuration key With Pipewire now requiring a minimum version 0.3.24, the PW_KEY_CONTEXT_PROFILE_MODULES value is no longer required for legacy compatability and can be safely removed.
Ethan Lee ecfbdce6 2022-07-11T13:09:48 pipewire: Require version 0.3.24 or newer at runtime
Ethan Lee 2f0816ad 2022-07-11T13:08:30 Add SDL_GetDefaultAudioInfo. This API is supported on pipewire, pulseaudio, wasapi, and directsound. Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
Ethan Lee ae105ae1 2022-07-10T12:59:33 windows: Move IMMDevice work to common file, implement DirectSound enumeration support
285424336 4aad594a 2022-07-08T16:17:46 Update SDL_qsa_audio.c Fix qnx platform compile error, change SDL_Bool to SDL_bool.
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 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