src/audio


Log

Author Commit Date CI Message
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 2ba66d05 2016-12-31T16:21:55 Fixed bug 3535 - Misplaced comment #if/#endif closure comment Coriiander This notice is about a misplaced comment. Often times when we use an #if #endif sequence, the #endif is followed by a comment to indicate what #if statement it belonged to. The SDL_xaudio2.c file contains a misplaced comment, as follows (I stripped the other comments): #ifdef __GNUC__ # define SDL_XAUDIO2_HAS_SDK 1 #elif defined(__WINRT__) # define SDL_XAUDIO2_HAS_SDK #include "SDL_xaudio2.h" #else #if 0 #include <dxsdkver.h> #if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284)) # pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.") #else # define SDL_XAUDIO2_HAS_SDK 1 #endif #endif #endif /* 0 */ That final /* 0 */ should be moved one line up. Like this (I tabbed it out for you to make it more clear):
Sam Lantinga 9492492d 2016-12-26T01:56:52 Fixed bug 3516 - fix build on illumos Sylvain trivial patch to fix the build on illumos -Werror=declaration-after-statement https://gist.github.com/wiedi/15b71456667f7aa2a7f8815663723bb3
Sam Lantinga b2f6c4c1 2016-12-19T11:15:53 Fixed bus error when converting 16-bit to float for non-integral-multiple sample rates
Ryan C. Gordon 366c77a9 2016-12-18T20:17:33 audio: fixed one more incorrectly-hardcoded value in the resamplers.
Ryan C. Gordon f956df23 2016-12-17T16:15:24 audio: fixed arbitrary upsampling (thanks, Sylvain!). This was a leftover of simplifying the resamplers down from autogenerated code; I forgot to make something that the generator hardcoded into something variable. Fixes Bugzilla #3507.
Ryan C. Gordon c0231875 2016-12-06T12:23:17 audio: Fixed compiler warnings.
Ryan C. Gordon a0e003ee 2016-12-06T02:23:54 Refactored the audio queueing code to a generic SDL_DataQueue interface. This is not a public API (at the moment), but we will be needing this for other internal things soon.
Ryan C. Gordon 8b960d4e 2016-12-06T02:20:58 Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place.
Sam Lantinga 26f05ecb 2016-12-02T02:25:12 Fixed missing prototypes on Android, patch from Sylvain
Ryan C. Gordon 52827361 2016-11-23T10:51:44 directsound: fixed compiler warnings.
Sam Lantinga 36156335 2016-11-20T21:34:54 Renaming of guard header names to quiet -Wreserved-id-macro Patch contributed by Sylvain
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga c13a077d 2016-11-13T00:09:02 Fixed bug 3488 - Random crashes (because Memory overlap in audio converters detected by Valgrind) Vitaly Novichkov Okay, when I researched code and algorithm, I tried to replace condition "while(dst >= target)" with "while(dst > target)" and crashes are gone. Seems on some moments it tries to write into the place before memory block begin, therefore phantom crashes appearing after some moments.
Sam Lantinga 302a6e62 2016-11-11T12:41:06 Fixed bug 3484 - DSP driver does not detect /dev/dsp0 Tobias Kortkamp using SDL 2.0.5 (and a repository checkout) on FreeBSD 11.0 I get this output from testaudioinfo with SDL_AUDIODRIVER=dsp: INFO: Found 8 output devices: INFO: 0: /dev/dsp INFO: 1: /dev/dsp1 INFO: 2: /dev/dsp2 INFO: 3: /dev/dsp3 INFO: 4: /dev/dsp4 INFO: 5: /dev/dsp5 INFO: 6: /dev/dsp6 INFO: 7: /dev/dsp7 INFO: INFO: Found 3 capture devices: INFO: 0: /dev/dsp INFO: 1: /dev/dsp4 INFO: 2: /dev/dsp5 INFO: This is /dev/sndstat: Installed devices: pcm0: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play) pcm1: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play) pcm2: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play) pcm3: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play) pcm4: <Realtek ALC887 (Rear Analog 7.1/2.0)> (play/rec) pcm5: <Realtek ALC887 (Front Analog)> (play/rec) default pcm6: <Realtek ALC887 (Rear Digital)> (play) pcm7: <Realtek ALC887 (Onboard Digital)> (play) No devices installed from userspace. I'd expect to find /dev/dsp0 in the output device list. It's not detected because of a a small logic error in SDL_audiodev.c (see attached patch). With the patch applied I get this which is what I'd expect: INFO: Found 9 output devices: INFO: 0: /dev/dsp INFO: 1: /dev/dsp0 INFO: 2: /dev/dsp1 INFO: 3: /dev/dsp2 INFO: 4: /dev/dsp3 INFO: 5: /dev/dsp4 INFO: 6: /dev/dsp5 INFO: 7: /dev/dsp6 INFO: 8: /dev/dsp7
Philipp Wiesemann 6380d5c2 2016-11-07T21:10:01 Fixed audio conversion for unsigned 16 bit data.
Philipp Wiesemann 7ad3a46d 2016-11-05T21:23:17 ALSA: Fixed compile warning about unused function. Found by buildbot.
Sam Lantinga 6ed82130 2016-11-05T01:52:28 Fixed Windows build
Ryan C. Gordon a17abf10 2016-11-05T03:56:55 Also patched to compile on C89 compilers.
Ryan C. Gordon 067f0c84 2016-11-05T03:53:59 Patched to compile on C89 compilers.
Ryan C. Gordon f3456e9a 2016-11-05T02:34:38 Reworked audio converter code. This no longer uses a script to generate code for every possible type conversion or resampler. This caused a bloat in binary size and and compile times. Now we use a handful of more generic functions and assume staying in the CPU cache is the most important thing anyhow. This shrinks the size of the final build (in this case: macOS X amd64, -Os to optimize for size) by 15%. When compiling on a single core, build times drop by about 15% too (although the previous cost was largely hidden by multicore builds).
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...?