src/audio/SDL_audio.c


Log

Author Commit Date CI Message
Ryan C. Gordon c85c57a0 2017-03-29T14:23:39 wasapi: Handle lost audio device endpoints. This gracefully recovers when a device format is changed, and will switch to the new default device if the current one is unplugged, etc. This does not handle when a new default device is added; it only notices if the current default goes away. That will be fixed by implementing the stubbed-out MMNotificationClient_OnDefaultDeviceChanged() function.
Sam Lantinga c4d54504 2017-03-14T07:16:56 differentiate between capture / playback audio thread names
Ryan C. Gordon a4249b48 2017-02-26T00:56:13 Patched to compile on C89 compilers.
Ryan C. Gordon 3b9e4d0a 2017-02-26T00:39:22 audio: Try to keep callbacks firing at normal pace when device is lost.
Ryan C. Gordon a366c35f 2017-02-26T00:12:33 audio: run the audio callback even if device was lost. We will throw away the data anyhow, but some apps depend on the callback firing to make progress; testmultiaudio.c, if nothing else, is an example of this. Capture also will now fire the callback in these conditions, offering nothing but silence. Apps can check SDL_GetAudioDeviceStatus() or listen for the SDL_AUDIODEVICEREMOVED event if they want to gracefully deal with an opened audio device that has been unexpectedly lost.
Ryan C. Gordon 5728cb20 2017-02-26T00:10:02 audio: Make sure the disk and dummy targets are the last ones we try to init.
Ryan C. Gordon 6046fd4c 2017-02-14T03:03:27 wasapi: Initial WASAPI support, for Windows Vista and later. This should remain binary compatible with Windows XP, as we dynamically load anything we need and fall back to DirectSound/WinMM/XAudio2 if not available.
Ryan C. Gordon 175f1e8f 2017-02-13T16:55:00 audio: Added a ThreadDeinit() method to match ThreadInit. Not used by any targets at the moment, but will be shortly!
Sam Lantinga 886736a2 2017-02-11T16:38:16 Fixed bug 3584 - Small stack size for audio callback thread Walter van Niftrik We have found that since SDL 2.0.5 the audio callback thread is created with a very small stack size. In our application this is leading to stack overflows. We believe there is a bug at http://hg.libsdl.org/SDL/file/391fd532f79e/src/audio/SDL_audio.c#l1132, where the is_internal_thread flag appears to be inverted.
Sam Lantinga ede5c734 2017-01-24T19:38:01 Generalized the audio resampling hint for other resampling methods in the future
Ryan C. Gordon c7f9dcb6 2017-01-24T15:52:22 audio: Offer a hint for libsamplerate quality/speed tradeoff. This defaults to the internal SDL resampler, since that's the likely default without a system-wide install of libsamplerate, but those that need more can tweak this.
Ryan C. Gordon 57182930 2017-01-16T00:58:28 audio: Implemented SIMD support for audio data type converters. This currently adds an SSE2 implementation (but it's #ifdef'd out for now, until it's hooked up to the configure script and such).
Ryan C. Gordon a41103b1 2017-01-09T05:59:30 audio: Patched to compile if linking directly to libsamplerate.
Ryan C. Gordon 35166609 2017-01-08T14:28:44 audio: Patched to compile with libsamplerate support (again).
Ryan C. Gordon 19e937fc 2017-01-08T14:18:03 audio: libsamplerate loading now happens once at init time.
Sam Lantinga 37f404fb 2017-01-06T00:47:42 Fixed confusion between Ryan's new audio stream and the audio buffer we were calling stream in the callback
Ryan C. Gordon 748f4605 2017-01-06T03:38:14 audio: Add an assert to make sure non-streaming audio uses good buffer sizes.
Ryan C. Gordon b3e8db80 2017-01-06T01:07:34 audio: rename fake_stream to work_buffer. It's more than an alternative for when the OS can't provide a DMA buffer, now.
Ryan C. Gordon 992124d4 2017-01-06T01:02:58 audio: Fixed SDL_AudioStreamGet() function parameters. There was a draft of this where it did audio conversion into the final buffer, if there was enough room available past what you asked for, but that interface got removed, so the parameters didn't make sense (and we were using the wrong one in any case, too!).
Ryan C. Gordon f07a1a5a 2017-01-05T21:31:02 emscriptenaudio: Reworked to use SDL_AudioStream.
Ryan C. Gordon 3761b5f6 2017-01-05T20:11:19 Fixed a few compiler warnings.
Ryan C. Gordon 30178a9b 2017-01-05T19:29:38 audio: Added SDL_AudioStream. Non-power-of-two resampling now works!
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
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 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.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
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 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
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 b879595a 2016-08-10T14:14:14 audio: Patched to compile on C89 compilers.
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 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 9b2a59ef 2016-08-05T02:04:48 audio: Changed OnlyHasDefaultInputDevice to OnlyHasDefaultCaptureDevice.
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 6bd1ec6b 2016-08-02T15:04:33 audio: a little more robustness in the capture device's thread.
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 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 ee099750 2016-08-01T00:18:56 audio: Initial bits to enable audio capture support.
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.
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().