src/audio/alsa


Log

Author Commit Date CI Message
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.
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.
Ethan Lee 67e8522d 2021-02-27T17:37:25 Add SDL_GetAudioDeviceSpec. This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
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.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sylvain Becker 60d3965e 2019-10-30T15:36:17 Readability: remove redundant return, continue, enum declaration
Sylvain Becker b458d7a2 2019-10-30T15:13:55 Readability: remove redundant cast to the same type
Sam Lantinga 680e7937 2019-07-07T09:10:56 Fixed bug 4710 - audio/alsa: avoid configuring hardware parameters with only a single period Anthony Pesch The previous code first configured the period size using snd_pcm_hw_par- ams_set_period_size_near. Then, it further narrowed the configuration space by calling snd_pcm_hw_params_set_buffer_size_near using a buffer size of 2 times the _requested_ period size in order to try and get a configuration with only 2 periods. If the configured period size was larger than the requested size, the second call could inadvertently narrow the configuration space to contain only a single period. Rather than fixing the call to snd_pcm_hw_params_set_buffer_size_near to use a size of 2 times the configured period size, the code has been changed to use snd_pcm_hw_params_set_periods_min in order to more clearly explain the intent.
Sam Lantinga 35255342 2019-03-16T18:48:21 Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return value check Anthony Pesch Fix snd_device_name_hint return value check According to the ALSA documentation, snd_device_name_hint returns 0 on success, otherwise a negative error code. The code previously only considered -1 to be an error, which let other error codes through resulting in a segfault when hints (which was NULL) was dereferenced
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Ryan C. Gordon 623a6def 2018-08-07T16:49:18 alsa: optionally run entire pipeline non-blocking.
Anthony Pesch c5914295 2018-05-04T21:21:32 alsa: avoid hardware parameters with an excessive number of periods. The previous code attempted to use set_buffer_size / set_period_size discretely, favoring the parameters which generated a buffer size that was exactly 2x the requested buffer size. This solution ultimately prioritizes only the buffer size, which comes at a large performance cost on some machines where this results in an excessive number of periods. In my case, for a 4096 sample buffer, this configured the device to use 37 periods with a period size of 221 samples and a buffer size of 8192 samples. With 37 periods, the SDL Audio thread was consuming 25% of the CPU. This code has been refactored to use set_period_size and set_buffer_size together. set_period_size is called first to attempt to set the period to exactly match the requested buffer size, and set_buffer_size is called second to further refine the parameters to attempt to use only 2 periods. The fundamental change here is that the period size / count won't go to extreme values if the buffer size can't be exactly matched, the buffer size should instead just increase to the next closest multiple of the target period size that is supported. After changing this, for a 4096 sample buffer, the device is configured to use 3 periods with a period size of 4096 samples and a buffer size of 12288 samples. With only 3 periods, the SDL Audio thread doesn't even show up when profiling. Fixes Bugzilla #4156.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Ryan C. Gordon 93583d46 2017-09-09T21:17:46 alsa: removed snd_pcm_wait() call before writing to playback device. This would cause playback problems in certain situations, such as on the Raspberry Pi. The device that the wait was added for seems to not benefit from it in modern times, and standard desktop Linux seems to do the right thing when a USB device is unplugged now, without this patch. Fixes Bugzilla #3599.
Philipp Wiesemann 3639895e 2017-05-27T23:30:07 Removed unused errno includes.
Sam Lantinga 6814f5db 2017-03-14T07:20:14 ALSA driver improvements: * alsa hotplug thread is low priority * give a chance for other threads to catch up when audio playback is not progressing * use nonblocking for alsa audio capture There is a bug with SDL hanging when an audio capture USB device is removed, because poll never returns
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 36156335 2016-11-20T21:34:54 Renaming of guard header names to quiet -Wreserved-id-macro Patch contributed by Sylvain
Philipp Wiesemann 7ad3a46d 2016-11-05T21:23:17 ALSA: Fixed compile warning about unused function. Found by buildbot.
Sam Lantinga 88f2d16e 2016-10-28T17:00:37 Fixed compiling on older versions of ALSA
Sam Lantinga fdcac1c2 2016-10-28T16:47:06 Fixed audio data swizzling when the device channel map already matches what SDL expects
Sam Lantinga 62310c6b 2016-10-12T22:25:19 Work-around for a hang when USB devices are unplugged, contributed by James Zipperer
Sam Lantinga fed9b604 2016-10-10T23:26:26 Use SDL C runtime strlen()
Ryan C. Gordon ca42373f 2016-10-10T15:29:18 alsa: more tapdancing to enumerate physical hardware devices. Apparently some systems see "hw:", some see "default:" and some see "sysdefault:" (and maybe others!). My workstation sees both "hw:" and "sysdefault:" ... Try to find a prefix we like and prioritize the prefixes we (think) we want most. If everything else fails, if there's a "default" (not a prefix) device name, list that by itself so the user gets _something_ here. If we can't find a prefix we like _and_ there's no "default" device, report no hardware found at all.
Sam Lantinga 52ae92ea 2016-10-07T19:08:22 ALSA_snd_pcm_drop() can hang on some systems (Steam Link) so don't use that when shutting down the ALSA audio driver.
Sam Lantinga 3b0c7936 2016-10-07T11:18:55 Some systems include both "default:" and "hw:" for the same usb device
Sam Lantinga 8e199461 2016-10-06T06:08:16 fix for finding ALSA hotplug devices on Steam Link James Zipperer The device names show up as "default:", not "hw:"
Sam Lantinga 69cf1703 2016-10-04T06:46:46 fix deadlock on close device James Zipperer snd_pcm_drain doesn't always drain when you unplug a usb device. Use snd_pcm_drop instead
Ryan C. Gordon 2da1ec83 2016-08-28T13:36:13 Merge audio capture work back into the mainline.
Ryan C. Gordon 06dcdc7d 2016-08-28T11:56:11 Patched to compile.
Ryan C. Gordon 850da32f 2016-08-28T08:50:26 alsa: Implemented hotplug support, cleaned up device names.
Ryan C. Gordon cfa95fe6 2016-08-15T10:09:41 alsa: don't enumerate virtual devices, just physical hardware.
Ryan C. Gordon 761a7978 2016-08-05T01:59:06 audio: changed some SDL_memset() calls to SDL_zero(), other minor corrections.
Ryan C. Gordon 9b647727 2016-08-05T01:44:41 audio: Clean up some CloseDevice() interface details. - It's now always called if device->hidden isn't NULL, even if OpenDevice() failed halfway through. This lets implementation code not have to clean up itself on every possible failure point; just return an error and SDL will handle it for you. - Implementations can assume this->hidden != NULL and not check for it. - implementations don't have to set this->hidden = NULL when done, because the caller is always about to free(this). - Don't reset other fields that are in a block of memory about to be free()'d. - Implementations all now free things like internal mix buffers last, after closing devices and such, to guarantee they definitely aren't in use anymore at the point of deallocation.
Ryan C. Gordon 979de761 2016-08-05T01:44:15 audio: Removed internal SDL_audiomem.h and macros. I think this was important for SDL 1.2 because some targets needed special device memory for DMA buffers or locked memory buffers for use in hardware interrupts or something, but since it just defines to SDL_malloc and SDL_free now, I took it out for clarity's sake.
Ryan C. Gordon 38f4b68c 2016-08-03T01:00:30 alsa: capture devices don't need a mixbuf allocated.
Ryan C. Gordon 41e8f9ed 2016-08-02T15:06:40 alsa: Implemented audio capture support!
Ryan C. Gordon 754efd43 2016-08-02T15:06:05 alsa: Cleaned up the 5.1 swizzle mess a little. Shouldn't this be something ALSA handles for us with channel maps, so we can just delete this code?
Ryan C. Gordon 6d5c9c1e 2016-08-02T13:48:52 audio: Made some SDL_AudioDevice fields atomic. This makes sure they're properly communicated to the audio threads.
Philipp Wiesemann 427472fe 2016-07-19T21:02:44 ALSA: Fixed adding wrong status to error message (thanks, romain145!). Fixes Bugzilla #3364.
Ryan C. Gordon a581346f 2016-04-04T22:49:13 alsa: Make device enumeration robust against weird results with NULL strings.
Ryan C. Gordon 1e8df9cd 2016-03-05T23:25:23 alsa: Implemented basic device detection. This is kind of nasty, because ALSA reports dozens of "devices" that aren't really things you'd ever want, or things that should be listed this way, but the default path still works as before, and it at least allows these devices to be available to apps. This does not handle hotplugging yet. You get a device list at init time and that's it.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Ryan C. Gordon f9cfd9fa 2015-03-18T02:01:17 Bunch of reworking to how we manage audio devices. Device enumeration now happens at startup and then is managed exclusively through hotplugging instead of full redetection. The device name list now has a unique "handle" associated with each item and SDL will pass this to the backend so they don't have to figure out how a human readable name maps to real hardware for a second time. Other cleanups, fixes, improvements, plus all the audio backends updated to the new interface...largely untested at this point, though.
Ryan C. Gordon 0e02ce08 2015-03-16T02:11:39 Initial work on audio device hotplug support. This fills in the core pieces and fully implements it for Mac OS X. Most other platforms, at the moment, will report a disconnected device if it fails to write audio, but don't notice if the system's device list changed at all.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Sam Lantinga 08fa8da7 2013-10-20T21:56:15 Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings Andreas Ertelt The problem in question is caused by changeset 7771 (http://hg.libsdl.org/SDL/rev/5486e579872e / https://bugzilla.libsdl.org/show_bug.cgi?id=2121) The redefinition of __inline__ (introduced by the addition of begin_code.h:128's "|| __STRICT_ANSI__") results in mingw's gcc throwing multiple warning: always_inline function might not be inlinable [-Wattributes] as well as a whole bunch of redefinitions of mingw internals which break linking of projects including the SDL2 headers.
Sam Lantinga f79fc33a 2013-08-29T08:29:21 Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Gabriel Jacobo 1e49b1ed 2013-08-21T09:47:10 OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo 695344d1 2013-08-21T09:43:09 OCD fixes: Adds a space before */
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.