src/audio


Log

Author Commit Date CI Message
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 93ff12ce 2016-10-07T17:23:20 Fixed bug 2952 - SDL_MixAudioFormat does not support audio format AUDIO_U16LSB/AUDIO_U16MSB Simon Sandstr?m As stated in Summary. The switch statement will execute the default case and set a SDL error message: "SDL_MixAudio(): unknown audio format". There are atleast two more problems here: 1. SDL_MixAudioFormat does not notify the user that an error has occured and that a SDL error message was set. It took me awhile to understand why I couldn't mix down the volume on my AUDIO_U16LSB formatted audio stream.. until I started digging in the SDL source code. 2. The error message is incorrect, it should read: "SDL_MixAudioFormat(): unknown audio format".
Ryan C. Gordon 7d2108ce 2016-10-07T19:39:43 audio: Backed out the audio-thread detaching changes. It added a ton of complexity. A simpler solution might arise at some point though.
Ryan C. Gordon f6a280ab 2016-10-07T15:13:46 audio: Don't trust audio drivers to drain pending audio. This tends to be a frequent spot where drivers hang, and the waits were often unreliable in any case. Instead, our audio thread now alerts the driver that we're done streaming audio (which currently XAudio2 uses to alert the system not to warn about the impending underflow) and then SDL_Delay()'s for a duration that's reasonable to drain the DMA buffers before closing the device.
Ryan C. Gordon 551cdc8d 2016-10-07T14:42:24 audio: better way to calculate buffer drain wait times.
Ryan C. Gordon 76f48acf 2016-10-07T14:35:25 audio: threading and device hang improvements. This tries to make SDL robust against device drivers that have hung up, apps don't freeze in catastrophic (but not necessarily uncommon) conditions. Now we detach the audio thread and let it clean up and don't care if it never actually runs to completion.
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 9257b72d 2016-10-05T00:12:16 Backed out a very unsafe change that was trying to prevent audio hang at quit. Ryan and I have ideas on a better way to handle this.
Sam Lantinga bac61096 2016-10-04T06:48:07 ensure SDL_AUDIODEVICEREMOVED gets sent when hotplug removes a device James Zipperer The problem I was seeing was that the the ALSA hotplug thread would call SDL_RemoveAudioDevice, but my application code was not seeing an SDL_AUDIODEVICEREMOVED event to go along with it. To fix it, I added some code into SDL_RemoveAudioDevice to call SDL_OpenedAudioDeviceDisconnected on the corresponding open audio device. There didn't appear to be a way to cross reference the handle that SDL_RemoveAudioDevice gets and the SDL_AudioDevice pointer that SDL_OpenedAudioDeviceDisconnected needs, so I ended up adding a void *handle field to struct SDL_AudioDevice so that I could do the cross reference. Is there some other way beside adding a void *handle field to the struct to get the proper information for SDL_OpenedAudioDeviceDisconnected?
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
Sam Lantinga 2558c9c8 2016-10-04T06:45:28 fix audio deadlock James Zipperer Close the audio device before waiting for the audio thread to complete, which fixes a situation where the audio thread never completes Add an additional check in the audio thread to see if the device is enabled and bail out if the device is no longer enabled
Philipp Wiesemann 8e88f081 2016-09-21T23:06:49 Mac: Fixed whitespace around function return type.
Alex Szpakowski f0fca288 2016-09-18T19:22:09 Handle audio interruptions on iOS/tvOS. Fixes bugs 2569 and 2960.
Ryan C. Gordon 06700a90 2016-09-18T18:07:47 emscripten: get even more aggressive about audio device closing. I still get exceptions thrown sometimes on shutdown without this.
Alex Szpakowski 4209a1fd 2016-09-15T19:59:57 CoreAudio iOS/tvOS: Use AVFoundation instead of AudioSession. Fixes audio on tvOS. Note that linking with AVFoundation is now required if you don't disable SDL_audio compilation on iOS and tvOS.
Alex Szpakowski f0505766 2016-09-13T22:18:06 Initial Apple TV / tvOS support. The Apple TV remote is currently exposed as a joystick with its touch surface treated as two axes. Key presses are also generated when its buttons and touch surface are used. A new hint has been added to help deal with deciding whether to background the app when the remote's menu button is pressed: SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS.
Alon Zakai 63200ea3 2016-09-13T00:03:41 optimize a getValue
Ryan C. Gordon 0265d3af 2016-09-04T01:23:55 coreaudio: Move from AudioUnits to AudioQueues. AudioQueues are available in Mac OS X 10.5 and later (and iOS 2.0 and later). Their API is much more clear (and if you don't mind the threading tapdance to get its own CFRunLoop) much easier to use in general for our purposes. As an added benefit: they seemlessly deal with format conversion in ways AudioUnits don't: for example, my MacBook Pro's built-in microphone won't capture at 8000Hz and the AudioUnit version wouldn't resample to hide this fact; the AudioQueue version, however, can handle this.
Ryan C. Gordon 3b53304a 2016-09-03T00:13:41 coreaudio: capture devices should let the system allocate the render buffer.
Ryan C. Gordon fda7a3d1 2016-09-02T13:12:21 coreaudio: Replaced an int with an SDL_bool.
Ryan C. Gordon f9d9708f 2016-09-02T13:11:28 coreaudio: Move some variable declarations to the top of the scope.
Ryan C. Gordon 2098bfb3 2016-08-31T16:10:04 emscripten: Be more aggressive when closing audio capture devices. Fixes exceptions being thrown on shutdown.
Ryan C. Gordon c9bfcbde 2016-08-28T18:52:25 nacl: Patched to compile.
Ryan C. Gordon 714aa211 2016-08-28T18:24:44 Patched to compile on Haiku.
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 3b88f5c6 2016-08-12T00:03:58 emscripten audio: check for an "undefined" object, remove some console.log().
Ryan C. Gordon e435659c 2016-08-11T22:26:58 audio: Cleaned up "extern AudioBootStrap" list.
Ryan C. Gordon 6f4bcd24 2016-08-11T22:22:09 audio: Renamed some internal driver symbols in various targets.
Ryan C. Gordon 8f0af773 2016-08-11T22:04:49 android: implement audio capture support.
Ryan C. Gordon b78ec974 2016-08-10T16:00:16 directsound: Implemented audio capture support.
Ryan C. Gordon 21c7fe00 2016-08-10T15:34:24 windows: directsound should also map audio device GUIDs to proper names. Moved this code from winmm into core so both can use it. DirectSound (at least on Win10) also returns truncated device names, even though it's handed in as a string pointer and not a static-sized buffer. :/
Ryan C. Gordon b879595a 2016-08-10T14:14:14 audio: Patched to compile on C89 compilers.
Ryan C. Gordon 244d2dbc 2016-08-10T14:13:48 emscripten audio: fix timer on capture's silence callback.
Ryan C. Gordon 7a8e4cb0 2016-08-09T19:35:46 directsound: recalculate audiospec size before creating secondary buffer. I think this was a bug before? Maybe I'm misunderstanding this, but it looks like it was working because we allocate room for 8 chunks...
Ryan C. Gordon 358a168c 2016-08-09T16:58:32 emscripten audio: Added audio capture support.
Ryan C. Gordon 5de11a5f 2016-08-09T16:58:06 Added a FIXME.
Ryan C. Gordon a05bde21 2016-08-09T00:44:59 audio: Only allocate fake_stream if we're using the standard audio threads.
Ryan C. Gordon be8d7a46 2016-08-09T00:44:05 audio: simplifed check for internal callback. Easier to check when it's NULL instead of a list of known internal functions.
Ryan C. Gordon df4985e2 2016-08-07T02:43:20 dsp: Implemented audio capture support.
Ryan C. Gordon a0ff2554 2016-08-07T01:48:38 winmm: Try to get full device names from the Windows Registry.
Ryan C. Gordon ff7df7e6 2016-08-06T23:05:02 winmm: Added a FIXME for truncated device names.
Ryan C. Gordon 51d15233 2016-08-06T19:34:32 winmm: Implemented audio capture support.
Ryan C. Gordon 4499e5bc 2016-08-06T03:45:45 disk audio: Make default i/o delay match what device is meant to be running at.
Ryan C. Gordon 978df1ad 2016-08-06T03:39:15 disk audio: Implemented "capture" support, cleaned up some things.
Ryan C. Gordon 73153901 2016-08-06T02:47:27 audio: Implemented buffer queueing for capture devices (SDL_DequeueAudio()).
Ryan C. Gordon e7347a40 2016-08-06T02:27:55 audio: SDL_ClearQueuedAudio() should free everything but two packets. Otherwise, if you had a massive, one-time queue buildup, the memory from that remains allocated until you close the device. Also, if you are just using a reasonable amount of space, this would previously cause you to reallocate it over and over instead of keeping a little bit of memory around.
Ryan C. Gordon 9a331544 2016-08-05T04:23:32 nas: initial shot at audio capture support. Compiles, but not tested.
Ryan C. Gordon 9b2a59ef 2016-08-05T02:04:48 audio: Changed OnlyHasDefaultInputDevice to OnlyHasDefaultCaptureDevice.
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 30a9139b 2016-08-04T11:51:17 arts: backed out audio capture support. Turns out that libartsc isn't thread-safe, so if we run a capture and playback device at the same time, it often crashes in arts's internal event loop. We could throw mutexes around the read/write calls, but these are meant to block, so one device could cause serious latency and stutter in the other. Since this audio target isn't in high-demand (Ubuntu hasn't offered a libartsc package for years), I'm just backing out the capture support. If someone needs it, they can pull it out of the revision history.
Ryan C. Gordon 20cd5e44 2016-08-03T16:54:10 dummy audio: Patched to compile.
Ryan C. Gordon 17246ba9 2016-08-03T02:18:47 dummy audio: Implemented dummy audio capture support. :)
Ryan C. Gordon 9dd8477a 2016-08-03T01:57:41 bsdaudio: first shot at audio capture support! (untested, uncompiled...for now.)
Ryan C. Gordon d30a2f5a 2016-08-03T01:56:58 bsdaudio: this appears to be using the wrong variable...? (We probably never noticed because this is meant to block until it fully writes a buffer, and would only trigger an issue if we had a short write that wasn't otherwise an error condition.)
Ryan C. Gordon ecbd625c 2016-08-03T01:53:59 arts: Patched to (maybe) compile.
Ryan C. Gordon a7dddacd 2016-08-03T01:01:44 arts: implemented audio capture support. (completely untested! Not even compiled!!).
Ryan C. Gordon 38f4b68c 2016-08-03T01:00:30 alsa: capture devices don't need a mixbuf allocated.
Ryan C. Gordon a9ef240c 2016-08-03T00:30:12 coreaudio: Implemented audio capture for iOS.
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 6bd1ec6b 2016-08-02T15:04:33 audio: a little more robustness in the capture device's thread.
Ryan C. Gordon d662bc04 2016-08-02T13:50:58 pulseaudio: Implemented audio capture support!
Ryan C. Gordon 0d0f7080 2016-08-02T13:50:21 audio: implemented higher level infrastructure for running capture devices.
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.
Ryan C. Gordon 67f2538c 2016-08-01T13:32:27 audio: changed some internal ints to be SDL_bools.
Ryan C. Gordon a94376c7 2016-08-01T11:47:02 nacl: unlock audio thread mutex when done with it.
Ryan C. Gordon c754662d 2016-08-01T11:45:45 audio: Make SDL_AudioDevice::shutdown an atomic value. Just to make sure this get communicated to the audio thread properly.
Ryan C. Gordon 015dd8dd 2016-08-01T00:20:47 audio: Implemented capture support for Mac OS X CoreAudio. I don't know what iOS wants yet, so this code might work there, too...?
Ryan C. Gordon ee099750 2016-08-01T00:18:56 audio: Initial bits to enable audio capture support.
Philipp Wiesemann 427472fe 2016-07-19T21:02:44 ALSA: Fixed adding wrong status to error message (thanks, romain145!). Fixes Bugzilla #3364.
Alex Szpakowski 4a468739 2016-05-21T00:20:52 Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
Ryan C. Gordon 9b4db2b8 2016-04-12T18:11:36 Patched to compile on various platforms.
Ryan C. Gordon c61675dc 2016-04-12T16:45:10 threads: Move SDL's own thread creation to a new internal API. This allows us to set an explicit stack size (overriding the system default and the global hint an app might have set), and remove all the macro salsa for dealing with _beginthreadex and such, as internal threads always set those to NULL anyhow. I've taken some guesses on reasonable (and tiny!) stack sizes for our internal threads, but some of these might turn out to be too small in practice and need an increase. Most of them are simple functions, though.
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.
Philipp Wiesemann 9bdd1881 2016-01-27T23:20:23 PSP: Removed inlined copy of SDL_CalculateAudioSpec()'s functionality.
Sam Lantinga 68a32728 2016-01-02T10:38:51 Fixed sed error on Mac OS X and updated copyright on a few last files
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Sam Lantinga 8ddcc63a 2015-12-18T18:49:35 sdl: xaudio2 is not linked against sdl but the sdk already handles dynamically loading (XAudio2Create is inlined and just loads a com object). Updated SDL_xaudio2.c
David Ludwig 25abce51 2015-11-29T19:33:11 WinRT: added Win10/UWP (Universal Windows Platform) support "UWP" appears to be Microsoft's new name for WinRT/Windows-Store APIs. This set of changes updates SDL's WinRT backends to support the Win10 flavor of WinRT. It has been tested on Win10 on a desktop. In theory, it should also support Win10 on other devices (phone, Xbox One, etc.), however further patches may be necessary. This adds: - a set of MSVC 2015 project files, for use in creating UWP apps - modifications to various pieces of SDL, in order to compile via MSVC 2015 + the Win10 API set - enables SDL_Window resizing and programmatic-fullscreen toggling, when using the WinRT backend - WinRT README updates
Philipp Wiesemann fcc59409 2015-08-05T21:04:10 Emscripten: Added missing error messages for audio and joystick init failures.
Ryan C. Gordon 4986563d 2015-06-30T13:46:06 Fixed assertion failure in diskaudio target caused by new hotplugging support. Fixes Bugzilla #3032.
Alfred Reynolds cbbdd27a 2015-06-24T10:56:51 SDL - disable compiling in XAudio2 support. We both need the DX SDK to make this code plus we need to work out the runtime dependency problem this code bring in on windows (needing the DX runtime installed). CR: SamL
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().