Commit graph

119 commits

Author SHA1 Message Date
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
Sam Lantinga
17d38b0d37 Fixed issue where there was a garbage sample at the end of the buffer. 2012-01-12 21:42:35 -05:00
Sam Lantinga
7e2e5d34e6 Fixed bug 1091 - Hardcoded size in SDL_audiocvt.c may lead to heap/stack corruption
Markovtsev Vadim 2011-01-18 22:00:16 PST

SDL_audiocvt.c:

static void SDLCALL
SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format):

#define dup_chans_1_to_2(type) \
    { \
        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
        for (i = cvt->len_cvt / 2; i; --i, --src) { \
            const type val = *src; \
            dst -= 2; \
            dst[0] = dst[1] = val; \
        } \
    }

Pay attention to cvt->len_cvt / 2. 2 is the sizeof(Uint16), hovewer, below we
see that the conversion function supports Uint8 and Uint32:

switch (SDL_AUDIO_BITSIZE(format)) {
    case 8:
        dup_chans_1_to_2(Uint8);
        break;
    case 16:
        dup_chans_1_to_2(Uint16);
        break;
    case 32:
        dup_chans_1_to_2(Uint32);
        break;
    }

If type is Uint32, src will be decreased twice as it should be, memory being
written before the cvt->buf. If type is Uint8, the conversion will not be
complete. I suggest to change that define to

#define dup_chans_1_to_2(type) \
    { \
        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
        for (i = cvt->len_cvt / sizeof(type); i; --i, --src) { \
            const type val = *src; \
            dst -= 2; \
            dst[0] = dst[1] = val; \
        } \
    }

I tested that and now it's working fine. I did not consider the similar defines
in functions nearby.
2012-01-08 17:20:33 -05:00
Sam Lantinga
028e5dcdbd Happy New Year! 2011-12-31 09:28:07 -05:00
Sam Lantinga
b0660ba5ff SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
e5803d148c Happy 2011! :) 2011-02-11 22:37:15 -08:00
Sam Lantinga
4d3df8b3e3 Fixed bug #926
Updated copyright to LGPL version 2.1 and year 2010

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404453
2010-01-24 21:10:53 +00:00
Sam Lantinga
f0b63f9249 Add error messages for failure cases
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404232
2009-11-25 06:00:00 +00:00
Sam Lantinga
628262d3af indent
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403502
2009-01-14 04:25:32 +00:00
Sam Lantinga
e43f6d619e Fixed Visual C++ build
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403494
2009-01-12 08:46:28 +00:00
Ryan C. Gordon
fea75bcab7 First shot at new audio resampling code.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403483
2009-01-11 04:46:42 +00:00
Sam Lantinga
e32916c7f0 Fixed Visual C++ release build for Visual C++ 2005
* Some math functions become intrinsic in release mode, so we need to
  convert all the math functions into SDL math functions, like we did
  with the stdlib functions.
* Constant initializers of 8-bit values become calls to memset() in
  release mode, but memset() itself is an intrinsic when explicitly
  called.  So we'll just explicitly call memset() in those cases.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403474
2009-01-10 18:32:24 +00:00
Sam Lantinga
60c39418a7 indent
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403345
2008-12-20 08:41:05 +00:00
Ryan C. Gordon
b18cb0012e More resampling fixes.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403343
2008-12-19 09:15:59 +00:00
Ryan C. Gordon
83de18855b Allocate SDL_AudioCVT::coeff before using it.
FIXME: this is a memory leak. We don't have an SDL_FreeAudioCVT() yet.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403342
2008-12-19 08:30:26 +00:00
Ryan C. Gordon
45ed26c3c2 Use SDL_zerop instead of SDL_memset.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403341
2008-12-19 06:43:41 +00:00
Ryan C. Gordon
d7d4dc4b7e Zero out SDL_AudioCVT struct before using it, to ensure it's all initialized.
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403340
2008-12-19 06:01:03 +00:00
Sam Lantinga
0c30a927ed Updated copyright date
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403321
2008-12-08 00:27:32 +00:00
Sam Lantinga
a3c6362a20 Don't include <math.h> when HAVE_MATH_H isn't defined
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403225
2008-10-12 16:21:36 +00:00
Sam Lantinga
c6ac35a2bb Final merge of Google Summer of Code 2008 work...
Bring SDL to iPhone and iPod Touch
by Holmes Futrell, mentored by Sam Lantinga

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403222
2008-10-04 06:46:59 +00:00
Sam Lantinga
809f6ba3b4 Updated Visual C++ build
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403216
2008-09-15 07:34:36 +00:00
Sam Lantinga
cd839b4bd3 Fixed a bunch of compile warnings on Mac OS X
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403191
2008-09-01 16:04:20 +00:00
Sam Lantinga
5e73fc7c16 Fixed Visual Studio compilation problems
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403179
2008-08-26 07:34:49 +00:00
Sam Lantinga
0eeb8c92b6 Final merge of Google Summer of Code 2008 work...
Audio Ideas - Resampling and Pitch Shifting
by Aaron Wishnick, mentored by Ryan C. Gordon

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403165
2008-08-25 15:08:59 +00:00
Sam Lantinga
ed60e3a7d4 Fixes for compiling with Visual C++ 8.0 Express Edition
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402369
2007-06-19 05:53:56 +00:00