Commit Graph

662 Commits

Author SHA1 Message Date
Ryan C. Gordon
bda48fafc9 Replaced a few single-line "//" comments. 2017-01-07 17:09:14 -05:00
Sam Lantinga
4d0e3910dc Added configure and cmake support for libsamplerate 2017-01-06 20:43:53 -08:00
Ryan C. Gordon
5691f0a47e audio: Don't call a NULL function pointer when clearing audio streams.
(Partially?) fixes Bugzilla #3547.
2017-01-06 21:23:51 -05:00
Sam Lantinga
2590e16033 Added support for using libsamplerate to do audio resampling 2017-01-06 02:16:26 -08:00
Sam Lantinga
6ccc5dba96 Fixed confusion between Ryan's new audio stream and the audio buffer we were calling stream in the callback 2017-01-06 00:47:42 -08:00
Ryan C. Gordon
00ec10cdfd audio: Add an assert to make sure non-streaming audio uses good buffer sizes. 2017-01-06 03:38:14 -05:00
Ryan C. Gordon
4777c6045c haiku: Patched to compile. 2017-01-06 03:15:27 -05:00
Sam Lantinga
e8817d2de0 Don't do any audio conversion if none is necessary 2017-01-05 23:53:46 -08:00
Ryan C. Gordon
46cb198f18 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
01ef898525 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!).
2017-01-06 01:02:58 -05:00
Ryan C. Gordon
6ad693799a naclaudio: Untested attempt to migrate to SDL_AudioStream. 2017-01-06 00:56:29 -05:00
Ryan C. Gordon
8b97edfd35 haikuaudio: Untested attempt to get this working with SDL_AudioStream. 2017-01-06 00:50:01 -05:00
Ryan C. Gordon
d559e45eba emscriptenaudio: don't get stuck in infinite loop if SDL_AudioStreamPut fails. 2017-01-06 00:49:35 -05:00
Ryan C. Gordon
f36aa7ccc0 emscriptenaudio: Reworked to use SDL_AudioStream. 2017-01-05 21:31:02 -05:00
Ryan C. Gordon
81f7ac425c Fixed a few compiler warnings. 2017-01-05 20:11:19 -05:00
Ryan C. Gordon
9002a16f88 Patched to compile on some compilers. 2017-01-05 19:45:57 -05:00
Ryan C. Gordon
8ffb5f4ace audio: Added SDL_AudioStream. Non-power-of-two resampling now works! 2017-01-05 19:29:38 -05:00
Ryan C. Gordon
7ef486f9c8 audio: More effort to improve and simplify audio resamplers. 2017-01-05 19:12:20 -05:00
Ryan C. Gordon
839e13056d diskaudio: Use SDL_Log, not fprintf. 2017-01-05 19:30:45 -05:00
Sam Lantinga
d77ab77a7a Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
012e17b879 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):
2016-12-31 16:21:55 -08:00
Sam Lantinga
a838f265ba 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
2016-12-26 01:56:52 -08:00
Sam Lantinga
d4bf5754f1 Fixed bus error when converting 16-bit to float for non-integral-multiple sample rates 2016-12-19 11:15:53 -08:00
Ryan C. Gordon
b9d8e7cdfd audio: fixed one more incorrectly-hardcoded value in the resamplers. 2016-12-18 20:17:33 -05:00
Ryan C. Gordon
4405458835 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.
2016-12-17 16:15:24 -05:00
Ryan C. Gordon
17856a8b9f audio: Fixed compiler warnings. 2016-12-06 12:23:17 -05:00
Ryan C. Gordon
43fa407edf 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
1e16752241 Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place. 2016-12-06 02:20:58 -05:00
Sam Lantinga
f0ca0a5183 Fixed missing prototypes on Android, patch from Sylvain 2016-12-02 02:25:12 -08:00
Ryan C. Gordon
45c72a176b directsound: fixed compiler warnings. 2016-11-23 10:51:44 -05:00
Sam Lantinga
9cc7ce9008 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Sam Lantinga
5e1151257d Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
34578b09f4 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.
2016-11-13 00:09:02 -08:00
Sam Lantinga
7360e7876d 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
2016-11-11 12:41:06 -08:00
Philipp Wiesemann
704178b1b2 Fixed audio conversion for unsigned 16 bit data. 2016-11-07 21:10:01 +01:00
Philipp Wiesemann
a14ec8f1c9 ALSA: Fixed compile warning about unused function.
Found by buildbot.
2016-11-05 21:23:17 +01:00
Sam Lantinga
dcb1a410aa Fixed Windows build 2016-11-05 01:52:28 -07:00
Ryan C. Gordon
1db5e3cead Also patched to compile on C89 compilers. 2016-11-05 03:56:55 -04:00
Ryan C. Gordon
ab3f23e948 Patched to compile on C89 compilers. 2016-11-05 03:53:59 -04:00
Ryan C. Gordon
eadddb3977 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).
2016-11-05 02:34:38 -04:00
Sam Lantinga
a7cafb8549 Fixed compiling on older versions of ALSA 2016-10-28 17:00:37 -07:00
Sam Lantinga
2738bea5a8 Fixed audio data swizzling when the device channel map already matches what SDL expects 2016-10-28 16:47:06 -07:00
Sam Lantinga
c5b8ddacca Work-around for a hang when USB devices are unplugged, contributed by James Zipperer 2016-10-12 22:25:19 -07:00
Sam Lantinga
134f47d9c9 Use SDL C runtime strlen() 2016-10-10 23:26:26 -07:00
Ryan C. Gordon
7a666e170e 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.
2016-10-10 15:29:18 -04:00
Sam Lantinga
c9a67a6cd0 ALSA_snd_pcm_drop() can hang on some systems (Steam Link) so don't use that when shutting down the ALSA audio driver. 2016-10-07 19:08:22 -07:00
Sam Lantinga
27201c3741 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".
2016-10-07 17:23:20 -07:00
Ryan C. Gordon
874160d49f audio: Backed out the audio-thread detaching changes.
It added a ton of complexity. A simpler solution might arise at some
point though.
2016-10-07 19:39:43 -04:00
Ryan C. Gordon
4cbd94c61c 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
7385f42fbe audio: better way to calculate buffer drain wait times. 2016-10-07 14:42:24 -04:00