Commit graph

53 commits

Author SHA1 Message Date
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Ethan Lee 90b86b132a audio: Handle non-power-of-two spec.samples when unsupported
Fixes #3685
2022-07-17 10:36:15 -04:00
Ethan Lee 2f0816adb7 Add SDL_GetDefaultAudioInfo.
This API is supported on pipewire, pulseaudio, wasapi, and directsound.

Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
2022-07-11 13:34:35 -04:00
Francisco Javier Trujillo Mata e4a8087551 Initial Audio driver 2022-06-27 15:18:48 -07:00
pionere a70bb259c7 drop handle parameter of OpenDevice 2022-01-28 20:40:19 -05:00
pionere 1043dd8c0d adjust handling of iscapture
- drop iscapture parameter of OpenDevice
- use SDL_bool for iscapture
2022-01-28 20:40:19 -05:00
pionere 4a17612bff get rid of BeginLoopIteration 2022-01-28 20:40:19 -05:00
pionere 0770c5829c get rid of PrepareToClose 2022-01-28 20:40:19 -05:00
pionere 0dda8a7f4c cleanup init functions of audio
- use SDL_bool if possible
- assume NULL/SDL_FALSE filled impl
- skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
2022-01-28 20:40:19 -05:00
pionere 6fcfcc3d6f get rid of SkipMixerLock 2022-01-28 20:40:19 -05:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain f1fab24e35
AAudio: add bootstrap in SDL_audio.c 2021-04-15 21:00:00 +02:00
Ivan Epifanov 2d64e37e41 Initial rebase of xerpi's port 2021-03-08 09:07:12 -08:00
Ethan Lee 67e8522d31 Add SDL_GetAudioDeviceSpec.
This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
2021-03-05 12:03:07 -08:00
Frank Praznik 2f0b99a774 audio: Add Pipewire playback/capture sink 2021-02-28 19:40:09 -08:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Ozkan Sezer d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 723d014336 Fixed bug 4171 - SDL_GetQueuedAudioSize is broken with WASAPI
Cameron Gutman

I was trying to use SDL_GetQueuedAudioSize() to ensure my audio latency didn't get too high while streaming data in from the network. If I get more than N frames of audio queued, I know that the network is giving me more data than I can play and I need to drop some to keep latency low.

This doesn't work well on WASAPI out of the box, due to the addition of GetPendingBytes() to the amount of queued data. As a terrible hack, I loop 100 times calling SDL_Delay(10) and SDL_GetQueuedAudioSize() before I ever call SDL_QueueAudio() to get a "baseline" amount that I then subtract from SDL_GetQueuedAudioSize() later. However, because this value isn't actually a constant, this hack can cause SDL_GetQueuedAudioSize() - baselineSize to be < 0. This means I have no accurate way of determining how much data is actually queued in SDL's audio buffer queue.

The SDL_GetQueuedAudioSize() documentation says: "This is the number of bytes that have been queued for playback with SDL_QueueAudio(), but have not yet been sent to the hardware." Yet, SDL_GetQueuedAudioSize() returns > 0 value when SDL_QueueAudio() has never been called.

Based on that documentation, I believe the current behavior contradicts the documented behavior of this function and should be changed in line with Boris's patch.

I understand that exposing the IAudioClient::GetCurrentPadding() value is useful, but a solution there needs to take into account what of that data is silence inserted by SDL and what is actual data queued by the user with SDL_QueueAudio(). Until that happens, I think the best approach is to remove the GetPendingBytes() call until SDL is able to keep track of queued data to make sense of it. This would make SDL_GetQueuedAudioSize() possible to use accurately with WASAPI.
2019-06-04 17:32:15 -07:00
Sam Lantinga f3e76ea1d0 Use the OpenSL ES audio driver by default on Android, as it has the lowest latency. 2019-05-23 13:47:30 -07:00
Sam Lantinga 7dc92a7669 Initial Android OpenSL ES implementation, contributed by ANTA 2019-01-12 12:18:44 -08:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon 04cbf13261 audio: All device names reported by SDL must be unique.
This means that if you have two devices named "Soundblaster Pro" in your
machine, one will be reported as "Soundblaster Pro" and the other as
"Soundblaster Pro (2)".

This makes it so you can't into a position where one of your devices can't
be opened because another is sitting on the same name.
2018-10-10 15:20:56 -04:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Ryan C. Gordon 351d6d4784 audio: Port WASAPI to WinRT, remove XAudio2 backend.
XAudio2 doesn't have capture support, so WASAPI was to replace it; the holdout
was WinRT, which still needed it as its primary audio target until the WASAPI
code code be made to work.

The support matrix now looks like:

WinXP: directsound by default, winmm as a fallback for buggy drivers.
Vista+: WASAPI (directsound and winmm as fallbacks for debugging).
WinRT: WASAPI
2017-12-06 12:24:32 -05:00
Philipp Wiesemann 4366721b46 qnx: Removed unused bootstrap declaration.
QNX_bootstrap is the VideoBootStrap. QSAAUDIO_bootstrap is still there.
2017-07-02 22:46:00 +02:00
Ryan C. Gordon 22241ed0b0 Support for QNX 7.0 (thanks, Elad!).
Fixes Bugzilla #3686.
2017-07-01 17:50:47 -04:00
Ryan C. Gordon d9039f2396 jack: Initial shot at a JACK audio target.
http://jackaudio.org/

Fixes Bugzilla #2163.
(with several more commits following to improve this code.)
2017-06-08 13:27:58 -04:00
Ryan C. Gordon a7fc2822d4 audio: rename bsd target to netbsd.
Apparently this is no longer a generic BSD audio target, and hasn't been for
years, so rename it for NetBSD.
2017-05-24 19:56:59 -04:00
Philipp Wiesemann cfcec57f42 Fixed comment. 2017-02-19 21:05:09 +01:00
Ryan C. Gordon 1ed41d6d0d Patched to compile on Windows. 2017-02-14 03:12:09 -05:00
Ryan C. Gordon e5fc93baca audio: Don't wrap bootstrap declarations in preprocessor macros.
They are harmless and ignored if we don't actually link against them. The
preprocessor checks elsewhere if they're actually used.
2017-02-13 16:59:02 -05:00
Ryan C. Gordon 175f1e8f4a audio: Added a ThreadDeinit() method to match ThreadInit.
Not used by any targets at the moment, but will be shortly!
2017-02-13 16:55:00 -05:00
Ryan C. Gordon b3e8db802e audio: rename fake_stream to work_buffer.
It's more than an alternative for when the OS can't provide a DMA buffer, now.
2017-01-06 01:07:34 -05:00
Ryan C. Gordon 4aa9e36983 Patched to compile on some compilers. 2017-01-05 19:45:57 -05:00
Ryan C. Gordon 30178a9b24 audio: Added SDL_AudioStream. Non-power-of-two resampling now works! 2017-01-05 19:29:38 -05:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Ryan C. Gordon a0e003eebb 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.
2016-12-06 02:23:54 -05:00
Ryan C. Gordon 8b960d4e0f Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place. 2016-12-06 02:20:58 -05:00
Sam Lantinga 3615633571 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Sam Lantinga 57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Ryan C. Gordon f6a280ab7f 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.
2016-10-07 15:13:46 -04:00
Ryan C. Gordon 76f48acf63 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.
2016-10-07 14:35:25 -04:00
Sam Lantinga bac61096d8 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?
2016-10-04 06:48:07 -07:00
Ryan C. Gordon 978df1ad74 disk audio: Implemented "capture" support, cleaned up some things. 2016-08-06 03:39:15 -04:00
Ryan C. Gordon 9b2a59ef05 audio: Changed OnlyHasDefaultInputDevice to OnlyHasDefaultCaptureDevice. 2016-08-05 02:04:48 -04:00
Ryan C. Gordon 9b64772775 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.
2016-08-05 01:44:41 -04:00
Ryan C. Gordon 0d0f7080a3 audio: implemented higher level infrastructure for running capture devices. 2016-08-02 13:50:21 -04:00
Ryan C. Gordon 6d5c9c1e67 audio: Made some SDL_AudioDevice fields atomic.
This makes sure they're properly communicated to the audio threads.
2016-08-02 13:48:52 -04:00
Ryan C. Gordon 67f2538c41 audio: changed some internal ints to be SDL_bools. 2016-08-01 13:32:27 -04:00