Commit graph

93 commits

Author SHA1 Message Date
Ryan C. Gordon
eeec5705e0 audio: libsamplerate can't resample in-place; make space for a copy if needed. 2017-01-24 20:30:48 -05:00
Ryan C. Gordon
0dc13f56ec 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.

--HG--
extra : amend_source : 804f3d3dc636b5f28f7194b48b492c6c3fe05bf5
2017-01-24 15:52:22 -05:00
Ryan C. Gordon
dc15193eb5 audio: Fix static analysis concerns about a dead assignment. 2017-01-24 10:09:29 -05:00
Ryan C. Gordon
ca2ab5780a audio: Make sure SDL_AudioStream's work buffer is 16-byte aligned, for SIMD.
Note the giantic FIXME, though!
2017-01-24 00:51:33 -05:00
Ryan C. Gordon
30238b8676 audio: Streams now resample in-place. Removed second allocated buffer. 2017-01-24 00:17:40 -05:00
Ryan C. Gordon
2471f581c6 audio: allow stereo Sint16 resampling fast path in SDL_AudioStream.
This currently favors libsamplerate over the fast path (quality over speed),
but I'm not sure that's the correct approach, as there may be surprising
changes in performance metrics depending on what packages are available on
a user's system. That being said, currently, the only thing with access to
SDL_AudioStream is an SDL audio device's thread, and it might be mostly idle
otherwise, so maybe this is generally good.
2017-01-24 00:08:24 -05:00
Ryan C. Gordon
6b1e0a7cd2 audio: Fixed off-by-one error in upsampling. 2017-01-24 00:03:36 -05:00
Ryan C. Gordon
8850103510 audio: Resampler now special-cases stereo and mono processing.
Turns out that iterating from 0 to channels-1 was a serious performance hit!

These cases now tend to match or beat the original audio resampler's speed!
2017-01-23 16:45:50 -05:00
Ryan C. Gordon
c869f0418a audio: Fixed incorrect pointer in SDL_ResampleCVT_si16_c2().
Forgot to update this when we changed this to process in-place. Whoops!
2017-01-23 16:42:47 -05:00
Ryan C. Gordon
6e1edca849 audio: Wired up new SSE code to build system.
--HG--
extra : rebase_source : 3c94cdc92b94864eb43d7429032724227b798cf2
2017-01-23 01:05:44 -05:00
Ryan C. Gordon
c46db55d26 audio: Special case for resampling stereo AUDIO_S16SYS audio data.
This is a fairly common case, so we avoid the conversion to/from float here.

--HG--
extra : rebase_source : 46d6e38d06da451b8c2e836ae36cd1ddba02e510
2017-01-22 20:27:48 -05:00
Ryan C. Gordon
50bb6473ed audio: Make the simple resampler operate in-place.
This allows us to avoid an extra copy, allocate less memory and reduce cache
pressure. On the downside: we have to do a lot of tapdancing to resample the
buffer in reverse when the output is growing.

--HG--
extra : rebase_source : cab98b19216722eae3749cc1e1429d1c802e9782
2017-01-22 23:48:15 -05:00
Ryan C. Gordon
6ceacbdc4a audio: Added SSE3 implementation of SDL_ConvertStereoToMono().
--HG--
extra : rebase_source : 92882c4fdf5dc4a326057f577ccb4c29c32f938e
2017-01-23 00:57:19 -05:00
Ryan C. Gordon
8af7561815 audio: don't cast to double in SDL_ConvertStereoToMono().
It's expensive and (hopefully) unnecessary. If this becomes an overflow
problem, we could multiply both values by 0.5f before adding them, but let's
see if we can get by without the extra multiplication first.

--HG--
extra : rebase_source : b7b47e961eb974510e133882548ea36b40f6d7e3
2017-01-22 20:18:59 -05:00
Ryan C. Gordon
34fe29bc62 audio: removed conditional from simple resampler's inner loop.
We never seem to overflow the source buffer now; this might have been a
leftover from a bug that was covered by Vitaly's fixes?

Removing this conditional makes the resampler 10-20% faster. Left an
assert in there for debug builds, in case this still happens.

--HG--
extra : rebase_source : c05a536f5a80f065c0872b35d77d4f70a56b4e3e
2017-01-20 16:26:24 -05:00
Ryan C. Gordon
adb1d6888f audio: Several fixes to "simple" resampler (thanks, Vitaly!).
Fixes Bugzilla #3551.
2017-01-18 02:11:56 -05:00
Ryan C. Gordon
c40d568133 audio: Some fixes to the audio data type converter code.
Removed some needless things ("len / sizeof (Uint8)"), and made sure the
int32 -> float code uses doubles to avoid working with large integer values
in a 32-bit float.

--HG--
extra : rebase_source : c803b416ec487b8c0feba780ac06f8d11e90879b
2017-01-15 05:01:59 -05:00
Sam Lantinga
8eb437d4e7 Fixed bug 3552 - Building SDL in release mode fails under VS 2017 RC
Lukasz Biel

Tried to compile SDL2 using newest version of VS.

Got:
SDL_audiocvt.obj : error LNK2019: unresolved external symbol memcpy referenced in function SDL_ResampleCVT
1>E:\Users\dotPo\Lib\SDL\VisualC\x64\Release\SDL2.dll : fatal error LNK1120: 1 unresolved externals

whole compilation process: http://pastebin.com/eWDAvBce

Steps to reproduce:
clone http://hg.libsdl.org/SDL using tortoise hg,
open SDL\VisualC\SDL.sln,
when promted if should retarget solution click ok,
select release x64 build type,
Build/Build Solution

attempt 2, using Visual Studio cmake support:
open folder SDL\
select release x64 build type,
run CMake\Build CMakeLists.txt
build fails

When switched to debug build type, buils succeeds in both cases.
VS 2017 is still beta.
2017-01-09 20:37:52 -08:00
Ryan C. Gordon
27737db314 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.

--HG--
extra : rebase_source : 4c5656de3d1de9f88d6368e5ca363d834fc93af1
2017-01-09 16:31:57 -05:00
Ryan C. Gordon
2f283c2beb audio: Replaced older resamplers in SDL_AudioCVT with the new ones.
--HG--
extra : rebase_source : a4df0c56d61d9927e97bbd738c12a3043f44742e
2017-01-09 06:00:58 -05:00
Ryan C. Gordon
9268415b53 audio: Improvements in channel conversion code.
--HG--
extra : amend_source : 521d4d1f25bba02be473faa4d573928ea9007452
2017-01-08 16:18:49 -05:00
Ryan C. Gordon
d8f718f75d audio: Patched to compile with libsamplerate support. 2017-01-08 14:23:15 -05:00
Ryan C. Gordon
f904fecce3 audio: libsamplerate loading now happens once at init time.
--HG--
extra : rebase_source : b88014744534e382d6b6ea004554ffcebe5caffe
2017-01-08 14:18:03 -05:00
Ryan C. Gordon
d81fb0038f Fixed coding style on a function signature.
--HG--
extra : rebase_source : ccbcdf0c433bac0ad213f4a377674363b1fab87e
2017-01-08 14:17:09 -05:00
Sam Lantinga
5a0aef995a Added configure and cmake support for libsamplerate 2017-01-06 20:43:53 -08:00
Ryan C. Gordon
8ab0ba202d 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
376e6fa6f2 Added support for using libsamplerate to do audio resampling 2017-01-06 02:16:26 -08:00
Sam Lantinga
2373e22054 Don't do any audio conversion if none is necessary 2017-01-05 23:53:46 -08:00
Ryan C. Gordon
29fb138f51 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
591dff71c2 Fixed a few compiler warnings. 2017-01-05 20:11:19 -05:00
Ryan C. Gordon
70608017eb audio: Added SDL_AudioStream. Non-power-of-two resampling now works!
--HG--
extra : rebase_source : f6b2eb0c8a4d8869879112d60abe32962839fe7a
2017-01-05 19:29:38 -05:00
Ryan C. Gordon
02fd7b4a1e audio: More effort to improve and simplify audio resamplers.
--HG--
extra : rebase_source : a46522900178929c58d4e5442f710eb1ae31e91e
2017-01-05 19:12:20 -05:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Philipp Wiesemann
5665ff1e98 Fixed audio conversion for unsigned 16 bit data. 2016-11-07 21:10:01 +01:00
Sam Lantinga
a966c3035b Fixed Windows build 2016-11-05 01:52:28 -07:00
Ryan C. Gordon
6441c50b51 Also patched to compile on C89 compilers. 2016-11-05 03:56:55 -04:00
Ryan C. Gordon
a053163b55 Patched to compile on C89 compilers. 2016-11-05 03:53:59 -04:00
Ryan C. Gordon
9d3696362e 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).

--HG--
extra : amend_source : ce9deadd24e237eb83d2ef900c493f25c7cf3a80
2016-11-05 02:34:38 -04:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
James Legg
9c3587ee5d Fix audio conversion when channel count changes
- Use the SDL_AUDIO_MASK_DATATYPE bit when selecting an implementation
  where it matters. Previously two existing AUDIO_F32 cases had been
  written, but were unreachable.
- Add AUDIO_F32 case for SDL_ConvertSurround_4.
- Fix incorrect pointer arithmetic causing the 2 to 6 channel
  conversion for 4 byte audio formats to read and write beyond the end
  of the buffer.
2014-02-21 13:57:53 +00:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
Ryan C. Gordon
82edee6971 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.

--HG--
extra : rebase_source : ddf4a4c0dc2c554b98c82700798f343cd91b16e3
2013-11-24 23:56:17 -05:00
Ryan C. Gordon
de2ec2b443 Fixed off-by-one error in SDL_ConvertStereo().
Fixes Bugzilla #561.

--HG--
extra : rebase_source : a21159567a0a8a9485c46d4c67e57224948952a0
2013-07-12 01:26:43 -04:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Ryan C. Gordon
4f438b70a2 Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
2013-03-31 12:48:50 -04:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Andreas Schiffler
b507ef3afa Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops) 2013-01-21 09:16:27 -08:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Ryan C. Gordon
df8784cd61 Replaced some assert macros with SDL_assert. 2012-02-07 02:11:15 -05:00