Commit graph

472 commits

Author SHA1 Message Date
Ryan C. Gordon
13b57b17fd Minor ALSA tweaks (include-once macro name, len for memset() more clear).
--HG--
extra : rebase_source : 44c8b456ce5867d127b8e307c7854d1bab882a50
2013-07-07 02:03:50 -04:00
Ryan C. Gordon
0634073030 Patched to compile on pre-C99 compilers. 2013-07-05 01:31:02 -04:00
Ryan C. Gordon
522eeaf814 Don't crash if SDL_AudioQuit() is called twice in a row.
Fixes Bugzilla #1396.
2013-07-05 00:54:00 -04:00
Ryan C. Gordon
0ea9cabb50 Don't close already-closed audio devices during SDL_Quit().
Otherwise, we spam a bunch of unnecessary SDL_SetError() calls.

Fixes Bugzilla #1791.
2013-07-05 00:30:23 -04:00
Sam Lantinga
8cf62ac298 Merged 2013-06-28 20:46:11 -07:00
Sam Lantinga
3fb130cb39 Fixed bug 1913 - state->index may get negative in SDL_wave.c file.
Nitz

In function:
static Sint32
IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
{
 const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
    const Sint32 min_audioval = -(1 << (16 - 1));
    const int index_table[16] = {
        -1, -1, -1, -1,
        2, 4, 6, 8,
        -1, -1, -1, -1,
        2, 4, 6, 8
    };
    const Sint32 step_table[89] = {
        7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
        34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
        143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
        449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
        1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
        3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
        9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
        22385, 24623, 27086, 29794, 32767
    };
    Sint32 delta, step;

    /* Compute difference and new sample value */
    step = step_table[state->index];
    // Some Code
}

Here step_table array have the state->index, which might be negative, so it is unsafe to assign this index to step_table array directly.
There would be a check before that to confirm its value.
2013-06-18 00:50:35 -07:00
Sam Lantinga
de9566518f Fixed some Visual Studio analyze warnings 2013-06-15 02:46:32 -07:00
Sam Lantinga
9ce206cdc0 Fixed compiling XAudio2 code with mingw64 2013-05-26 12:20:23 -07:00
Philipp Wiesemann
a5ba9c22a7 Changed three similar error messages to contain more context. 2013-05-26 11:54:17 +02:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Philipp Wiesemann
f19e013294 Removed unused variables from C source files. 2013-04-29 23:54:22 +02:00
David Ludwig
41ce3814e2 WinRT: merged with latest, official, SDL 2.x sources (at rev. bea100d73d13) 2013-04-14 11:42:55 -04:00
Ryan C. Gordon
2df4ed556e Changed audio subsystem's OpenDevice interface to return -1 on error.
This lets us 'return SDL_SetError("whatever");' on one line.

 Fixes Bugzilla #1778.
2013-03-31 13:05:40 -04: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
3afbe992d5 Removed Nintendo DS support since nobody has volunteered to maintain it for over a year. 2013-03-17 09:44:58 -07:00
Captain Lex
47dac69dc7 Add PSP support 2013-03-17 20:07:02 +08:00
Sam Lantinga
c6388c87c1 Changed the name of SDL_mutexP() SDL_mutexV() 2013-03-07 20:12:40 -08:00
Shawn Walker
6398f00da7 Fix pulseaudio dynamic linking for Solaris builds.
Fix Solaris Studio compilation errors.
Fix sunaudio backend for SDL2.
2013-02-25 22:46:21 +00:00
Sam Lantinga
a5e77bb96f Unload the PulseAudio library if the pulseaudio connection isn't available. 2013-02-26 23:26:00 -08:00
Sam Lantinga
90cde1bd46 Check to make sure we can connect to PulseAudio before we use it. 2013-02-26 16:31:52 -08:00
David Ludwig
776ebe3bda WinRT: merged with latest, official, SDL 2.x code 2013-02-23 20:01:46 -05:00
Ryan C. Gordon
c02c04cdba Backed out changeset 9fea506e48ab
Sam beat me to this on a different branch, apparently.
2013-02-20 14:49:30 -05:00
Ryan C. Gordon
9269a3af2e Allow SDL_AUDIODRIVER="pulse" to do the right thing.
(We renamed this audio target at some point; the Internet didn't get the memo.)
2013-02-20 13:25:38 -05:00
Sam Lantinga
7da5b83b75 Allow abbreviated strings to be used for driver names.
This allows people to use "pulse" with both SDL 1.2 and 2.0
2013-02-18 20:14:24 -08:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
David Ludwig
a1ef55a6f7 WinRT: added Windows Phone 8 project files, and got SDL compiling under them 2013-01-28 23:13:07 -05:00
Sam Lantinga
78b69734b8 Fixed bug 1679 - Error in buffer size setting in Haiku/BeOS audio driver
PulkoMandy

Just like in SDL, audio buffer sizes for BeOS and Haiku BSoundPlayer are sized
in bytes, not frames. SDL was feeding the wrong value, leading to buffers
smaller than expected and weird behaviour in some unsuspecting programs
(noticed it in HivelyTracker but others are likely affected as well. The fix is
fortunately very simple
2013-02-11 20:56:34 -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
David Ludwig
cc456a7516 WinRT: added a note to try removing some WinRT-specific code from SDL_xaudio2.c 2012-12-30 13:03:45 -05:00
David Ludwig
0b7cfac19e WinRT: fixed XAudio2 crash bug + enabled XAudio2 backend 2012-12-30 12:57:33 -05:00
David Ludwig
643b3f0a30 WinRT: merged with the latest official SDL source 2012-12-16 22:02:01 -05:00
Sam Lantinga
3899bd164f Fixed permissions for code generation scripts 2012-12-11 12:01:04 -08:00
David Ludwig
6e713b5e0f WinRT: fixed Win32 compile error in XAudio2 backend 2012-11-25 14:45:22 -05:00
David Ludwig
be90b123c3 WinRT: got XAudio2 sort-of working (it plays stuff poorly, then crashes) 2012-11-24 11:19:06 -05:00
David Ludwig
c4d055488f WinRT: got the XAudio2 backend compiling (but not running, yet) 2012-11-22 22:34:50 -05:00
Sam Lantinga
6f52124aad Fixed bug 1632 - iOS CoreAudio doesn't close
C.W. Betts 2012-10-28 19:42:01 PDT

I noticed when looking through the CoreAudio code of SDL 2.0 that there was a
fix me wondering how iOS closed the audio system. While working on my own audio
code on PlayerPRO, I discovered that Carbon's component code was replaced in
the audio subsystem with Audio Component Services.
2012-11-02 09:28:40 -07:00
Sam Lantinga
68ee3bad84 Allow playing iPod music in the background of SDL applications.
You can always change your audio session category afterwards if you want custom behavior.
2012-11-01 19:08:12 -07:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Sam Lantinga
d2b7ba63d1 NetBSD patch to use AUDIO_GETBUFINFO when available (contributed by jmcneill) 2012-09-25 20:47:38 -07:00
Ryan C. Gordon
5c732d6324 Removed Windows CE support from SDL 2.0.
It's a long-dead platform, and we don't have any way to build for, test, or
maintain it, so there's no sense in doing acrobatics to support it.

If you need Windows CE support, use SDL 1.2. If you need Windows Phone support,
send SDL 2.0 patches for the newer Windows Mobile platform.
2012-09-15 10:59:39 -04:00
Ryan C. Gordon
bd6eef53b6 Removed a FIXME; RemoteIO is correct for iOS.
--HG--
extra : rebase_source : b7707b74bcdcafe4165a8c6eb7982c23fb2b9d0e
2012-09-02 19:37:36 -04:00
Ryan C. Gordon
a4a3cff536 Fixed compiler warning. 2012-08-30 12:58:58 -07:00
Ryan C. Gordon
8912814135 Removed some unused variables that gcc 4.6.1 complains about. 2012-08-09 14:14:41 -04:00
Sam Lantinga
7b6f9ccd63 Removed unneeded audio buffer memset() for consistent behavior on all platforms. 2012-07-05 12:16:44 -04:00
Ryan C. Gordon
df8784cd61 Replaced some assert macros with SDL_assert. 2012-02-07 02:11:15 -05:00
Sam Lantinga
3fe05cfb55 Better interpolation for the x4 upsampling case 2012-01-12 22:54:09 -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
d3d897c6d0 Fixed memory corruption in the upsampling code, caught by valgrind 2012-01-08 17:31:11 -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
a9bcdb83a9 Fixed bug 1014 - SDL_ConvertAudio crashes
The patch Mark attached looks good and valgrind gives it a clean bill of health:

Mark.Howson@ntu.ac.uk 2010-12-15 07:45:25 PST

Reproducible here under Windows and Linux. Looking at the code for
SDL_Upsample_S16LSB_2c:

const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
while (dst > target) {
   dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   dst -= 2;
...

if dstsize is odd (and therefore dst), it'll write to target[1] which is one
byte before the allocated buf.

The attached patch to sdlgenaudiocvt.pl changes dst > target to dst >= target,
and removes the - $channels for the upsample case. The patch is not fully
tested, but seems to work here.
2012-01-08 17:10:57 -05:00