Commit Graph

143 Commits

Author SHA1 Message Date
Ryan C. Gordon
23020f92fa audio: Don't ever use libsamplerate in the SDL_AudioCVT codepath.
It causes audio pops if you're converting in chunks (and needs to
allocate/initialize/free on each convert). We'll either adjust this interface
when we break ABI for 2.1 to make this usable, or publish the SDL_AudioStream
API for those that want a streaming solution.

In the meantime, the "simple" resampler produces "good enough" audio without
pops and doesn't have to be initialized, so that'll do for now on the
SDL_AudioCVT interface.
2017-01-09 16:31:57 -05:00
Ryan C. Gordon
063c9d40d7 audio: Replaced older resamplers in SDL_AudioCVT with the new ones. 2017-01-09 06:00:58 -05:00
Ryan C. Gordon
a41103b170 audio: Patched to compile if linking directly to libsamplerate. 2017-01-09 05:59:30 -05:00
Ryan C. Gordon
38854e0333 audio: Improvements in channel conversion code. 2017-01-08 16:18:49 -05:00
Ryan C. Gordon
35166609d5 audio: Patched to compile with libsamplerate support (again). 2017-01-08 14:28:44 -05:00
Ryan C. Gordon
d005dc21d3 audio: Patched to compile with libsamplerate support. 2017-01-08 14:23:15 -05:00
Ryan C. Gordon
19e937fc2e audio: libsamplerate loading now happens once at init time. 2017-01-08 14:18:03 -05:00
Ryan C. Gordon
98cc9d10d3 Fixed coding style on a function signature. 2017-01-08 14:17:09 -05:00
Ryan C. Gordon
61a3ba303c Replaced a few single-line "//" comments. 2017-01-07 17:09:14 -05:00
Sam Lantinga
df25258a1e Added configure and cmake support for libsamplerate 2017-01-06 20:43:53 -08:00
Ryan C. Gordon
c5825b698d 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
cbe44f7ff1 Added support for using libsamplerate to do audio resampling 2017-01-06 02:16:26 -08:00
Sam Lantinga
37f404fb87 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
748f46054f 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
345c5989f1 haiku: Patched to compile. 2017-01-06 03:15:27 -05:00
Sam Lantinga
3443dc19f9 Don't do any audio conversion if none is necessary 2017-01-05 23:53:46 -08: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
992124d4de 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
99fc1ef994 naclaudio: Untested attempt to migrate to SDL_AudioStream. 2017-01-06 00:56:29 -05:00
Ryan C. Gordon
115d0ce71c haikuaudio: Untested attempt to get this working with SDL_AudioStream. 2017-01-06 00:50:01 -05:00
Ryan C. Gordon
1a90c72dfc emscriptenaudio: don't get stuck in infinite loop if SDL_AudioStreamPut fails. 2017-01-06 00:49:35 -05:00
Ryan C. Gordon
f07a1a5ad5 emscriptenaudio: Reworked to use SDL_AudioStream. 2017-01-05 21:31:02 -05:00
Ryan C. Gordon
3761b5f60b Fixed a few compiler warnings. 2017-01-05 20:11:19 -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
Ryan C. Gordon
f12ab8f2b3 audio: More effort to improve and simplify audio resamplers. 2017-01-05 19:12:20 -05:00
Ryan C. Gordon
52130bde40 diskaudio: Use SDL_Log, not fprintf. 2017-01-05 19:30:45 -05:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
2ba66d0525 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
9492492d5f 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
b2f6c4c1bd 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
366c77a9f0 audio: fixed one more incorrectly-hardcoded value in the resamplers. 2016-12-18 20:17:33 -05:00
Ryan C. Gordon
f956df23bb 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
c023187548 audio: Fixed compiler warnings. 2016-12-06 12:23:17 -05: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
26f05ecb4d Fixed missing prototypes on Android, patch from Sylvain 2016-12-02 02:25:12 -08:00
Ryan C. Gordon
52827361ae directsound: fixed compiler warnings. 2016-11-23 10:51:44 -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
Sam Lantinga
c13a077d15 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
302a6e62aa 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
6380d5c24e Fixed audio conversion for unsigned 16 bit data. 2016-11-07 21:10:01 +01:00
Philipp Wiesemann
7ad3a46d76 ALSA: Fixed compile warning about unused function.
Found by buildbot.
2016-11-05 21:23:17 +01:00
Sam Lantinga
6ed8213049 Fixed Windows build 2016-11-05 01:52:28 -07:00
Ryan C. Gordon
a17abf10b7 Also patched to compile on C89 compilers. 2016-11-05 03:56:55 -04:00
Ryan C. Gordon
067f0c8482 Patched to compile on C89 compilers. 2016-11-05 03:53:59 -04:00
Ryan C. Gordon
f3456e9a93 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
88f2d16e45 Fixed compiling on older versions of ALSA 2016-10-28 17:00:37 -07:00
Sam Lantinga
fdcac1c24f Fixed audio data swizzling when the device channel map already matches what SDL expects 2016-10-28 16:47:06 -07:00