mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -46,18 +46,21 @@
|
|||
#define _PATH_DEV_AUDIO "/dev/audio"
|
||||
#endif
|
||||
|
||||
static SDL_INLINE void
|
||||
test_device(const char *fname, int flags, int (*test) (int fd),
|
||||
SDL_AddAudioDevice addfn)
|
||||
static void
|
||||
test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
|
||||
{
|
||||
struct stat sb;
|
||||
if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
|
||||
const int audio_fd = open(fname, flags, 0);
|
||||
if (audio_fd >= 0) {
|
||||
if (test(audio_fd)) {
|
||||
addfn(fname);
|
||||
}
|
||||
const int okay = test(audio_fd);
|
||||
close(audio_fd);
|
||||
if (okay) {
|
||||
static size_t dummyhandle = 0;
|
||||
dummyhandle++;
|
||||
SDL_assert(dummyhandle != 0);
|
||||
SDL_AddAudioDevice(iscapture, fname, (void *) dummyhandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,11 +71,10 @@ test_stub(int fd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
|
||||
SDL_AddAudioDevice addfn)
|
||||
static void
|
||||
SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
|
||||
const char *audiodev;
|
||||
char audiopath[1024];
|
||||
|
||||
|
|
@ -97,17 +99,25 @@ SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
|
|||
}
|
||||
}
|
||||
}
|
||||
test_device(audiodev, flags, test, addfn);
|
||||
test_device(iscapture, audiodev, flags, test);
|
||||
|
||||
if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
|
||||
int instance = 0;
|
||||
while (instance++ <= 64) {
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance);
|
||||
test_device(audiopath, flags, test, addfn);
|
||||
test_device(iscapture, audiopath, flags, test);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
|
||||
{
|
||||
SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
|
||||
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
|
||||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -33,7 +33,6 @@
|
|||
#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
|
||||
#endif
|
||||
|
||||
void SDL_EnumUnixAudioDevices(int iscapture, int classic,
|
||||
int (*test) (int fd), SDL_AddAudioDevice addfn);
|
||||
extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int));
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -2300,7 +2300,7 @@ SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 16;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
|
||||
const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -2332,7 +2332,7 @@ SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 16;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = (Uint8 *) cvt->buf;
|
||||
const Uint8 *src = (Uint8 *) cvt->buf;
|
||||
|
|
@ -2364,7 +2364,7 @@ SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
|
||||
const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -2401,7 +2401,7 @@ SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = (Uint8 *) cvt->buf;
|
||||
const Uint8 *src = (Uint8 *) cvt->buf;
|
||||
|
|
@ -2438,7 +2438,7 @@ SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
|
||||
const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -2485,7 +2485,7 @@ SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = (Uint8 *) cvt->buf;
|
||||
const Uint8 *src = (Uint8 *) cvt->buf;
|
||||
|
|
@ -2532,7 +2532,7 @@ SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 96;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
|
||||
const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -2589,7 +2589,7 @@ SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 96;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = (Uint8 *) cvt->buf;
|
||||
const Uint8 *src = (Uint8 *) cvt->buf;
|
||||
|
|
@ -2646,7 +2646,7 @@ SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
|
||||
const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -2713,7 +2713,7 @@ SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint8 *dst = (Uint8 *) cvt->buf;
|
||||
const Uint8 *src = (Uint8 *) cvt->buf;
|
||||
|
|
@ -2780,7 +2780,7 @@ SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 16;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
|
||||
const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -2812,7 +2812,7 @@ SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 16;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = (Sint8 *) cvt->buf;
|
||||
const Sint8 *src = (Sint8 *) cvt->buf;
|
||||
|
|
@ -2844,7 +2844,7 @@ SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
|
||||
const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -2881,7 +2881,7 @@ SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = (Sint8 *) cvt->buf;
|
||||
const Sint8 *src = (Sint8 *) cvt->buf;
|
||||
|
|
@ -2918,7 +2918,7 @@ SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
|
||||
const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -2965,7 +2965,7 @@ SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = (Sint8 *) cvt->buf;
|
||||
const Sint8 *src = (Sint8 *) cvt->buf;
|
||||
|
|
@ -3012,7 +3012,7 @@ SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 96;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
|
||||
const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -3069,7 +3069,7 @@ SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 96;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = (Sint8 *) cvt->buf;
|
||||
const Sint8 *src = (Sint8 *) cvt->buf;
|
||||
|
|
@ -3126,7 +3126,7 @@ SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
|
||||
const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -3193,7 +3193,7 @@ SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint8 *dst = (Sint8 *) cvt->buf;
|
||||
const Sint8 *src = (Sint8 *) cvt->buf;
|
||||
|
|
@ -3260,7 +3260,7 @@ SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -3292,7 +3292,7 @@ SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -3324,7 +3324,7 @@ SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -3361,7 +3361,7 @@ SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -3398,7 +3398,7 @@ SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -3445,7 +3445,7 @@ SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -3492,7 +3492,7 @@ SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -3549,7 +3549,7 @@ SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -3606,7 +3606,7 @@ SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -3673,7 +3673,7 @@ SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -3740,7 +3740,7 @@ SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -3772,7 +3772,7 @@ SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -3804,7 +3804,7 @@ SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -3841,7 +3841,7 @@ SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -3878,7 +3878,7 @@ SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -3925,7 +3925,7 @@ SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -3972,7 +3972,7 @@ SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -4029,7 +4029,7 @@ SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -4086,7 +4086,7 @@ SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -4153,7 +4153,7 @@ SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -4220,7 +4220,7 @@ SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -4252,7 +4252,7 @@ SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -4284,7 +4284,7 @@ SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -4321,7 +4321,7 @@ SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -4358,7 +4358,7 @@ SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -4405,7 +4405,7 @@ SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -4452,7 +4452,7 @@ SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -4509,7 +4509,7 @@ SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -4566,7 +4566,7 @@ SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
|
||||
const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -4633,7 +4633,7 @@ SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Uint16 *dst = (Uint16 *) cvt->buf;
|
||||
const Uint16 *src = (Uint16 *) cvt->buf;
|
||||
|
|
@ -4700,7 +4700,7 @@ SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -4732,7 +4732,7 @@ SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 32;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -4764,7 +4764,7 @@ SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -4801,7 +4801,7 @@ SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -4838,7 +4838,7 @@ SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -4885,7 +4885,7 @@ SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -4932,7 +4932,7 @@ SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -4989,7 +4989,7 @@ SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 192;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -5046,7 +5046,7 @@ SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
|
||||
const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -5113,7 +5113,7 @@ SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint16 *dst = (Sint16 *) cvt->buf;
|
||||
const Sint16 *src = (Sint16 *) cvt->buf;
|
||||
|
|
@ -5180,7 +5180,7 @@ SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -5212,7 +5212,7 @@ SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5244,7 +5244,7 @@ SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -5281,7 +5281,7 @@ SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5318,7 +5318,7 @@ SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -5365,7 +5365,7 @@ SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5412,7 +5412,7 @@ SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -5469,7 +5469,7 @@ SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5526,7 +5526,7 @@ SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -5593,7 +5593,7 @@ SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5660,7 +5660,7 @@ SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -5692,7 +5692,7 @@ SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5724,7 +5724,7 @@ SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -5761,7 +5761,7 @@ SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5798,7 +5798,7 @@ SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -5845,7 +5845,7 @@ SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -5892,7 +5892,7 @@ SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -5949,7 +5949,7 @@ SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -6006,7 +6006,7 @@ SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
|
||||
const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -6073,7 +6073,7 @@ SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
Sint32 *dst = (Sint32 *) cvt->buf;
|
||||
const Sint32 *src = (Sint32 *) cvt->buf;
|
||||
|
|
@ -6140,7 +6140,7 @@ SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 1;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -6172,7 +6172,7 @@ SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6204,7 +6204,7 @@ SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 2;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -6241,7 +6241,7 @@ SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6278,7 +6278,7 @@ SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 4;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -6325,7 +6325,7 @@ SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6372,7 +6372,7 @@ SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 6;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -6429,7 +6429,7 @@ SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6486,7 +6486,7 @@ SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 8;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -6553,7 +6553,7 @@ SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6620,7 +6620,7 @@ SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 1;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||
|
|
@ -6652,7 +6652,7 @@ SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 64;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6684,7 +6684,7 @@ SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 2;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||
|
|
@ -6721,7 +6721,7 @@ SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 128;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6758,7 +6758,7 @@ SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 4;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||
|
|
@ -6805,7 +6805,7 @@ SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 256;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6852,7 +6852,7 @@ SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 6;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||
|
|
@ -6909,7 +6909,7 @@ SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 384;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
@ -6966,7 +6966,7 @@ SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
float *dst = ((float *) (cvt->buf + dstsize)) - 8;
|
||||
const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
|
||||
|
|
@ -7033,7 +7033,7 @@ SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - 512;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
|
||||
register int eps = 0;
|
||||
float *dst = (float *) cvt->buf;
|
||||
const float *src = (float *) cvt->buf;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -30,34 +30,83 @@
|
|||
typedef struct SDL_AudioDevice SDL_AudioDevice;
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
/* Used by audio targets during DetectDevices() */
|
||||
typedef void (*SDL_AddAudioDevice)(const char *name);
|
||||
/* Audio targets should call this as devices are added to the system (such as
|
||||
a USB headset being plugged in), and should also be called for
|
||||
for every device found during DetectDevices(). */
|
||||
extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle);
|
||||
|
||||
/* Audio targets should call this as devices are removed, so SDL can update
|
||||
its list of available devices. */
|
||||
extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
|
||||
|
||||
/* Audio targets should call this if an opened audio device is lost while
|
||||
being used. This can happen due to i/o errors, or a device being unplugged,
|
||||
etc. If the device is totally gone, please also call SDL_RemoveAudioDevice()
|
||||
as appropriate so SDL's list of devices is accurate. */
|
||||
extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device);
|
||||
|
||||
|
||||
/* This is the size of a packet when using SDL_QueueAudio(). We allocate
|
||||
these as necessary and pool them, under the assumption that we'll
|
||||
eventually end up with a handful that keep recycling, meeting whatever
|
||||
the app needs. We keep packing data tightly as more arrives to avoid
|
||||
wasting space, and if we get a giant block of data, we'll split them
|
||||
into multiple packets behind the scenes. My expectation is that most
|
||||
apps will have 2-3 of these in the pool. 8k should cover most needs, but
|
||||
if this is crippling for some embedded system, we can #ifdef this.
|
||||
The system preallocates enough packets for 2 callbacks' worth of data. */
|
||||
#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)
|
||||
|
||||
/* Used by apps that queue audio instead of using the callback. */
|
||||
typedef struct SDL_AudioBufferQueue
|
||||
{
|
||||
Uint8 data[SDL_AUDIOBUFFERQUEUE_PACKETLEN]; /* packet data. */
|
||||
Uint32 datalen; /* bytes currently in use in this packet. */
|
||||
Uint32 startpos; /* bytes currently consumed in this packet. */
|
||||
struct SDL_AudioBufferQueue *next; /* next item in linked list. */
|
||||
} SDL_AudioBufferQueue;
|
||||
|
||||
typedef struct SDL_AudioDriverImpl
|
||||
{
|
||||
void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
|
||||
int (*OpenDevice) (_THIS, const char *devname, int iscapture);
|
||||
void (*DetectDevices) (void);
|
||||
int (*OpenDevice) (_THIS, void *handle, const char *devname, int iscapture);
|
||||
void (*ThreadInit) (_THIS); /* Called by audio thread at start */
|
||||
void (*WaitDevice) (_THIS);
|
||||
void (*PlayDevice) (_THIS);
|
||||
int (*GetPendingBytes) (_THIS);
|
||||
Uint8 *(*GetDeviceBuf) (_THIS);
|
||||
void (*WaitDone) (_THIS);
|
||||
void (*CloseDevice) (_THIS);
|
||||
void (*LockDevice) (_THIS);
|
||||
void (*UnlockDevice) (_THIS);
|
||||
void (*FreeDeviceHandle) (void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */
|
||||
void (*Deinitialize) (void);
|
||||
|
||||
/* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */
|
||||
|
||||
/* Some flags to push duplicate code into the core and reduce #ifdefs. */
|
||||
/* !!! FIXME: these should be SDL_bool */
|
||||
int ProvidesOwnCallbackThread;
|
||||
int SkipMixerLock; /* !!! FIXME: do we need this anymore? */
|
||||
int HasCaptureSupport;
|
||||
int OnlyHasDefaultOutputDevice;
|
||||
int OnlyHasDefaultInputDevice;
|
||||
int AllowsArbitraryDeviceNames;
|
||||
} SDL_AudioDriverImpl;
|
||||
|
||||
|
||||
typedef struct SDL_AudioDeviceItem
|
||||
{
|
||||
void *handle;
|
||||
struct SDL_AudioDeviceItem *next;
|
||||
#if (defined(__GNUC__) && (__GNUC__ <= 2))
|
||||
char name[1]; /* actually variable length. */
|
||||
#else
|
||||
char name[];
|
||||
#endif
|
||||
} SDL_AudioDeviceItem;
|
||||
|
||||
|
||||
typedef struct SDL_AudioDriver
|
||||
{
|
||||
/* * * */
|
||||
|
|
@ -70,11 +119,14 @@ typedef struct SDL_AudioDriver
|
|||
|
||||
SDL_AudioDriverImpl impl;
|
||||
|
||||
char **outputDevices;
|
||||
/* A mutex for device detection */
|
||||
SDL_mutex *detectionLock;
|
||||
SDL_bool captureDevicesRemoved;
|
||||
SDL_bool outputDevicesRemoved;
|
||||
int outputDeviceCount;
|
||||
|
||||
char **inputDevices;
|
||||
int inputDeviceCount;
|
||||
SDL_AudioDeviceItem *outputDevices;
|
||||
SDL_AudioDeviceItem *inputDevices;
|
||||
} SDL_AudioDriver;
|
||||
|
||||
|
||||
|
|
@ -92,6 +144,7 @@ struct SDL_AudioDevice
|
|||
{
|
||||
/* * * */
|
||||
/* Data common to all devices */
|
||||
SDL_AudioDeviceID id;
|
||||
|
||||
/* The current audio specification (shared with audio thread) */
|
||||
SDL_AudioSpec spec;
|
||||
|
|
@ -104,21 +157,29 @@ struct SDL_AudioDevice
|
|||
SDL_AudioStreamer streamer;
|
||||
|
||||
/* Current state flags */
|
||||
/* !!! FIXME: should be SDL_bool */
|
||||
int iscapture;
|
||||
int enabled;
|
||||
int enabled; /* true if device is functioning and connected. */
|
||||
int shutdown; /* true if we are signaling the play thread to end. */
|
||||
int paused;
|
||||
int opened;
|
||||
|
||||
/* Fake audio buffer for when the audio hardware is busy */
|
||||
Uint8 *fake_stream;
|
||||
|
||||
/* A semaphore for locking the mixing buffers */
|
||||
/* A mutex for locking the mixing buffers */
|
||||
SDL_mutex *mixer_lock;
|
||||
|
||||
/* A thread to feed the audio device */
|
||||
SDL_Thread *thread;
|
||||
SDL_threadID threadid;
|
||||
|
||||
/* Queued buffers (if app not using callback). */
|
||||
SDL_AudioBufferQueue *buffer_queue_head; /* device fed from here. */
|
||||
SDL_AudioBufferQueue *buffer_queue_tail; /* queue fills to here. */
|
||||
SDL_AudioBufferQueue *buffer_queue_pool; /* these are unused packets. */
|
||||
Uint32 queued_bytes; /* number of bytes of audio data in the queue. */
|
||||
|
||||
/* * * */
|
||||
/* Data private to this driver */
|
||||
struct SDL_PrivateAudioData *hidden;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -121,7 +121,8 @@ MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
|||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
Sint8 nybble, stereo;
|
||||
Sint8 nybble;
|
||||
Uint8 stereo;
|
||||
Sint16 *coeff[2];
|
||||
Sint32 new_sample;
|
||||
|
||||
|
|
@ -278,7 +279,8 @@ IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
|
|||
} else if (state->index < 0) {
|
||||
state->index = 0;
|
||||
}
|
||||
step = step_table[state->index];
|
||||
/* explicit cast to avoid gcc warning about using 'char' as array index */
|
||||
step = step_table[(int)state->index];
|
||||
delta = step >> 3;
|
||||
if (nybble & 0x04)
|
||||
delta += step;
|
||||
|
|
@ -343,8 +345,8 @@ IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
|
|||
/* Check to make sure we have enough variables in the state array */
|
||||
channels = IMA_ADPCM_state.wavefmt.channels;
|
||||
if (channels > SDL_arraysize(IMA_ADPCM_state.state)) {
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %d channels",
|
||||
SDL_arraysize(IMA_ADPCM_state.state));
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %u channels",
|
||||
(unsigned int)SDL_arraysize(IMA_ADPCM_state.state));
|
||||
return (-1);
|
||||
}
|
||||
state = IMA_ADPCM_state.state;
|
||||
|
|
@ -458,7 +460,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
|||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ((chunk.magic == FACT) || (chunk.magic == LIST));
|
||||
} while ((chunk.magic == FACT) || (chunk.magic == LIST) || (chunk.magic == BEXT) || (chunk.magic == JUNK));
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *) chunk.data;
|
||||
|
|
@ -493,8 +495,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
|||
IMA_ADPCM_encoded = 1;
|
||||
break;
|
||||
case MP3_CODE:
|
||||
SDL_SetError("MPEG Layer 3 data not supported",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
SDL_SetError("MPEG Layer 3 data not supported");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,6 +29,8 @@
|
|||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define BEXT 0x74786562 /* "bext" */
|
||||
#define JUNK 0x4B4E554A /* "JUNK" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
#define PCM_CODE 0x0001
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -320,7 +320,7 @@ ALSA_PlayDevice(_THIS)
|
|||
/* Hmm, not much we can do - abort */
|
||||
fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
|
||||
ALSA_snd_strerror(status));
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -465,7 +465,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
|
|||
}
|
||||
|
||||
static int
|
||||
ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int status = 0;
|
||||
snd_pcm_t *pcm_handle = NULL;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
#include <android/log.h>
|
||||
|
||||
static void * audioDevice;
|
||||
static SDL_AudioDevice* audioDevice = NULL;
|
||||
|
||||
static int
|
||||
AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
AndroidAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format;
|
||||
|
||||
|
|
@ -49,6 +49,11 @@ AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
audioDevice = this;
|
||||
|
||||
this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
|
||||
if (this->hidden == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
while (test_format != 0) { /* no "UNKNOWN" constant */
|
||||
|
|
@ -110,6 +115,10 @@ AndroidAUD_CloseDevice(_THIS)
|
|||
Android_JNI_CloseAudioDevice();
|
||||
|
||||
if (audioDevice == this) {
|
||||
if (audioDevice->hidden != NULL) {
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
audioDevice = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -135,6 +144,41 @@ AudioBootStrap ANDROIDAUD_bootstrap = {
|
|||
"android", "SDL Android audio driver", AndroidAUD_Init, 0
|
||||
};
|
||||
|
||||
/* Pause (block) all non already paused audio devices by taking their mixer lock */
|
||||
void AndroidAUD_PauseDevices(void)
|
||||
{
|
||||
/* TODO: Handle multiple devices? */
|
||||
struct SDL_PrivateAudioData *private;
|
||||
if(audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
|
||||
if (audioDevice->paused) {
|
||||
/* The device is already paused, leave it alone */
|
||||
private->resume = SDL_FALSE;
|
||||
}
|
||||
else {
|
||||
SDL_LockMutex(audioDevice->mixer_lock);
|
||||
audioDevice->paused = SDL_TRUE;
|
||||
private->resume = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Resume (unblock) all non already paused audio devices by releasing their mixer lock */
|
||||
void AndroidAUD_ResumeDevices(void)
|
||||
{
|
||||
/* TODO: Handle multiple devices? */
|
||||
struct SDL_PrivateAudioData *private;
|
||||
if(audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
|
||||
if (private->resume) {
|
||||
audioDevice->paused = SDL_FALSE;
|
||||
private->resume = SDL_FALSE;
|
||||
SDL_UnlockMutex(audioDevice->mixer_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_ANDROID */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
/* Resume device if it was paused automatically */
|
||||
int resume;
|
||||
};
|
||||
|
||||
static void AndroidAUD_CloseDevice(_THIS);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -151,7 +151,7 @@ ARTS_WaitDevice(_THIS)
|
|||
/* Check every 10 loops */
|
||||
if (this->hidden->parent && (((++cnt) % 10) == 0)) {
|
||||
if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ ARTS_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
|
|
@ -229,7 +229,7 @@ ARTS_Suspend(void)
|
|||
}
|
||||
|
||||
static int
|
||||
ARTS_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int rc = 0;
|
||||
int bits = 0, frag_spec = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -51,9 +51,9 @@
|
|||
|
||||
|
||||
static void
|
||||
BSDAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
BSDAUDIO_DetectDevices(void)
|
||||
{
|
||||
SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn);
|
||||
SDL_EnumUnixAudioDevices(0, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ BSDAUDIO_WaitDevice(_THIS)
|
|||
the user know what happened.
|
||||
*/
|
||||
fprintf(stderr, "SDL: %s\n", message);
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
/* Don't try to close - may hang */
|
||||
this->hidden->audio_fd = -1;
|
||||
#ifdef DEBUG_AUDIO
|
||||
|
|
@ -195,7 +195,7 @@ BSDAUDIO_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
|
|
@ -224,7 +224,7 @@ BSDAUDIO_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
BSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
SDL_AudioFormat format = 0;
|
||||
|
|
@ -348,6 +348,8 @@ BSDAUDIO_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf;
|
||||
impl->CloseDevice = BSDAUDIO_CloseDevice;
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -19,6 +19,9 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_COREAUDIO
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
|
@ -37,31 +40,48 @@ static void COREAUDIO_CloseDevice(_THIS);
|
|||
}
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data);
|
||||
static const AudioObjectPropertyAddress devlist_address = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
static void
|
||||
addToDevList(const char *name, AudioDeviceID devId, void *data)
|
||||
typedef void (*addDevFn)(const char *name, const int iscapture, AudioDeviceID devId, void *data);
|
||||
|
||||
typedef struct AudioDeviceList
|
||||
{
|
||||
SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
|
||||
addfn(name);
|
||||
AudioDeviceID devid;
|
||||
SDL_bool alive;
|
||||
struct AudioDeviceList *next;
|
||||
} AudioDeviceList;
|
||||
|
||||
static AudioDeviceList *output_devs = NULL;
|
||||
static AudioDeviceList *capture_devs = NULL;
|
||||
|
||||
static SDL_bool
|
||||
add_to_internal_dev_list(const int iscapture, AudioDeviceID devId)
|
||||
{
|
||||
AudioDeviceList *item = (AudioDeviceList *) SDL_malloc(sizeof (AudioDeviceList));
|
||||
if (item == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
item->devid = devId;
|
||||
item->alive = SDL_TRUE;
|
||||
item->next = iscapture ? capture_devs : output_devs;
|
||||
if (iscapture) {
|
||||
capture_devs = item;
|
||||
} else {
|
||||
output_devs = item;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *findname;
|
||||
AudioDeviceID devId;
|
||||
int found;
|
||||
} FindDevIdData;
|
||||
|
||||
static void
|
||||
findDevId(const char *name, AudioDeviceID devId, void *_data)
|
||||
addToDevList(const char *name, const int iscapture, AudioDeviceID devId, void *data)
|
||||
{
|
||||
FindDevIdData *data = (FindDevIdData *) _data;
|
||||
if (!data->found) {
|
||||
if (SDL_strcmp(name, data->findname) == 0) {
|
||||
data->found = 1;
|
||||
data->devId = devId;
|
||||
}
|
||||
if (add_to_internal_dev_list(iscapture, devId)) {
|
||||
SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,14 +94,8 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
|||
UInt32 i = 0;
|
||||
UInt32 max = 0;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size);
|
||||
result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size);
|
||||
if (result != kAudioHardwareNoError)
|
||||
return;
|
||||
|
||||
|
|
@ -89,8 +103,8 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
|||
if (devs == NULL)
|
||||
return;
|
||||
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, devs);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||
&devlist_address, 0, NULL, &size, devs);
|
||||
if (result != kAudioHardwareNoError)
|
||||
return;
|
||||
|
||||
|
|
@ -102,10 +116,17 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
|||
AudioBufferList *buflist = NULL;
|
||||
int usable = 0;
|
||||
CFIndex len = 0;
|
||||
const AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyStreamConfiguration,
|
||||
iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
const AudioObjectPropertyAddress nameaddr = {
|
||||
kAudioObjectPropertyName,
|
||||
iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size);
|
||||
if (result != noErr)
|
||||
|
|
@ -133,9 +154,9 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
|||
if (!usable)
|
||||
continue;
|
||||
|
||||
addr.mSelector = kAudioObjectPropertyName;
|
||||
|
||||
size = sizeof (CFStringRef);
|
||||
result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, &size, &cfstr);
|
||||
result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr);
|
||||
if (result != kAudioHardwareNoError)
|
||||
continue;
|
||||
|
||||
|
|
@ -166,79 +187,84 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata)
|
|||
((iscapture) ? "capture" : "output"),
|
||||
(int) *devCount, ptr, (int) dev);
|
||||
#endif
|
||||
addfn(ptr, dev, addfndata);
|
||||
addfn(ptr, iscapture, dev, addfndata);
|
||||
}
|
||||
SDL_free(ptr); /* addfn() would have copied the string. */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
COREAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
free_audio_device_list(AudioDeviceList **list)
|
||||
{
|
||||
build_device_list(iscapture, addToDevList, addfn);
|
||||
AudioDeviceList *item = *list;
|
||||
while (item) {
|
||||
AudioDeviceList *next = item->next;
|
||||
SDL_free(item);
|
||||
item = next;
|
||||
}
|
||||
*list = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
find_device_by_name(_THIS, const char *devname, int iscapture)
|
||||
static void
|
||||
COREAUDIO_DetectDevices(void)
|
||||
{
|
||||
AudioDeviceID devid = 0;
|
||||
OSStatus result = noErr;
|
||||
UInt32 size = 0;
|
||||
UInt32 alive = 0;
|
||||
pid_t pid = 0;
|
||||
build_device_list(SDL_TRUE, addToDevList, NULL);
|
||||
build_device_list(SDL_FALSE, addToDevList, NULL);
|
||||
}
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
0,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (devname == NULL) {
|
||||
size = sizeof (AudioDeviceID);
|
||||
addr.mSelector =
|
||||
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
|
||||
kAudioHardwarePropertyDefaultOutputDevice);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, &devid);
|
||||
CHECK_RESULT("AudioHardwareGetProperty (default device)");
|
||||
} else {
|
||||
FindDevIdData data;
|
||||
SDL_zero(data);
|
||||
data.findname = devname;
|
||||
build_device_list(iscapture, findDevId, &data);
|
||||
if (!data.found) {
|
||||
SDL_SetError("CoreAudio: No such audio device.");
|
||||
return 0;
|
||||
static void
|
||||
build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data)
|
||||
{
|
||||
AudioDeviceList **list = (AudioDeviceList **) data;
|
||||
AudioDeviceList *item;
|
||||
for (item = *list; item != NULL; item = item->next) {
|
||||
if (item->devid == devId) {
|
||||
item->alive = SDL_TRUE;
|
||||
return;
|
||||
}
|
||||
devid = data.devId;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
add_to_internal_dev_list(iscapture, devId); /* new device, add it. */
|
||||
SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId));
|
||||
}
|
||||
|
||||
size = sizeof (alive);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
|
||||
CHECK_RESULT
|
||||
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
|
||||
|
||||
if (!alive) {
|
||||
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
|
||||
return 0;
|
||||
static void
|
||||
reprocess_device_list(const int iscapture, AudioDeviceList **list)
|
||||
{
|
||||
AudioDeviceList *item;
|
||||
AudioDeviceList *prev = NULL;
|
||||
for (item = *list; item != NULL; item = item->next) {
|
||||
item->alive = SDL_FALSE;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyHogMode;
|
||||
size = sizeof (pid);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
|
||||
build_device_list(iscapture, build_device_change_list, list);
|
||||
|
||||
/* some devices don't support this property, so errors are fine here. */
|
||||
if ((result == noErr) && (pid != -1)) {
|
||||
SDL_SetError("CoreAudio: requested device is being hogged.");
|
||||
return 0;
|
||||
/* free items in the list that aren't still alive. */
|
||||
item = *list;
|
||||
while (item != NULL) {
|
||||
AudioDeviceList *next = item->next;
|
||||
if (item->alive) {
|
||||
prev = item;
|
||||
} else {
|
||||
SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid));
|
||||
if (prev) {
|
||||
prev->next = item->next;
|
||||
} else {
|
||||
*list = item->next;
|
||||
}
|
||||
SDL_free(item);
|
||||
}
|
||||
item = next;
|
||||
}
|
||||
}
|
||||
|
||||
this->hidden->deviceID = devid;
|
||||
return 1;
|
||||
/* this is called when the system's list of available audio devices changes. */
|
||||
static OSStatus
|
||||
device_list_changed(AudioObjectID systemObj, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
|
||||
{
|
||||
reprocess_device_list(SDL_TRUE, &capture_devs);
|
||||
reprocess_device_list(SDL_FALSE, &output_devs);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -314,12 +340,54 @@ inputCallback(void *inRefCon,
|
|||
}
|
||||
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
static const AudioObjectPropertyAddress alive_address =
|
||||
{
|
||||
kAudioDevicePropertyDeviceIsAlive,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
static OSStatus
|
||||
device_unplugged(AudioObjectID devid, UInt32 num_addr, const AudioObjectPropertyAddress *addrs, void *data)
|
||||
{
|
||||
SDL_AudioDevice *this = (SDL_AudioDevice *) data;
|
||||
SDL_bool dead = SDL_FALSE;
|
||||
UInt32 isAlive = 1;
|
||||
UInt32 size = sizeof (isAlive);
|
||||
OSStatus error;
|
||||
|
||||
if (!this->enabled) {
|
||||
return 0; /* already known to be dead. */
|
||||
}
|
||||
|
||||
error = AudioObjectGetPropertyData(this->hidden->deviceID, &alive_address,
|
||||
0, NULL, &size, &isAlive);
|
||||
|
||||
if (error == kAudioHardwareBadDeviceError) {
|
||||
dead = SDL_TRUE; /* device was unplugged. */
|
||||
} else if ((error == kAudioHardwareNoError) && (!isAlive)) {
|
||||
dead = SDL_TRUE; /* device died in some other way. */
|
||||
}
|
||||
|
||||
if (dead) {
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
COREAUDIO_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
if (this->hidden->audioUnitOpened) {
|
||||
OSStatus result = noErr;
|
||||
#if MACOSX_COREAUDIO
|
||||
/* Unregister our disconnect callback. */
|
||||
AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
|
||||
#endif
|
||||
|
||||
AURenderCallbackStruct callback;
|
||||
const AudioUnitElement output_bus = 0;
|
||||
const AudioUnitElement input_bus = 1;
|
||||
|
|
@ -331,14 +399,13 @@ COREAUDIO_CloseDevice(_THIS)
|
|||
kAudioUnitScope_Input);
|
||||
|
||||
/* stop processing the audio unit */
|
||||
result = AudioOutputUnitStop(this->hidden->audioUnit);
|
||||
AudioOutputUnitStop(this->hidden->audioUnit);
|
||||
|
||||
/* Remove the input callback */
|
||||
SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
|
||||
result = AudioUnitSetProperty(this->hidden->audioUnit,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
scope, bus, &callback,
|
||||
sizeof(callback));
|
||||
AudioUnitSetProperty(this->hidden->audioUnit,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
scope, bus, &callback, sizeof(callback));
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
CloseComponent(this->hidden->audioUnit);
|
||||
|
|
@ -354,9 +421,63 @@ COREAUDIO_CloseDevice(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
static int
|
||||
prepare_device(_THIS, void *handle, int iscapture)
|
||||
{
|
||||
AudioDeviceID devid = (AudioDeviceID) ((size_t) handle);
|
||||
OSStatus result = noErr;
|
||||
UInt32 size = 0;
|
||||
UInt32 alive = 0;
|
||||
pid_t pid = 0;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
0,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (handle == NULL) {
|
||||
size = sizeof (AudioDeviceID);
|
||||
addr.mSelector =
|
||||
((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
|
||||
kAudioHardwarePropertyDefaultOutputDevice);
|
||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, &devid);
|
||||
CHECK_RESULT("AudioHardwareGetProperty (default device)");
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
|
||||
addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
|
||||
kAudioDevicePropertyScopeOutput;
|
||||
|
||||
size = sizeof (alive);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
|
||||
CHECK_RESULT
|
||||
("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
|
||||
|
||||
if (!alive) {
|
||||
SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyHogMode;
|
||||
size = sizeof (pid);
|
||||
result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
|
||||
|
||||
/* some devices don't support this property, so errors are fine here. */
|
||||
if ((result == noErr) && (pid != -1)) {
|
||||
SDL_SetError("CoreAudio: requested device is being hogged.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
this->hidden->deviceID = devid;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
prepare_audiounit(_THIS, const char *devname, int iscapture,
|
||||
prepare_audiounit(_THIS, void *handle, int iscapture,
|
||||
const AudioStreamBasicDescription * strdesc)
|
||||
{
|
||||
OSStatus result = noErr;
|
||||
|
|
@ -375,8 +496,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
|
|||
kAudioUnitScope_Input);
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
if (!find_device_by_name(this, devname, iscapture)) {
|
||||
SDL_SetError("Couldn't find requested CoreAudio device");
|
||||
if (!prepare_device(this, handle, iscapture)) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -453,13 +573,18 @@ prepare_audiounit(_THIS, const char *devname, int iscapture,
|
|||
result = AudioOutputUnitStart(this->hidden->audioUnit);
|
||||
CHECK_RESULT("AudioOutputUnitStart");
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
/* Fire a callback if the device stops being "alive" (disconnected, etc). */
|
||||
AudioObjectAddPropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this);
|
||||
#endif
|
||||
|
||||
/* We're running! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
AudioStreamBasicDescription strdesc;
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
|
|
@ -518,7 +643,7 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
strdesc.mBytesPerPacket =
|
||||
strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
|
||||
|
||||
if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
|
||||
if (!prepare_audiounit(this, handle, iscapture, &strdesc)) {
|
||||
COREAUDIO_CloseDevice(this);
|
||||
return -1; /* prepare_audiounit() will call SDL_SetError()... */
|
||||
}
|
||||
|
|
@ -526,15 +651,27 @@ COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return 0; /* good to go. */
|
||||
}
|
||||
|
||||
static void
|
||||
COREAUDIO_Deinitialize(void)
|
||||
{
|
||||
#if MACOSX_COREAUDIO
|
||||
AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
|
||||
free_audio_device_list(&capture_devs);
|
||||
free_audio_device_list(&output_devs);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
COREAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = COREAUDIO_OpenDevice;
|
||||
impl->CloseDevice = COREAUDIO_CloseDevice;
|
||||
impl->Deinitialize = COREAUDIO_Deinitialize;
|
||||
|
||||
#if MACOSX_COREAUDIO
|
||||
impl->DetectDevices = COREAUDIO_DetectDevices;
|
||||
AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
|
||||
#else
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
|
||||
|
|
@ -556,4 +693,6 @@ AudioBootStrap COREAUDIO_bootstrap = {
|
|||
"coreaudio", "CoreAudio", COREAUDIO_Init, 0
|
||||
};
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_COREAUDIO */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -144,15 +144,22 @@ SetDSerror(const char *function, int code)
|
|||
return SDL_SetError("%s", errbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
DSOUND_FreeDeviceHandle(void *handle)
|
||||
{
|
||||
SDL_free(handle);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK
|
||||
FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
|
||||
{
|
||||
SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
|
||||
const int iscapture = (int) ((size_t) data);
|
||||
if (guid != NULL) { /* skip default device */
|
||||
char *str = WIN_StringToUTF8(desc);
|
||||
if (str != NULL) {
|
||||
addfn(str);
|
||||
LPGUID cpyguid = (LPGUID) SDL_malloc(sizeof (GUID));
|
||||
SDL_memcpy(cpyguid, guid, sizeof (GUID));
|
||||
SDL_AddAudioDevice(iscapture, str, cpyguid);
|
||||
SDL_free(str); /* addfn() makes a copy of this string. */
|
||||
}
|
||||
}
|
||||
|
|
@ -160,13 +167,10 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data)
|
|||
}
|
||||
|
||||
static void
|
||||
DSOUND_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
DSOUND_DetectDevices(void)
|
||||
{
|
||||
if (iscapture) {
|
||||
pDirectSoundCaptureEnumerateW(FindAllDevs, addfn);
|
||||
} else {
|
||||
pDirectSoundEnumerateW(FindAllDevs, addfn);
|
||||
}
|
||||
pDirectSoundCaptureEnumerateW(FindAllDevs, (void *) ((size_t) 1));
|
||||
pDirectSoundEnumerateW(FindAllDevs, (void *) ((size_t) 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -419,53 +423,14 @@ CreateSecondary(_THIS, HWND focus)
|
|||
return (numchunks);
|
||||
}
|
||||
|
||||
typedef struct FindDevGUIDData
|
||||
{
|
||||
const char *devname;
|
||||
GUID guid;
|
||||
int found;
|
||||
} FindDevGUIDData;
|
||||
|
||||
static BOOL CALLBACK
|
||||
FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data)
|
||||
{
|
||||
if (guid != NULL) { /* skip the default device. */
|
||||
FindDevGUIDData *data = (FindDevGUIDData *) _data;
|
||||
char *str = WIN_StringToUTF8(desc);
|
||||
const int match = (SDL_strcmp(str, data->devname) == 0);
|
||||
SDL_free(str);
|
||||
if (match) {
|
||||
data->found = 1;
|
||||
SDL_memcpy(&data->guid, guid, sizeof (data->guid));
|
||||
return FALSE; /* found it! stop enumerating. */
|
||||
}
|
||||
}
|
||||
return TRUE; /* keep enumerating. */
|
||||
}
|
||||
|
||||
static int
|
||||
DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
DSOUND_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
HRESULT result;
|
||||
SDL_bool valid_format = SDL_FALSE;
|
||||
SDL_bool tried_format = SDL_FALSE;
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
FindDevGUIDData devguid;
|
||||
LPGUID guid = NULL;
|
||||
|
||||
if (devname != NULL) {
|
||||
devguid.found = 0;
|
||||
devguid.devname = devname;
|
||||
if (iscapture)
|
||||
pDirectSoundCaptureEnumerateW(FindDevGUID, &devguid);
|
||||
else
|
||||
pDirectSoundEnumerateW(FindDevGUID, &devguid);
|
||||
|
||||
if (!devguid.found) {
|
||||
return SDL_SetError("DirectSound: Requested device not found");
|
||||
}
|
||||
guid = &devguid.guid;
|
||||
}
|
||||
LPGUID guid = (LPGUID) handle;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
|
|
@ -536,6 +501,8 @@ DSOUND_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->WaitDone = DSOUND_WaitDone;
|
||||
impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
|
||||
impl->CloseDevice = DSOUND_CloseDevice;
|
||||
impl->FreeDeviceHandle = DSOUND_FreeDeviceHandle;
|
||||
|
||||
impl->Deinitialize = DSOUND_Deinitialize;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef _SDL_directsound_h
|
||||
#define _SDL_directsound_h
|
||||
|
||||
#include "directx.h"
|
||||
#include "../../core/windows/SDL_directx.h"
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef _directx_h
|
||||
#define _directx_h
|
||||
|
||||
/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <mmsystem.h>
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
#endif
|
||||
#undef WINNT
|
||||
|
||||
/* Far pointers don't exist in 32-bit code */
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
/* Error codes not yet included in Win32 API header files */
|
||||
#ifndef MAKE_HRESULT
|
||||
#define MAKE_HRESULT(sev,fac,code) \
|
||||
((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
|
||||
#endif
|
||||
|
||||
#ifndef S_OK
|
||||
#define S_OK (HRESULT)0x00000000L
|
||||
#endif
|
||||
|
||||
#ifndef SUCCEEDED
|
||||
#define SUCCEEDED(x) ((HRESULT)(x) >= 0)
|
||||
#endif
|
||||
#ifndef FAILED
|
||||
#define FAILED(x) ((HRESULT)(x)<0)
|
||||
#endif
|
||||
|
||||
#ifndef E_FAIL
|
||||
#define E_FAIL (HRESULT)0x80000008L
|
||||
#endif
|
||||
#ifndef E_NOINTERFACE
|
||||
#define E_NOINTERFACE (HRESULT)0x80004002L
|
||||
#endif
|
||||
#ifndef E_OUTOFMEMORY
|
||||
#define E_OUTOFMEMORY (HRESULT)0x8007000EL
|
||||
#endif
|
||||
#ifndef E_INVALIDARG
|
||||
#define E_INVALIDARG (HRESULT)0x80070057L
|
||||
#endif
|
||||
#ifndef E_NOTIMPL
|
||||
#define E_NOTIMPL (HRESULT)0x80004001L
|
||||
#endif
|
||||
#ifndef REGDB_E_CLASSNOTREG
|
||||
#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L
|
||||
#endif
|
||||
|
||||
/* Severity codes */
|
||||
#ifndef SEVERITY_ERROR
|
||||
#define SEVERITY_ERROR 1
|
||||
#endif
|
||||
|
||||
/* Error facility codes */
|
||||
#ifndef FACILITY_WIN32
|
||||
#define FACILITY_WIN32 7
|
||||
#endif
|
||||
|
||||
#ifndef FIELD_OFFSET
|
||||
#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
|
||||
#endif
|
||||
|
||||
/* DirectX headers (if it isn't included, I haven't tested it yet)
|
||||
*/
|
||||
/* We need these defines to mark what version of DirectX API we use */
|
||||
#define DIRECTDRAW_VERSION 0x0700
|
||||
#define DIRECTSOUND_VERSION 0x0800
|
||||
#define DIRECTINPUT_VERSION 0x0500
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <dsound.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#endif /* _directx_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -71,7 +71,7 @@ DISKAUD_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written != this->hidden->mixlen) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
|
|
@ -100,10 +100,11 @@ DISKAUD_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
DISKAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
/* handle != NULL means "user specified the placeholder name on the fake detected device list" */
|
||||
const char *fname = DISKAUD_GetOutputFilename(handle ? NULL : devname);
|
||||
const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
|
||||
const char *fname = DISKAUD_GetOutputFilename(devname);
|
||||
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc(sizeof(*this->hidden));
|
||||
|
|
@ -141,6 +142,13 @@ DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
DISKAUD_DetectDevices(void)
|
||||
{
|
||||
/* !!! FIXME: stole this literal string from DEFAULT_OUTPUT_DEVNAME in SDL_audio.c */
|
||||
SDL_AddAudioDevice(SDL_FALSE, "System audio output device", (void *) 0x1);
|
||||
}
|
||||
|
||||
static int
|
||||
DISKAUD_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
|
|
@ -150,6 +158,9 @@ DISKAUD_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->PlayDevice = DISKAUD_PlayDevice;
|
||||
impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
|
||||
impl->CloseDevice = DISKAUD_CloseDevice;
|
||||
impl->DetectDevices = DISKAUD_DetectDevices;
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -51,9 +51,9 @@
|
|||
|
||||
|
||||
static void
|
||||
DSP_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
DSP_DetectDevices(void)
|
||||
{
|
||||
SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn);
|
||||
SDL_EnumUnixAudioDevices(0, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ DSP_CloseDevice(_THIS)
|
|||
|
||||
|
||||
static int
|
||||
DSP_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
DSP_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
int format;
|
||||
|
|
@ -270,7 +270,7 @@ DSP_PlayDevice(_THIS)
|
|||
const int mixlen = this->hidden->mixlen;
|
||||
if (write(this->hidden->audio_fd, mixbuf, mixlen) == -1) {
|
||||
perror("Audio write");
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen);
|
||||
|
|
@ -293,6 +293,8 @@ DSP_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->GetDeviceBuf = DSP_GetDeviceBuf;
|
||||
impl->CloseDevice = DSP_CloseDevice;
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#include "SDL_dummyaudio.h"
|
||||
|
||||
static int
|
||||
DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
DUMMYAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
return 0; /* always succeeds. */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
279
Engine/lib/sdl/src/audio/emscripten/SDL_emscriptenaudio.c
Normal file
279
Engine/lib/sdl/src/audio/emscripten/SDL_emscriptenaudio.c
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_EMSCRIPTEN
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_log.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_emscriptenaudio.h"
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
static int
|
||||
copyData(_THIS)
|
||||
{
|
||||
int byte_len;
|
||||
|
||||
if (this->hidden->write_off + this->convert.len_cvt > this->hidden->mixlen) {
|
||||
if (this->hidden->write_off > this->hidden->read_off) {
|
||||
SDL_memmove(this->hidden->mixbuf,
|
||||
this->hidden->mixbuf + this->hidden->read_off,
|
||||
this->hidden->mixlen - this->hidden->read_off);
|
||||
this->hidden->write_off = this->hidden->write_off - this->hidden->read_off;
|
||||
} else {
|
||||
this->hidden->write_off = 0;
|
||||
}
|
||||
this->hidden->read_off = 0;
|
||||
}
|
||||
|
||||
SDL_memcpy(this->hidden->mixbuf + this->hidden->write_off,
|
||||
this->convert.buf,
|
||||
this->convert.len_cvt);
|
||||
this->hidden->write_off += this->convert.len_cvt;
|
||||
byte_len = this->hidden->write_off - this->hidden->read_off;
|
||||
|
||||
return byte_len;
|
||||
}
|
||||
|
||||
static void
|
||||
HandleAudioProcess(_THIS)
|
||||
{
|
||||
Uint8 *buf = NULL;
|
||||
int byte_len = 0;
|
||||
int bytes = SDL_AUDIO_BITSIZE(this->spec.format) / 8;
|
||||
int bytes_in = SDL_AUDIO_BITSIZE(this->convert.src_format) / 8;
|
||||
|
||||
/* Only do soemthing if audio is enabled */
|
||||
if (!this->enabled)
|
||||
return;
|
||||
|
||||
if (this->paused)
|
||||
return;
|
||||
|
||||
if (this->convert.needed) {
|
||||
if (this->hidden->conv_in_len != 0) {
|
||||
this->convert.len = this->hidden->conv_in_len * bytes_in * this->spec.channels;
|
||||
}
|
||||
|
||||
(*this->spec.callback) (this->spec.userdata,
|
||||
this->convert.buf,
|
||||
this->convert.len);
|
||||
SDL_ConvertAudio(&this->convert);
|
||||
buf = this->convert.buf;
|
||||
byte_len = this->convert.len_cvt;
|
||||
|
||||
/* size mismatch*/
|
||||
if (byte_len != this->spec.size) {
|
||||
if (!this->hidden->mixbuf) {
|
||||
this->hidden->mixlen = this->spec.size > byte_len ? this->spec.size * 2 : byte_len * 2;
|
||||
this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
|
||||
}
|
||||
|
||||
/* copy existing data */
|
||||
byte_len = copyData(this);
|
||||
|
||||
/* read more data*/
|
||||
while (byte_len < this->spec.size) {
|
||||
(*this->spec.callback) (this->spec.userdata,
|
||||
this->convert.buf,
|
||||
this->convert.len);
|
||||
SDL_ConvertAudio(&this->convert);
|
||||
byte_len = copyData(this);
|
||||
}
|
||||
|
||||
byte_len = this->spec.size;
|
||||
buf = this->hidden->mixbuf + this->hidden->read_off;
|
||||
this->hidden->read_off += byte_len;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!this->hidden->mixbuf) {
|
||||
this->hidden->mixlen = this->spec.size;
|
||||
this->hidden->mixbuf = SDL_malloc(this->hidden->mixlen);
|
||||
}
|
||||
(*this->spec.callback) (this->spec.userdata,
|
||||
this->hidden->mixbuf,
|
||||
this->hidden->mixlen);
|
||||
buf = this->hidden->mixbuf;
|
||||
byte_len = this->hidden->mixlen;
|
||||
}
|
||||
|
||||
if (buf) {
|
||||
EM_ASM_ARGS({
|
||||
var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels'];
|
||||
for (var c = 0; c < numChannels; ++c) {
|
||||
var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c);
|
||||
if (channelData.length != $1) {
|
||||
throw 'Web Audio output buffer length mismatch! Destination size: ' + channelData.length + ' samples vs expected ' + $1 + ' samples!';
|
||||
}
|
||||
|
||||
for (var j = 0; j < $1; ++j) {
|
||||
channelData[j] = getValue($0 + (j*numChannels + c)*4, 'float');
|
||||
}
|
||||
}
|
||||
}, buf, byte_len / bytes / this->spec.channels);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
if (this->hidden->mixbuf != NULL) {
|
||||
/* Clean up the audio buffer */
|
||||
SDL_free(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
}
|
||||
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_bool valid_format = SDL_FALSE;
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
int i;
|
||||
float f;
|
||||
int result;
|
||||
|
||||
while ((!valid_format) && (test_format)) {
|
||||
switch (test_format) {
|
||||
case AUDIO_F32: /* web audio only supports floats */
|
||||
this->spec.format = test_format;
|
||||
|
||||
valid_format = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
test_format = SDL_NextAudioFormat();
|
||||
}
|
||||
|
||||
if (!valid_format) {
|
||||
/* Didn't find a compatible format :( */
|
||||
return SDL_SetError("No compatible audio format!");
|
||||
}
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
if (this->hidden == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
/* based on parts of library_sdl.js */
|
||||
|
||||
/* create context (TODO: this puts stuff in the global namespace...)*/
|
||||
result = EM_ASM_INT_V({
|
||||
if(typeof(SDL2) === 'undefined')
|
||||
SDL2 = {};
|
||||
|
||||
if(typeof(SDL2.audio) === 'undefined')
|
||||
SDL2.audio = {};
|
||||
|
||||
if (!SDL2.audioContext) {
|
||||
if (typeof(AudioContext) !== 'undefined') {
|
||||
SDL2.audioContext = new AudioContext();
|
||||
} else if (typeof(webkitAudioContext) !== 'undefined') {
|
||||
SDL2.audioContext = new webkitAudioContext();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
if (result < 0) {
|
||||
return SDL_SetError("Web Audio API is not available!");
|
||||
}
|
||||
|
||||
/* limit to native freq */
|
||||
int sampleRate = EM_ASM_INT_V({
|
||||
return SDL2.audioContext['sampleRate'];
|
||||
});
|
||||
|
||||
if(this->spec.freq != sampleRate) {
|
||||
for (i = this->spec.samples; i > 0; i--) {
|
||||
f = (float)i / (float)sampleRate * (float)this->spec.freq;
|
||||
if (SDL_floor(f) == f) {
|
||||
this->hidden->conv_in_len = SDL_floor(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->spec.freq = sampleRate;
|
||||
}
|
||||
|
||||
SDL_CalculateAudioSpec(&this->spec);
|
||||
|
||||
/* setup a ScriptProcessorNode */
|
||||
EM_ASM_ARGS({
|
||||
SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0);
|
||||
SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) {
|
||||
SDL2.audio.currentOutputBuffer = e['outputBuffer'];
|
||||
Runtime.dynCall('vi', $2, [$3]);
|
||||
};
|
||||
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
|
||||
}, this->spec.channels, this->spec.samples, HandleAudioProcess, this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = Emscripten_OpenDevice;
|
||||
impl->CloseDevice = Emscripten_CloseDevice;
|
||||
|
||||
/* only one output */
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
|
||||
/* no threads here */
|
||||
impl->SkipMixerLock = 1;
|
||||
impl->ProvidesOwnCallbackThread = 1;
|
||||
|
||||
/* check availability */
|
||||
int available = EM_ASM_INT_V({
|
||||
if (typeof(AudioContext) !== 'undefined') {
|
||||
return 1;
|
||||
} else if (typeof(webkitAudioContext) !== 'undefined') {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
if (!available) {
|
||||
SDL_SetError("No audio context available");
|
||||
}
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
AudioBootStrap EmscriptenAudio_bootstrap = {
|
||||
"emscripten", "SDL emscripten audio driver", Emscripten_Init, 0
|
||||
};
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_EMSCRIPTEN */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
42
Engine/lib/sdl/src/audio/emscripten/SDL_emscriptenaudio.h
Normal file
42
Engine/lib/sdl/src/audio/emscripten/SDL_emscriptenaudio.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef _SDL_emscriptenaudio_h
|
||||
#define _SDL_emscriptenaudio_h
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
|
||||
Uint32 conv_in_len;
|
||||
|
||||
Uint32 write_off, read_off;
|
||||
};
|
||||
|
||||
#endif /* _SDL_emscriptenaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -129,7 +129,7 @@ ESD_WaitDevice(_THIS)
|
|||
/* Check every 10 loops */
|
||||
if (this->hidden->parent && (((++cnt) % 10) == 0)) {
|
||||
if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ ESD_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ get_progname(void)
|
|||
|
||||
|
||||
static int
|
||||
ESD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ESD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
esd_format_t format = (ESD_STREAM | ESD_PLAY);
|
||||
SDL_AudioFormat test_format = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -143,7 +143,7 @@ SDL_FS_PlayDevice(_THIS)
|
|||
this->hidden->mixsamples);
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (ret) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
|
||||
|
|
@ -186,7 +186,7 @@ SDL_FS_CloseDevice(_THIS)
|
|||
|
||||
|
||||
static int
|
||||
SDL_FS_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
SDL_FS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int bytes;
|
||||
SDL_AudioFormat test_format = 0, format = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -111,7 +111,7 @@ UnmaskSignals(sigset_t * omask)
|
|||
|
||||
|
||||
static int
|
||||
HAIKUAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
HAIKUAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int valid_datatype = 0;
|
||||
media_raw_audio_format format;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
152
Engine/lib/sdl/src/audio/nacl/SDL_naclaudio.c
Normal file
152
Engine/lib/sdl/src/audio/nacl/SDL_naclaudio.c
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_NACL
|
||||
|
||||
#include "SDL_naclaudio.h"
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "../SDL_audiomem.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "../SDL_audiodev_c.h"
|
||||
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/pp_instance.h"
|
||||
#include "ppapi_simple/ps.h"
|
||||
#include "ppapi_simple/ps_interface.h"
|
||||
#include "ppapi_simple/ps_event.h"
|
||||
|
||||
/* The tag name used by NACL audio */
|
||||
#define NACLAUD_DRIVER_NAME "nacl"
|
||||
|
||||
#define SAMPLE_FRAME_COUNT 4096
|
||||
|
||||
/* Audio driver functions */
|
||||
static int NACLAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture);
|
||||
static void NACLAUD_CloseDevice(_THIS);
|
||||
static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data);
|
||||
|
||||
/* FIXME: Make use of latency if needed */
|
||||
static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data) {
|
||||
SDL_AudioDevice* _this = (SDL_AudioDevice*) data;
|
||||
|
||||
SDL_LockMutex(private->mutex);
|
||||
|
||||
if (_this->enabled && !_this->paused) {
|
||||
if (_this->convert.needed) {
|
||||
SDL_LockMutex(_this->mixer_lock);
|
||||
(*_this->spec.callback) (_this->spec.userdata,
|
||||
(Uint8 *) _this->convert.buf,
|
||||
_this->convert.len);
|
||||
SDL_UnlockMutex(_this->mixer_lock);
|
||||
SDL_ConvertAudio(&_this->convert);
|
||||
SDL_memcpy(samples, _this->convert.buf, _this->convert.len_cvt);
|
||||
} else {
|
||||
SDL_LockMutex(_this->mixer_lock);
|
||||
(*_this->spec.callback) (_this->spec.userdata, (Uint8 *) samples, buffer_size);
|
||||
SDL_UnlockMutex(_this->mixer_lock);
|
||||
}
|
||||
} else {
|
||||
SDL_memset(samples, 0, buffer_size);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void NACLAUD_CloseDevice(SDL_AudioDevice *device) {
|
||||
const PPB_Core *core = PSInterfaceCore();
|
||||
const PPB_Audio *ppb_audio = PSInterfaceAudio();
|
||||
SDL_PrivateAudioData *hidden = (SDL_PrivateAudioData *) device->hidden;
|
||||
|
||||
ppb_audio->StopPlayback(hidden->audio);
|
||||
SDL_DestroyMutex(hidden->mutex);
|
||||
core->ReleaseResource(hidden->audio);
|
||||
}
|
||||
|
||||
static int
|
||||
NACLAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) {
|
||||
PP_Instance instance = PSGetInstanceId();
|
||||
const PPB_Audio *ppb_audio = PSInterfaceAudio();
|
||||
const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig();
|
||||
|
||||
private = (SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *private));
|
||||
if (private == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
|
||||
private->mutex = SDL_CreateMutex();
|
||||
_this->spec.freq = 44100;
|
||||
_this->spec.format = AUDIO_S16LSB;
|
||||
_this->spec.channels = 2;
|
||||
_this->spec.samples = ppb_audiocfg->RecommendSampleFrameCount(
|
||||
instance,
|
||||
PP_AUDIOSAMPLERATE_44100,
|
||||
SAMPLE_FRAME_COUNT);
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
SDL_CalculateAudioSpec(&_this->spec);
|
||||
|
||||
private->audio = ppb_audio->Create(
|
||||
instance,
|
||||
ppb_audiocfg->CreateStereo16Bit(instance, PP_AUDIOSAMPLERATE_44100, _this->spec.samples),
|
||||
nacl_audio_callback,
|
||||
_this);
|
||||
|
||||
/* Start audio playback while we are still on the main thread. */
|
||||
ppb_audio->StartPlayback(private->audio);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
NACLAUD_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
if (PSGetInstanceId() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = NACLAUD_OpenDevice;
|
||||
impl->CloseDevice = NACLAUD_CloseDevice;
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
impl->ProvidesOwnCallbackThread = 1;
|
||||
/*
|
||||
* impl->WaitDevice = NACLAUD_WaitDevice;
|
||||
* impl->GetDeviceBuf = NACLAUD_GetDeviceBuf;
|
||||
* impl->PlayDevice = NACLAUD_PlayDevice;
|
||||
* impl->Deinitialize = NACLAUD_Deinitialize;
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AudioBootStrap NACLAUD_bootstrap = {
|
||||
NACLAUD_DRIVER_NAME, "SDL NaCl Audio Driver",
|
||||
NACLAUD_Init, 0
|
||||
};
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_NACL */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
41
Engine/lib/sdl/src/audio/nacl/SDL_naclaudio.h
Normal file
41
Engine/lib/sdl/src/audio/nacl/SDL_naclaudio.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef _SDL_naclaudio_h
|
||||
#define _SDL_naclaudio_h
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_sysaudio.h"
|
||||
#include "SDL_mutex.h"
|
||||
|
||||
#include "ppapi/c/ppb_audio.h"
|
||||
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
#define private _this->hidden
|
||||
|
||||
typedef struct SDL_PrivateAudioData {
|
||||
SDL_mutex* mutex;
|
||||
PP_Resource audio;
|
||||
} SDL_PrivateAudioData;
|
||||
|
||||
#endif /* _SDL_naclaudio_h */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -276,7 +276,7 @@ find_device(_THIS, int nch)
|
|||
}
|
||||
|
||||
static int
|
||||
NAS_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
NAS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
AuElement elms[3];
|
||||
int buffer_size;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -111,7 +111,7 @@ OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
|||
|
||||
if (stat(audiopath, &sb) == 0) {
|
||||
fd = open(audiopath, flags, 0);
|
||||
if (fd > 0) {
|
||||
if (fd >= 0) {
|
||||
if (path != NULL) {
|
||||
SDL_strlcpy(path, audiopath, maxlen);
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ PAUDIO_WaitDevice(_THIS)
|
|||
* the user know what happened.
|
||||
*/
|
||||
fprintf(stderr, "SDL: %s - %s\n", strerror(errno), message);
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
/* Don't try to close - may hang */
|
||||
this->hidden->audio_fd = -1;
|
||||
#ifdef DEBUG_AUDIO
|
||||
|
|
@ -212,7 +212,7 @@ PAUDIO_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (written < 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
|
|
@ -241,7 +241,7 @@ PAUDIO_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
PAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const char *workaround = SDL_getenv("SDL_DSP_NOSELECT");
|
||||
char audiodev[1024];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -18,6 +18,9 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_PSP
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -40,7 +43,7 @@
|
|||
#define PSPAUD_DRIVER_NAME "psp"
|
||||
|
||||
static int
|
||||
PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
PSPAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
int format, mixlen, i;
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
|
|
@ -191,5 +194,6 @@ AudioBootStrap PSPAUD_bootstrap = {
|
|||
|
||||
/* SDL_AUDI */
|
||||
|
||||
#endif /* SDL_AUDIO_DRIVER_PSP */
|
||||
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
#define NUM_BUFFERS 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
Stéphan Kochen: stephan .a.t. kochen.nl
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_PULSEAUDIO
|
||||
|
||||
|
|
@ -38,7 +39,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include <pulse/simple.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
|
|
@ -66,16 +66,14 @@ static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
|
|||
|
||||
|
||||
static const char *(*PULSEAUDIO_pa_get_library_version) (void);
|
||||
static pa_simple *(*PULSEAUDIO_pa_simple_new) (const char *, const char *,
|
||||
pa_stream_direction_t, const char *, const char *, const pa_sample_spec *,
|
||||
const pa_channel_map *, const pa_buffer_attr *, int *);
|
||||
static void (*PULSEAUDIO_pa_simple_free) (pa_simple *);
|
||||
static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto) (
|
||||
pa_channel_map *, unsigned, pa_channel_map_def_t);
|
||||
static const char * (*PULSEAUDIO_pa_strerror) (int);
|
||||
static pa_mainloop * (*PULSEAUDIO_pa_mainloop_new) (void);
|
||||
static pa_mainloop_api * (*PULSEAUDIO_pa_mainloop_get_api) (pa_mainloop *);
|
||||
static int (*PULSEAUDIO_pa_mainloop_iterate) (pa_mainloop *, int, int *);
|
||||
static int (*PULSEAUDIO_pa_mainloop_run) (pa_mainloop *, int *);
|
||||
static void (*PULSEAUDIO_pa_mainloop_quit) (pa_mainloop *, int);
|
||||
static void (*PULSEAUDIO_pa_mainloop_free) (pa_mainloop *);
|
||||
|
||||
static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state) (
|
||||
|
|
@ -87,7 +85,13 @@ static pa_context * (*PULSEAUDIO_pa_context_new) (pa_mainloop_api *,
|
|||
const char *);
|
||||
static int (*PULSEAUDIO_pa_context_connect) (pa_context *, const char *,
|
||||
pa_context_flags_t, const pa_spawn_api *);
|
||||
static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_list) (pa_context *, pa_sink_info_cb_t, void *);
|
||||
static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_list) (pa_context *, pa_source_info_cb_t, void *);
|
||||
static pa_operation * (*PULSEAUDIO_pa_context_get_sink_info_by_index) (pa_context *, uint32_t, pa_sink_info_cb_t, void *);
|
||||
static pa_operation * (*PULSEAUDIO_pa_context_get_source_info_by_index) (pa_context *, uint32_t, pa_source_info_cb_t, void *);
|
||||
static pa_context_state_t (*PULSEAUDIO_pa_context_get_state) (pa_context *);
|
||||
static pa_operation * (*PULSEAUDIO_pa_context_subscribe) (pa_context *, pa_subscription_mask_t, pa_context_success_cb_t, void *);
|
||||
static void (*PULSEAUDIO_pa_context_set_subscribe_callback) (pa_context *, pa_context_subscribe_cb_t, void *);
|
||||
static void (*PULSEAUDIO_pa_context_disconnect) (pa_context *);
|
||||
static void (*PULSEAUDIO_pa_context_unref) (pa_context *);
|
||||
|
||||
|
|
@ -179,18 +183,24 @@ static int
|
|||
load_pulseaudio_syms(void)
|
||||
{
|
||||
SDL_PULSEAUDIO_SYM(pa_get_library_version);
|
||||
SDL_PULSEAUDIO_SYM(pa_simple_new);
|
||||
SDL_PULSEAUDIO_SYM(pa_simple_free);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_new);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_get_api);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_iterate);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_run);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_quit);
|
||||
SDL_PULSEAUDIO_SYM(pa_mainloop_free);
|
||||
SDL_PULSEAUDIO_SYM(pa_operation_get_state);
|
||||
SDL_PULSEAUDIO_SYM(pa_operation_cancel);
|
||||
SDL_PULSEAUDIO_SYM(pa_operation_unref);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_new);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_connect);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_list);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_get_source_info_list);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_by_index);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_get_source_info_by_index);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_get_state);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_subscribe);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_set_subscribe_callback);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_disconnect);
|
||||
SDL_PULSEAUDIO_SYM(pa_context_unref);
|
||||
SDL_PULSEAUDIO_SYM(pa_stream_new);
|
||||
|
|
@ -206,122 +216,6 @@ load_pulseaudio_syms(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Check to see if we can connect to PulseAudio */
|
||||
static SDL_bool
|
||||
CheckPulseAudioAvailable()
|
||||
{
|
||||
pa_simple *s;
|
||||
pa_sample_spec ss;
|
||||
|
||||
ss.format = PA_SAMPLE_S16NE;
|
||||
ss.channels = 1;
|
||||
ss.rate = 22050;
|
||||
|
||||
s = PULSEAUDIO_pa_simple_new(NULL, "SDL", PA_STREAM_PLAYBACK, NULL,
|
||||
"Test", &ss, NULL, NULL, NULL);
|
||||
if (s) {
|
||||
PULSEAUDIO_pa_simple_free(s);
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void
|
||||
PULSEAUDIO_WaitDevice(_THIS)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
|
||||
while(1) {
|
||||
if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
|
||||
PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
|
||||
PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
|
||||
this->enabled = 0;
|
||||
return;
|
||||
}
|
||||
if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= h->mixlen) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_PlayDevice(_THIS)
|
||||
{
|
||||
/* Write the audio data */
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf, h->mixlen, NULL, 0LL,
|
||||
PA_SEEK_RELATIVE) < 0) {
|
||||
this->enabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stream_drain_complete(pa_stream *s, int success, void *userdata)
|
||||
{
|
||||
/* no-op for pa_stream_drain() to use for callback. */
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_WaitDone(_THIS)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
pa_operation *o;
|
||||
|
||||
o = PULSEAUDIO_pa_stream_drain(h->stream, stream_drain_complete, NULL);
|
||||
if (!o) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (PULSEAUDIO_pa_operation_get_state(o) != PA_OPERATION_DONE) {
|
||||
if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
|
||||
PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
|
||||
PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
|
||||
PULSEAUDIO_pa_operation_cancel(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PULSEAUDIO_pa_operation_unref(o);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Uint8 *
|
||||
PULSEAUDIO_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
PULSEAUDIO_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
if (this->hidden->stream) {
|
||||
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
|
||||
PULSEAUDIO_pa_stream_unref(this->hidden->stream);
|
||||
this->hidden->stream = NULL;
|
||||
}
|
||||
if (this->hidden->context != NULL) {
|
||||
PULSEAUDIO_pa_context_disconnect(this->hidden->context);
|
||||
PULSEAUDIO_pa_context_unref(this->hidden->context);
|
||||
this->hidden->context = NULL;
|
||||
}
|
||||
if (this->hidden->mainloop != NULL) {
|
||||
PULSEAUDIO_pa_mainloop_free(this->hidden->mainloop);
|
||||
this->hidden->mainloop = NULL;
|
||||
}
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static SDL_INLINE int
|
||||
squashVersion(const int major, const int minor, const int patch)
|
||||
{
|
||||
|
|
@ -344,8 +238,193 @@ getAppName(void)
|
|||
return "SDL Application"; /* oh well. */
|
||||
}
|
||||
|
||||
static void
|
||||
WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
|
||||
{
|
||||
/* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
|
||||
if (mainloop && o) {
|
||||
SDL_bool okay = SDL_TRUE;
|
||||
while (okay && (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING)) {
|
||||
okay = (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) >= 0);
|
||||
}
|
||||
PULSEAUDIO_pa_operation_unref(o);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context)
|
||||
{
|
||||
if (context) {
|
||||
PULSEAUDIO_pa_context_disconnect(context);
|
||||
PULSEAUDIO_pa_context_unref(context);
|
||||
}
|
||||
if (mainloop != NULL) {
|
||||
PULSEAUDIO_pa_mainloop_free(mainloop);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
|
||||
{
|
||||
pa_mainloop *mainloop = NULL;
|
||||
pa_context *context = NULL;
|
||||
pa_mainloop_api *mainloop_api = NULL;
|
||||
int state = 0;
|
||||
|
||||
*_mainloop = NULL;
|
||||
*_context = NULL;
|
||||
|
||||
/* Set up a new main loop */
|
||||
if (!(mainloop = PULSEAUDIO_pa_mainloop_new())) {
|
||||
return SDL_SetError("pa_mainloop_new() failed");
|
||||
}
|
||||
|
||||
*_mainloop = mainloop;
|
||||
|
||||
mainloop_api = PULSEAUDIO_pa_mainloop_get_api(mainloop);
|
||||
SDL_assert(mainloop_api); /* this never fails, right? */
|
||||
|
||||
context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName());
|
||||
if (!context) {
|
||||
return SDL_SetError("pa_context_new() failed");
|
||||
}
|
||||
*_context = context;
|
||||
|
||||
/* Connect to the PulseAudio server */
|
||||
if (PULSEAUDIO_pa_context_connect(context, NULL, 0, NULL) < 0) {
|
||||
return SDL_SetError("Could not setup connection to PulseAudio");
|
||||
}
|
||||
|
||||
do {
|
||||
if (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) < 0) {
|
||||
return SDL_SetError("pa_mainloop_iterate() failed");
|
||||
}
|
||||
state = PULSEAUDIO_pa_context_get_state(context);
|
||||
if (!PA_CONTEXT_IS_GOOD(state)) {
|
||||
return SDL_SetError("Could not connect to PulseAudio");
|
||||
}
|
||||
} while (state != PA_CONTEXT_READY);
|
||||
|
||||
return 0; /* connected and ready! */
|
||||
}
|
||||
|
||||
static int
|
||||
ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context)
|
||||
{
|
||||
const int retval = ConnectToPulseServer_Internal(_mainloop, _context);
|
||||
if (retval < 0) {
|
||||
DisconnectFromPulseServer(*_mainloop, *_context);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void
|
||||
PULSEAUDIO_WaitDevice(_THIS)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
|
||||
while (this->enabled) {
|
||||
if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
|
||||
PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
|
||||
PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
return;
|
||||
}
|
||||
if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= h->mixlen) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_PlayDevice(_THIS)
|
||||
{
|
||||
/* Write the audio data */
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
if (this->enabled) {
|
||||
if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf, h->mixlen, NULL, 0LL, PA_SEEK_RELATIVE) < 0) {
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stream_drain_complete(pa_stream *s, int success, void *userdata)
|
||||
{
|
||||
/* no-op for pa_stream_drain() to use for callback. */
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_WaitDone(_THIS)
|
||||
{
|
||||
if (this->enabled) {
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
pa_operation *o = PULSEAUDIO_pa_stream_drain(h->stream, stream_drain_complete, NULL);
|
||||
if (o) {
|
||||
while (PULSEAUDIO_pa_operation_get_state(o) != PA_OPERATION_DONE) {
|
||||
if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
|
||||
PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
|
||||
PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
|
||||
PULSEAUDIO_pa_operation_cancel(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PULSEAUDIO_pa_operation_unref(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Uint8 *
|
||||
PULSEAUDIO_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
PULSEAUDIO_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden != NULL) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
SDL_free(this->hidden->device_name);
|
||||
if (this->hidden->stream) {
|
||||
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
|
||||
PULSEAUDIO_pa_stream_unref(this->hidden->stream);
|
||||
}
|
||||
DisconnectFromPulseServer(this->hidden->mainloop, this->hidden->context);
|
||||
SDL_free(this->hidden);
|
||||
this->hidden = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
|
||||
{
|
||||
if (i) {
|
||||
char **devname = (char **) data;
|
||||
*devname = SDL_strdup(i->name);
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
FindDeviceName(struct SDL_PrivateAudioData *h, void *handle)
|
||||
{
|
||||
const uint32_t idx = ((uint32_t) ((size_t) handle)) - 1;
|
||||
|
||||
if (handle == NULL) { /* NULL == default device. */
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
WaitForPulseOperation(h->mainloop, PULSEAUDIO_pa_context_get_sink_info_by_index(h->context, idx, DeviceNameCallback, &h->device_name));
|
||||
return (h->device_name != NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
PULSEAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = NULL;
|
||||
Uint16 test_format = 0;
|
||||
|
|
@ -442,42 +521,21 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
paattr.minreq = h->mixlen;
|
||||
#endif
|
||||
|
||||
if (ConnectToPulseServer(&h->mainloop, &h->context) < 0) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Could not connect to PulseAudio server");
|
||||
}
|
||||
|
||||
if (!FindDeviceName(h, handle)) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Requested PulseAudio sink missing?");
|
||||
}
|
||||
|
||||
/* The SDL ALSA output hints us that we use Windows' channel mapping */
|
||||
/* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
|
||||
PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels,
|
||||
PA_CHANNEL_MAP_WAVEEX);
|
||||
|
||||
/* Set up a new main loop */
|
||||
if (!(h->mainloop = PULSEAUDIO_pa_mainloop_new())) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("pa_mainloop_new() failed");
|
||||
}
|
||||
|
||||
h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop);
|
||||
h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, getAppName());
|
||||
if (!h->context) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("pa_context_new() failed");
|
||||
}
|
||||
|
||||
/* Connect to the PulseAudio server */
|
||||
if (PULSEAUDIO_pa_context_connect(h->context, NULL, 0, NULL) < 0) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Could not setup connection to PulseAudio");
|
||||
}
|
||||
|
||||
do {
|
||||
if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("pa_mainloop_iterate() failed");
|
||||
}
|
||||
state = PULSEAUDIO_pa_context_get_state(h->context);
|
||||
if (!PA_CONTEXT_IS_GOOD(state)) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Could not connect to PulseAudio");
|
||||
}
|
||||
} while (state != PA_CONTEXT_READY);
|
||||
|
||||
h->stream = PULSEAUDIO_pa_stream_new(
|
||||
h->context,
|
||||
"Simple DirectMedia Layer", /* stream description */
|
||||
|
|
@ -490,7 +548,13 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return SDL_SetError("Could not set up PulseAudio stream");
|
||||
}
|
||||
|
||||
if (PULSEAUDIO_pa_stream_connect_playback(h->stream, NULL, &paattr, flags,
|
||||
/* now that we have multi-device support, don't move a stream from
|
||||
a device that was unplugged to something else, unless we're default. */
|
||||
if (h->device_name != NULL) {
|
||||
flags |= PA_STREAM_DONT_MOVE;
|
||||
}
|
||||
|
||||
if (PULSEAUDIO_pa_stream_connect_playback(h->stream, h->device_name, &paattr, flags,
|
||||
NULL, NULL) < 0) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Could not connect PulseAudio stream");
|
||||
|
|
@ -504,7 +568,7 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
state = PULSEAUDIO_pa_stream_get_state(h->stream);
|
||||
if (!PA_STREAM_IS_GOOD(state)) {
|
||||
PULSEAUDIO_CloseDevice(this);
|
||||
return SDL_SetError("Could not create to PulseAudio stream");
|
||||
return SDL_SetError("Could not connect PulseAudio stream");
|
||||
}
|
||||
} while (state != PA_STREAM_READY);
|
||||
|
||||
|
|
@ -512,10 +576,92 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static pa_mainloop *hotplug_mainloop = NULL;
|
||||
static pa_context *hotplug_context = NULL;
|
||||
static SDL_Thread *hotplug_thread = NULL;
|
||||
|
||||
/* device handles are device index + 1, cast to void*, so we never pass a NULL. */
|
||||
|
||||
/* This is called when PulseAudio adds an output ("sink") device. */
|
||||
static void
|
||||
SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data)
|
||||
{
|
||||
if (i) {
|
||||
SDL_AddAudioDevice(SDL_FALSE, i->description, (void *) ((size_t) i->index+1));
|
||||
}
|
||||
}
|
||||
|
||||
/* This is called when PulseAudio adds a capture ("source") device. */
|
||||
static void
|
||||
SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data)
|
||||
{
|
||||
if (i) {
|
||||
/* Skip "monitor" sources. These are just output from other sinks. */
|
||||
if (i->monitor_of_sink == PA_INVALID_INDEX) {
|
||||
SDL_AddAudioDevice(SDL_TRUE, i->description, (void *) ((size_t) i->index+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This is called when PulseAudio has a device connected/removed/changed. */
|
||||
static void
|
||||
HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data)
|
||||
{
|
||||
const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW);
|
||||
const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE);
|
||||
|
||||
if (added || removed) { /* we only care about add/remove events. */
|
||||
const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK);
|
||||
const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE);
|
||||
|
||||
/* adds need sink details from the PulseAudio server. Another callback... */
|
||||
if (added && sink) {
|
||||
PULSEAUDIO_pa_context_get_sink_info_by_index(hotplug_context, idx, SinkInfoCallback, NULL);
|
||||
} else if (added && source) {
|
||||
PULSEAUDIO_pa_context_get_source_info_by_index(hotplug_context, idx, SourceInfoCallback, NULL);
|
||||
} else if (removed && (sink || source)) {
|
||||
/* removes we can handle just with the device index. */
|
||||
SDL_RemoveAudioDevice(source != 0, (void *) ((size_t) idx+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* this runs as a thread while the Pulse target is initialized to catch hotplug events. */
|
||||
static int SDLCALL
|
||||
HotplugThread(void *data)
|
||||
{
|
||||
pa_operation *o;
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
|
||||
PULSEAUDIO_pa_context_set_subscribe_callback(hotplug_context, HotplugCallback, NULL);
|
||||
o = PULSEAUDIO_pa_context_subscribe(hotplug_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL);
|
||||
PULSEAUDIO_pa_operation_unref(o); /* don't wait for it, just do our thing. */
|
||||
PULSEAUDIO_pa_mainloop_run(hotplug_mainloop, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_DetectDevices()
|
||||
{
|
||||
WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, NULL));
|
||||
WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_source_info_list(hotplug_context, SourceInfoCallback, NULL));
|
||||
|
||||
/* ok, we have a sane list, let's set up hotplug notifications now... */
|
||||
hotplug_thread = SDL_CreateThread(HotplugThread, "PulseHotplug", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
PULSEAUDIO_Deinitialize(void)
|
||||
{
|
||||
if (hotplug_thread) {
|
||||
PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0);
|
||||
SDL_WaitThread(hotplug_thread, NULL);
|
||||
hotplug_thread = NULL;
|
||||
}
|
||||
|
||||
DisconnectFromPulseServer(hotplug_mainloop, hotplug_context);
|
||||
hotplug_mainloop = NULL;
|
||||
hotplug_context = NULL;
|
||||
|
||||
UnloadPulseAudioLibrary();
|
||||
}
|
||||
|
||||
|
|
@ -526,12 +672,13 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!CheckPulseAudioAvailable()) {
|
||||
if (ConnectToPulseServer(&hotplug_mainloop, &hotplug_context) < 0) {
|
||||
UnloadPulseAudioLibrary();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
impl->DetectDevices = PULSEAUDIO_DetectDevices;
|
||||
impl->OpenDevice = PULSEAUDIO_OpenDevice;
|
||||
impl->PlayDevice = PULSEAUDIO_PlayDevice;
|
||||
impl->WaitDevice = PULSEAUDIO_WaitDevice;
|
||||
|
|
@ -539,12 +686,10 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->CloseDevice = PULSEAUDIO_CloseDevice;
|
||||
impl->WaitDone = PULSEAUDIO_WaitDone;
|
||||
impl->Deinitialize = PULSEAUDIO_Deinitialize;
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
||||
AudioBootStrap PULSEAUDIO_bootstrap = {
|
||||
"pulseaudio", "PulseAudio", PULSEAUDIO_Init, 0
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -32,9 +32,10 @@
|
|||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
char *device_name;
|
||||
|
||||
/* pulseaudio structures */
|
||||
pa_mainloop *mainloop;
|
||||
pa_mainloop_api *mainloop_api;
|
||||
pa_context *context;
|
||||
pa_stream *stream;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -19,6 +19,15 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* !!! FIXME: streamline this a little by removing all the
|
||||
* !!! FIXME: if (capture) {} else {} sections that are identical
|
||||
* !!! FIXME: except for one flag.
|
||||
*/
|
||||
|
||||
/* !!! FIXME: can this target support hotplugging? */
|
||||
/* !!! FIXME: ...does SDL2 even support QNX? */
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_AUDIO_DRIVER_QSA
|
||||
|
|
@ -300,7 +309,7 @@ QSA_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (towrite != 0) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -337,8 +346,9 @@ QSA_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
QSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const QSA_Device *device = (const QSA_Device *) handle;
|
||||
int status = 0;
|
||||
int format = 0;
|
||||
SDL_AudioFormat test_format = 0;
|
||||
|
|
@ -363,80 +373,19 @@ QSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
/* Initialize channel direction: capture or playback */
|
||||
this->hidden->iscapture = iscapture;
|
||||
|
||||
/* Find deviceid and cardid by device name for playback */
|
||||
if ((!this->hidden->iscapture) && (devname != NULL)) {
|
||||
uint32_t device;
|
||||
int32_t status;
|
||||
|
||||
/* Search in the playback devices */
|
||||
device = 0;
|
||||
do {
|
||||
status = SDL_strcmp(qsa_playback_device[device].name, devname);
|
||||
if (status == 0) {
|
||||
/* Found requested device */
|
||||
this->hidden->deviceno = qsa_playback_device[device].deviceno;
|
||||
this->hidden->cardno = qsa_playback_device[device].cardno;
|
||||
break;
|
||||
}
|
||||
device++;
|
||||
if (device >= qsa_playback_devices) {
|
||||
QSA_CloseDevice(this);
|
||||
return SDL_SetError("No such playback device");
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
/* Find deviceid and cardid by device name for capture */
|
||||
if ((this->hidden->iscapture) && (devname != NULL)) {
|
||||
/* Search in the capture devices */
|
||||
uint32_t device;
|
||||
int32_t status;
|
||||
|
||||
/* Searching in the playback devices */
|
||||
device = 0;
|
||||
do {
|
||||
status = SDL_strcmp(qsa_capture_device[device].name, devname);
|
||||
if (status == 0) {
|
||||
/* Found requested device */
|
||||
this->hidden->deviceno = qsa_capture_device[device].deviceno;
|
||||
this->hidden->cardno = qsa_capture_device[device].cardno;
|
||||
break;
|
||||
}
|
||||
device++;
|
||||
if (device >= qsa_capture_devices) {
|
||||
QSA_CloseDevice(this);
|
||||
return SDL_SetError("No such capture device");
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
/* Check if SDL requested default audio device */
|
||||
if (devname == NULL) {
|
||||
/* Open system default audio device */
|
||||
if (!this->hidden->iscapture) {
|
||||
status = snd_pcm_open_preferred(&this->hidden->audio_handle,
|
||||
&this->hidden->cardno,
|
||||
&this->hidden->deviceno,
|
||||
SND_PCM_OPEN_PLAYBACK);
|
||||
} else {
|
||||
status = snd_pcm_open_preferred(&this->hidden->audio_handle,
|
||||
&this->hidden->cardno,
|
||||
&this->hidden->deviceno,
|
||||
SND_PCM_OPEN_CAPTURE);
|
||||
}
|
||||
} else {
|
||||
if (device != NULL) {
|
||||
/* Open requested audio device */
|
||||
if (!this->hidden->iscapture) {
|
||||
status =
|
||||
snd_pcm_open(&this->hidden->audio_handle,
|
||||
this->hidden->cardno, this->hidden->deviceno,
|
||||
SND_PCM_OPEN_PLAYBACK);
|
||||
} else {
|
||||
status =
|
||||
snd_pcm_open(&this->hidden->audio_handle,
|
||||
this->hidden->cardno, this->hidden->deviceno,
|
||||
SND_PCM_OPEN_CAPTURE);
|
||||
}
|
||||
this->hidden->deviceno = device->deviceno;
|
||||
this->hidden->cardno = device->cardno;
|
||||
status = snd_pcm_open(&this->hidden->audio_handle,
|
||||
device->cardno, device->deviceno,
|
||||
iscapture ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_CAPTURE);
|
||||
} else {
|
||||
/* Open system default audio device */
|
||||
status = snd_pcm_open_preferred(&this->hidden->audio_handle,
|
||||
&this->hidden->cardno,
|
||||
&this->hidden->deviceno,
|
||||
iscapture ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_CAPTURE);
|
||||
}
|
||||
|
||||
/* Check if requested device is opened */
|
||||
|
|
@ -638,7 +587,7 @@ QSA_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
}
|
||||
|
||||
static void
|
||||
QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
QSA_DetectDevices(void)
|
||||
{
|
||||
uint32_t it;
|
||||
uint32_t cards;
|
||||
|
|
@ -656,8 +605,9 @@ QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
|||
return;
|
||||
}
|
||||
|
||||
/* !!! FIXME: code duplication */
|
||||
/* Find requested devices by type */
|
||||
if (!iscapture) {
|
||||
{ /* output devices */
|
||||
/* Playback devices enumeration requested */
|
||||
for (it = 0; it < cards; it++) {
|
||||
devices = 0;
|
||||
|
|
@ -688,7 +638,7 @@ QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
|||
devices;
|
||||
status = snd_pcm_close(handle);
|
||||
if (status == EOK) {
|
||||
addfn(qsa_playback_device[qsa_playback_devices].name);
|
||||
SDL_AddAudioDevice(SDL_FALSE, qsa_playback_device[qsa_playback_devices].name, &qsa_playback_device[qsa_playback_devices]);
|
||||
qsa_playback_devices++;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -713,7 +663,9 @@ QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
{ /* capture devices */
|
||||
/* Capture devices enumeration requested */
|
||||
for (it = 0; it < cards; it++) {
|
||||
devices = 0;
|
||||
|
|
@ -744,7 +696,7 @@ QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
|||
devices;
|
||||
status = snd_pcm_close(handle);
|
||||
if (status == EOK) {
|
||||
addfn(qsa_capture_device[qsa_capture_devices].name);
|
||||
SDL_AddAudioDevice(SDL_TRUE, qsa_capture_device[qsa_capture_devices].name, &qsa_capture_device[qsa_capture_devices]);
|
||||
qsa_capture_devices++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ sub outputHeader {
|
|||
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken\@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken\@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -383,6 +383,7 @@ sub buildArbitraryResampleFunc {
|
|||
my $eps_adjust = ($upsample) ? 'dstsize' : 'srcsize';
|
||||
my $incr = '';
|
||||
my $incr2 = '';
|
||||
my $block_align = $channels * $fsize/8;
|
||||
|
||||
|
||||
# !!! FIXME: DEBUG_CONVERT should report frequencies.
|
||||
|
|
@ -395,7 +396,7 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
|||
#endif
|
||||
|
||||
const int srcsize = cvt->len_cvt - $fudge;
|
||||
const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
|
||||
const int dstsize = (int) (((double)(cvt->len_cvt/${block_align})) * cvt->rate_incr) * ${block_align};
|
||||
register int eps = 0;
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -158,7 +158,7 @@ SNDIO_PlayDevice(_THIS)
|
|||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if ( written == 0 ) {
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
#ifdef DEBUG_AUDIO
|
||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||
|
|
@ -193,7 +193,7 @@ SNDIO_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
SNDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
SNDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
struct sio_par par;
|
||||
|
|
@ -209,7 +209,7 @@ SNDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
this->hidden->mixlen = this->spec.size;
|
||||
|
||||
/* !!! FIXME: SIO_DEVANY can be a specific device... */
|
||||
if ((this->hidden->dev = SNDIO_sio_open(NULL, SIO_PLAY, 0)) == NULL) {
|
||||
if ((this->hidden->dev = SNDIO_sio_open(SIO_DEVANY, SIO_PLAY, 0)) == NULL) {
|
||||
SNDIO_CloseDevice(this);
|
||||
return SDL_SetError("sio_open() failed");
|
||||
}
|
||||
|
|
@ -229,7 +229,17 @@ SNDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
par.sig = SDL_AUDIO_ISSIGNED(test_format) ? 1 : 0;
|
||||
par.bits = SDL_AUDIO_BITSIZE(test_format);
|
||||
|
||||
if (SNDIO_sio_setpar(this->hidden->dev, &par) == 1) {
|
||||
if (SNDIO_sio_setpar(this->hidden->dev, &par) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (SNDIO_sio_getpar(this->hidden->dev, &par) == 0) {
|
||||
SNDIO_CloseDevice(this);
|
||||
return SDL_SetError("sio_getpar() failed");
|
||||
}
|
||||
if (par.bps != SIO_BPS(par.bits)) {
|
||||
continue;
|
||||
}
|
||||
if ((par.bits == 8 * par.bps) || (par.msb)) {
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -242,26 +252,21 @@ SNDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return SDL_SetError("sndio: Couldn't find any hardware audio formats");
|
||||
}
|
||||
|
||||
if (SNDIO_sio_getpar(this->hidden->dev, &par) == 0) {
|
||||
SNDIO_CloseDevice(this);
|
||||
return SDL_SetError("sio_getpar() failed");
|
||||
}
|
||||
|
||||
if ((par.bits == 32) && (par.sig) && (par.le))
|
||||
if ((par.bps == 4) && (par.sig) && (par.le))
|
||||
this->spec.format = AUDIO_S32LSB;
|
||||
else if ((par.bits == 32) && (par.sig) && (!par.le))
|
||||
else if ((par.bps == 4) && (par.sig) && (!par.le))
|
||||
this->spec.format = AUDIO_S32MSB;
|
||||
else if ((par.bits == 16) && (par.sig) && (par.le))
|
||||
else if ((par.bps == 2) && (par.sig) && (par.le))
|
||||
this->spec.format = AUDIO_S16LSB;
|
||||
else if ((par.bits == 16) && (par.sig) && (!par.le))
|
||||
else if ((par.bps == 2) && (par.sig) && (!par.le))
|
||||
this->spec.format = AUDIO_S16MSB;
|
||||
else if ((par.bits == 16) && (!par.sig) && (par.le))
|
||||
else if ((par.bps == 2) && (!par.sig) && (par.le))
|
||||
this->spec.format = AUDIO_U16LSB;
|
||||
else if ((par.bits == 16) && (!par.sig) && (!par.le))
|
||||
else if ((par.bps == 2) && (!par.sig) && (!par.le))
|
||||
this->spec.format = AUDIO_U16MSB;
|
||||
else if ((par.bits == 8) && (par.sig))
|
||||
else if ((par.bps == 1) && (par.sig))
|
||||
this->spec.format = AUDIO_S8;
|
||||
else if ((par.bits == 8) && (!par.sig))
|
||||
else if ((par.bps == 1) && (!par.sig))
|
||||
this->spec.format = AUDIO_U8;
|
||||
else {
|
||||
SNDIO_CloseDevice(this);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -56,9 +56,9 @@ static Uint8 snd2au(int sample);
|
|||
|
||||
/* Audio driver bootstrap functions */
|
||||
static void
|
||||
SUNAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
SUNAUDIO_DetectDevices(void)
|
||||
{
|
||||
SDL_EnumUnixAudioDevices(iscapture, 1, (int (*)(int fd)) NULL, addfn);
|
||||
SDL_EnumUnixAudioDevices(1, (int (*)(int)) NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_AUDIO
|
||||
|
|
@ -158,7 +158,7 @@ SUNAUDIO_PlayDevice(_THIS)
|
|||
if (write(this->hidden->audio_fd, this->hidden->ulaw_buf,
|
||||
this->hidden->fragsize) < 0) {
|
||||
/* Assume fatal error, for now */
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
this->hidden->written += this->hidden->fragsize;
|
||||
} else {
|
||||
|
|
@ -168,7 +168,7 @@ SUNAUDIO_PlayDevice(_THIS)
|
|||
if (write(this->hidden->audio_fd, this->hidden->mixbuf,
|
||||
this->spec.size) < 0) {
|
||||
/* Assume fatal error, for now */
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
this->hidden->written += this->hidden->fragsize;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ SUNAUDIO_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
SUNAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
SUNAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
|
||||
SDL_AudioFormat format = 0;
|
||||
|
|
@ -414,6 +414,8 @@ SUNAUDIO_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->GetDeviceBuf = SUNAUDIO_GetDeviceBuf;
|
||||
impl->CloseDevice = SUNAUDIO_CloseDevice;
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = 1;
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -36,8 +36,9 @@
|
|||
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
|
||||
#endif
|
||||
|
||||
#define DETECT_DEV_IMPL(typ, capstyp) \
|
||||
static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \
|
||||
#define DETECT_DEV_IMPL(iscap, typ, capstyp) \
|
||||
static void DetectWave##typ##Devs(void) { \
|
||||
const UINT iscapture = iscap ? 1 : 0; \
|
||||
const UINT devcount = wave##typ##GetNumDevs(); \
|
||||
capstyp caps; \
|
||||
UINT i; \
|
||||
|
|
@ -45,24 +46,21 @@ static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \
|
|||
if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
|
||||
char *name = WIN_StringToUTF8(caps.szPname); \
|
||||
if (name != NULL) { \
|
||||
addfn(name); \
|
||||
SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i+1)); \
|
||||
SDL_free(name); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
DETECT_DEV_IMPL(Out, WAVEOUTCAPS)
|
||||
DETECT_DEV_IMPL(In, WAVEINCAPS)
|
||||
DETECT_DEV_IMPL(SDL_FALSE, Out, WAVEOUTCAPS)
|
||||
DETECT_DEV_IMPL(SDL_TRUE, In, WAVEINCAPS)
|
||||
|
||||
static void
|
||||
WINMM_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
WINMM_DetectDevices(void)
|
||||
{
|
||||
if (iscapture) {
|
||||
DetectWaveInDevs(addfn);
|
||||
} else {
|
||||
DetectWaveOutDevs(addfn);
|
||||
}
|
||||
DetectWaveInDevs();
|
||||
DetectWaveOutDevs();
|
||||
}
|
||||
|
||||
static void CALLBACK
|
||||
|
|
@ -220,48 +218,19 @@ PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture)
|
|||
}
|
||||
|
||||
static int
|
||||
WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
int valid_datatype = 0;
|
||||
MMRESULT result;
|
||||
WAVEFORMATEX waveformat;
|
||||
UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */
|
||||
char *utf8 = NULL;
|
||||
UINT i;
|
||||
|
||||
if (devname != NULL) { /* specific device requested? */
|
||||
if (iscapture) {
|
||||
const UINT devcount = waveInGetNumDevs();
|
||||
WAVEINCAPS caps;
|
||||
for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
|
||||
result = waveInGetDevCaps(i, &caps, sizeof (caps));
|
||||
if (result != MMSYSERR_NOERROR)
|
||||
continue;
|
||||
else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
|
||||
continue;
|
||||
else if (SDL_strcmp(devname, utf8) == 0)
|
||||
devId = i;
|
||||
SDL_free(utf8);
|
||||
}
|
||||
} else {
|
||||
const UINT devcount = waveOutGetNumDevs();
|
||||
WAVEOUTCAPS caps;
|
||||
for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
|
||||
result = waveOutGetDevCaps(i, &caps, sizeof (caps));
|
||||
if (result != MMSYSERR_NOERROR)
|
||||
continue;
|
||||
else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
|
||||
continue;
|
||||
else if (SDL_strcmp(devname, utf8) == 0)
|
||||
devId = i;
|
||||
SDL_free(utf8);
|
||||
}
|
||||
}
|
||||
|
||||
if (devId == WAVE_MAPPER) {
|
||||
return SDL_SetError("Requested device not found");
|
||||
}
|
||||
if (handle != NULL) { /* specific device requested? */
|
||||
/* -1 because we increment the original value to avoid NULL. */
|
||||
const size_t val = ((size_t) handle) - 1;
|
||||
devId = (UINT) val;
|
||||
}
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
|
|
@ -279,10 +248,6 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
if (this->spec.channels > 2)
|
||||
this->spec.channels = 2; /* !!! FIXME: is this right? */
|
||||
|
||||
/* Check the buffer size -- minimum of 1/4 second (word aligned) */
|
||||
if (this->spec.samples < (this->spec.freq / 4))
|
||||
this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;
|
||||
|
||||
while ((!valid_datatype) && (test_format)) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -58,13 +58,20 @@
|
|||
/* The configure script already did any necessary checking */
|
||||
# define SDL_XAUDIO2_HAS_SDK 1
|
||||
#elif defined(__WINRT__)
|
||||
/* WinRT always has access to the .the XAudio 2 SDK */
|
||||
/* WinRT always has access to the XAudio 2 SDK (albeit with a header file
|
||||
that doesn't compile as C code).
|
||||
*/
|
||||
# define SDL_XAUDIO2_HAS_SDK
|
||||
#include "SDL_xaudio2.h" /* ... compiles as C code, in contrast to XAudio2 headers
|
||||
in the Windows SDK, v.10.0.10240.0 (Win 10's initial SDK)
|
||||
*/
|
||||
#else
|
||||
/* XAudio2 exists as of the March 2008 DirectX SDK
|
||||
The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
|
||||
If you want to build SDL with XAudio2 support you should install the DirectX SDK.
|
||||
/* XAudio2 exists in the last DirectX SDK as well as the latest Windows SDK.
|
||||
To enable XAudio2 support, you will need to add the location of your DirectX SDK headers to
|
||||
the SDL projects additional include directories and then set SDL_XAUDIO2_HAS_SDK=1 as a
|
||||
preprocessor define
|
||||
*/
|
||||
#if 0 /* See comment above */
|
||||
#include <dxsdkver.h>
|
||||
#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
|
||||
# pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
|
||||
|
|
@ -72,6 +79,7 @@
|
|||
# define SDL_XAUDIO2_HAS_SDK 1
|
||||
#endif
|
||||
#endif
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef SDL_XAUDIO2_HAS_SDK
|
||||
|
||||
|
|
@ -82,17 +90,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* The XAudio header file, when #include'd on WinRT, will only compile in C++
|
||||
files, but not C. A few preprocessor-based hacks are defined below in order
|
||||
to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c.
|
||||
*/
|
||||
#ifdef __WINRT__
|
||||
#define uuid(x)
|
||||
#define DX_BUILD
|
||||
#endif
|
||||
|
||||
#if !defined(_SDL_XAUDIO2_H)
|
||||
#define INITGUID 1
|
||||
#include <xaudio2.h>
|
||||
#endif
|
||||
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
|
@ -126,16 +127,13 @@ struct SDL_PrivateAudioData
|
|||
|
||||
|
||||
static void
|
||||
XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
||||
XAUDIO2_DetectDevices(void)
|
||||
{
|
||||
IXAudio2 *ixa2 = NULL;
|
||||
UINT32 devcount = 0;
|
||||
UINT32 i = 0;
|
||||
|
||||
if (iscapture) {
|
||||
SDL_SetError("XAudio2: capture devices unsupported.");
|
||||
return;
|
||||
} else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
|
||||
if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
|
||||
SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
|
||||
return;
|
||||
} else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
|
||||
|
|
@ -149,8 +147,8 @@ XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
|
|||
if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
|
||||
char *str = WIN_StringToUTF8(details.DisplayName);
|
||||
if (str != NULL) {
|
||||
addfn(str);
|
||||
SDL_free(str); /* addfn() made a copy of the string. */
|
||||
SDL_AddAudioDevice(SDL_FALSE, str, (void *) ((size_t) i+1));
|
||||
SDL_free(str); /* SDL_AddAudioDevice made a copy of the string. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,8 +167,8 @@ VoiceCBOnBufferEnd(THIS_ void *data)
|
|||
static void STDMETHODCALLTYPE
|
||||
VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error)
|
||||
{
|
||||
/* !!! FIXME: attempt to recover, or mark device disconnected. */
|
||||
SDL_assert(0 && "write me!");
|
||||
SDL_AudioDevice *this = (SDL_AudioDevice *) data;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
|
||||
/* no-op callbacks... */
|
||||
|
|
@ -221,7 +219,7 @@ XAUDIO2_PlayDevice(_THIS)
|
|||
|
||||
if (result != S_OK) { /* uhoh, panic! */
|
||||
IXAudio2SourceVoice_FlushSourceBuffers(source);
|
||||
this->enabled = 0;
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,14 +239,14 @@ XAUDIO2_WaitDone(_THIS)
|
|||
SDL_assert(!this->enabled); /* flag that stops playing. */
|
||||
IXAudio2SourceVoice_Discontinuity(source);
|
||||
#if SDL_XAUDIO2_WIN8
|
||||
IXAudio2SourceVoice_GetState(source, &state, 0);
|
||||
IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED);
|
||||
#else
|
||||
IXAudio2SourceVoice_GetState(source, &state);
|
||||
#endif
|
||||
while (state.BuffersQueued > 0) {
|
||||
SDL_SemWait(this->hidden->semaphore);
|
||||
#if SDL_XAUDIO2_WIN8
|
||||
IXAudio2SourceVoice_GetState(source, &state, 0);
|
||||
IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED);
|
||||
#else
|
||||
IXAudio2SourceVoice_GetState(source, &state);
|
||||
#endif
|
||||
|
|
@ -289,7 +287,7 @@ XAUDIO2_CloseDevice(_THIS)
|
|||
}
|
||||
|
||||
static int
|
||||
XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
XAUDIO2_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
WAVEFORMATEX waveformat;
|
||||
|
|
@ -315,9 +313,17 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
|
||||
static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
|
||||
|
||||
if (iscapture) {
|
||||
return SDL_SetError("XAudio2: capture devices unsupported.");
|
||||
} else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
|
||||
#if defined(SDL_XAUDIO2_WIN8)
|
||||
/* !!! FIXME: hook up hotplugging. */
|
||||
#else
|
||||
if (handle != NULL) { /* specific device requested? */
|
||||
/* -1 because we increment the original value to avoid NULL. */
|
||||
const size_t val = ((size_t) handle) - 1;
|
||||
devId = (UINT32) val;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
|
||||
return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
|
||||
}
|
||||
|
||||
|
|
@ -332,37 +338,6 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
ixa2->SetDebugConfiguration(&debugConfig);
|
||||
*/
|
||||
|
||||
#if ! defined(__WINRT__)
|
||||
if (devname != NULL) {
|
||||
UINT32 devcount = 0;
|
||||
UINT32 i = 0;
|
||||
|
||||
if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
|
||||
IXAudio2_Release(ixa2);
|
||||
return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
|
||||
}
|
||||
for (i = 0; i < devcount; i++) {
|
||||
XAUDIO2_DEVICE_DETAILS details;
|
||||
if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
|
||||
char *str = WIN_StringToUTF8(details.DisplayName);
|
||||
if (str != NULL) {
|
||||
const int match = (SDL_strcmp(str, devname) == 0);
|
||||
SDL_free(str);
|
||||
if (match) {
|
||||
devId = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == devcount) {
|
||||
IXAudio2_Release(ixa2);
|
||||
return SDL_SetError("XAudio2: Requested device not found.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
|
|
@ -529,6 +504,16 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
|
|||
impl->CloseDevice = XAUDIO2_CloseDevice;
|
||||
impl->Deinitialize = XAUDIO2_Deinitialize;
|
||||
|
||||
/* !!! FIXME: We can apparently use a C++ interface on Windows 8
|
||||
* !!! FIXME: (Windows::Devices::Enumeration::DeviceInformation) for device
|
||||
* !!! FIXME: detection, but it's not implemented here yet.
|
||||
* !!! FIXME: see http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
|
||||
* !!! FIXME: for now, force the default device.
|
||||
*/
|
||||
#if defined(SDL_XAUDIO2_WIN8) || defined(__WINRT__)
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
#endif
|
||||
|
||||
return 1; /* this audio target is available. */
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
386
Engine/lib/sdl/src/audio/xaudio2/SDL_xaudio2.h
Normal file
386
Engine/lib/sdl/src/audio/xaudio2/SDL_xaudio2.h
Normal file
|
|
@ -0,0 +1,386 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_XAUDIO2_H
|
||||
#define _SDL_XAUDIO2_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <objbase.h>
|
||||
|
||||
/* XAudio2 packs its structure members together as tightly as possible.
|
||||
This pragma is needed to ensure compatibility with XAudio2 on 64-bit
|
||||
platforms.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef interface IXAudio2 IXAudio2;
|
||||
typedef interface IXAudio2SourceVoice IXAudio2SourceVoice;
|
||||
typedef interface IXAudio2MasteringVoice IXAudio2MasteringVoice;
|
||||
typedef interface IXAudio2EngineCallback IXAudio2EngineCallback;
|
||||
typedef interface IXAudio2VoiceCallback IXAudio2VoiceCallback;
|
||||
typedef interface IXAudio2Voice IXAudio2Voice;
|
||||
typedef interface IXAudio2SubmixVoice IXAudio2SubmixVoice;
|
||||
|
||||
typedef enum _AUDIO_STREAM_CATEGORY {
|
||||
AudioCategory_Other = 0,
|
||||
AudioCategory_ForegroundOnlyMedia,
|
||||
AudioCategory_BackgroundCapableMedia,
|
||||
AudioCategory_Communications,
|
||||
AudioCategory_Alerts,
|
||||
AudioCategory_SoundEffects,
|
||||
AudioCategory_GameEffects,
|
||||
AudioCategory_GameMedia,
|
||||
AudioCategory_GameChat,
|
||||
AudioCategory_Movie,
|
||||
AudioCategory_Media
|
||||
} AUDIO_STREAM_CATEGORY;
|
||||
|
||||
typedef struct XAUDIO2_BUFFER {
|
||||
UINT32 Flags;
|
||||
UINT32 AudioBytes;
|
||||
const BYTE *pAudioData;
|
||||
UINT32 PlayBegin;
|
||||
UINT32 PlayLength;
|
||||
UINT32 LoopBegin;
|
||||
UINT32 LoopLength;
|
||||
UINT32 LoopCount;
|
||||
void *pContext;
|
||||
} XAUDIO2_BUFFER;
|
||||
|
||||
typedef struct XAUDIO2_BUFFER_WMA {
|
||||
const UINT32 *pDecodedPacketCumulativeBytes;
|
||||
UINT32 PacketCount;
|
||||
} XAUDIO2_BUFFER_WMA;
|
||||
|
||||
typedef struct XAUDIO2_SEND_DESCRIPTOR {
|
||||
UINT32 Flags;
|
||||
IXAudio2Voice *pOutputVoice;
|
||||
} XAUDIO2_SEND_DESCRIPTOR;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_SENDS {
|
||||
UINT32 SendCount;
|
||||
XAUDIO2_SEND_DESCRIPTOR *pSends;
|
||||
} XAUDIO2_VOICE_SENDS;
|
||||
|
||||
typedef struct XAUDIO2_EFFECT_DESCRIPTOR {
|
||||
IUnknown *pEffect;
|
||||
BOOL InitialState;
|
||||
UINT32 OutputChannels;
|
||||
} XAUDIO2_EFFECT_DESCRIPTOR;
|
||||
|
||||
typedef struct XAUDIO2_EFFECT_CHAIN {
|
||||
UINT32 EffectCount;
|
||||
XAUDIO2_EFFECT_DESCRIPTOR *pEffectDescriptors;
|
||||
} XAUDIO2_EFFECT_CHAIN;
|
||||
|
||||
typedef struct XAUDIO2_PERFORMANCE_DATA {
|
||||
UINT64 AudioCyclesSinceLastQuery;
|
||||
UINT64 TotalCyclesSinceLastQuery;
|
||||
UINT32 MinimumCyclesPerQuantum;
|
||||
UINT32 MaximumCyclesPerQuantum;
|
||||
UINT32 MemoryUsageInBytes;
|
||||
UINT32 CurrentLatencyInSamples;
|
||||
UINT32 GlitchesSinceEngineStarted;
|
||||
UINT32 ActiveSourceVoiceCount;
|
||||
UINT32 TotalSourceVoiceCount;
|
||||
UINT32 ActiveSubmixVoiceCount;
|
||||
UINT32 ActiveResamplerCount;
|
||||
UINT32 ActiveMatrixMixCount;
|
||||
UINT32 ActiveXmaSourceVoices;
|
||||
UINT32 ActiveXmaStreams;
|
||||
} XAUDIO2_PERFORMANCE_DATA;
|
||||
|
||||
typedef struct XAUDIO2_DEBUG_CONFIGURATION {
|
||||
UINT32 TraceMask;
|
||||
UINT32 BreakMask;
|
||||
BOOL LogThreadID;
|
||||
BOOL LogFileline;
|
||||
BOOL LogFunctionName;
|
||||
BOOL LogTiming;
|
||||
} XAUDIO2_DEBUG_CONFIGURATION;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_DETAILS {
|
||||
UINT32 CreationFlags;
|
||||
UINT32 ActiveFlags;
|
||||
UINT32 InputChannels;
|
||||
UINT32 InputSampleRate;
|
||||
} XAUDIO2_VOICE_DETAILS;
|
||||
|
||||
typedef enum XAUDIO2_FILTER_TYPE {
|
||||
LowPassFilter = 0,
|
||||
BandPassFilter = 1,
|
||||
HighPassFilter = 2,
|
||||
NotchFilter = 3,
|
||||
LowPassOnePoleFilter = 4,
|
||||
HighPassOnePoleFilter = 5
|
||||
} XAUDIO2_FILTER_TYPE;
|
||||
|
||||
typedef struct XAUDIO2_FILTER_PARAMETERS {
|
||||
XAUDIO2_FILTER_TYPE Type;
|
||||
float Frequency;
|
||||
float OneOverQ;
|
||||
} XAUDIO2_FILTER_PARAMETERS;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_STATE {
|
||||
void *pCurrentBufferContext;
|
||||
UINT32 BuffersQueued;
|
||||
UINT64 SamplesPlayed;
|
||||
} XAUDIO2_VOICE_STATE;
|
||||
|
||||
|
||||
typedef UINT32 XAUDIO2_PROCESSOR;
|
||||
#define Processor1 0x00000001
|
||||
#define XAUDIO2_DEFAULT_PROCESSOR Processor1
|
||||
|
||||
#define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004
|
||||
#define XAUDIO2_COMMIT_NOW 0
|
||||
#define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100
|
||||
#define XAUDIO2_DEFAULT_CHANNELS 0
|
||||
|
||||
extern HRESULT __stdcall XAudio2Create(
|
||||
_Out_ IXAudio2 **ppXAudio2,
|
||||
_In_ UINT32 Flags,
|
||||
_In_ XAUDIO2_PROCESSOR XAudio2Processor
|
||||
);
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IXAudio2
|
||||
typedef interface IXAudio2 {
|
||||
const struct IXAudio2Vtbl FAR* lpVtbl;
|
||||
} IXAudio2;
|
||||
typedef const struct IXAudio2Vtbl IXAudio2Vtbl;
|
||||
const struct IXAudio2Vtbl
|
||||
{
|
||||
/* IUnknown */
|
||||
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
|
||||
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
|
||||
STDMETHOD_(ULONG, Release)(THIS) PURE;
|
||||
|
||||
/* IXAudio2 */
|
||||
STDMETHOD_(HRESULT, RegisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
|
||||
STDMETHOD_(VOID, UnregisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
|
||||
STDMETHOD_(HRESULT, CreateSourceVoice)(THIS, IXAudio2SourceVoice **ppSourceVoice,
|
||||
const WAVEFORMATEX *pSourceFormat,
|
||||
UINT32 Flags,
|
||||
float MaxFrequencyRatio,
|
||||
IXAudio2VoiceCallback *pCallback,
|
||||
const XAUDIO2_VOICE_SENDS *pSendList,
|
||||
const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
|
||||
STDMETHOD_(HRESULT, CreateSubmixVoice)(THIS, IXAudio2SubmixVoice **ppSubmixVoice,
|
||||
UINT32 InputChannels,
|
||||
UINT32 InputSampleRate,
|
||||
UINT32 Flags,
|
||||
UINT32 ProcessingStage,
|
||||
const XAUDIO2_VOICE_SENDS *pSendList,
|
||||
const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
|
||||
STDMETHOD_(HRESULT, CreateMasteringVoice)(THIS, IXAudio2MasteringVoice **ppMasteringVoice,
|
||||
UINT32 InputChannels,
|
||||
UINT32 InputSampleRate,
|
||||
UINT32 Flags,
|
||||
LPCWSTR szDeviceId,
|
||||
const XAUDIO2_EFFECT_CHAIN *pEffectChain,
|
||||
AUDIO_STREAM_CATEGORY StreamCategory) PURE;
|
||||
STDMETHOD_(HRESULT, StartEngine)(THIS) PURE;
|
||||
STDMETHOD_(VOID, StopEngine)(THIS) PURE;
|
||||
STDMETHOD_(HRESULT, CommitChanges)(THIS, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(HRESULT, GetPerformanceData)(THIS, XAUDIO2_PERFORMANCE_DATA *pPerfData) PURE;
|
||||
STDMETHOD_(HRESULT, SetDebugConfiguration)(THIS, XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
|
||||
VOID *pReserved) PURE;
|
||||
};
|
||||
|
||||
#define IXAudio2_Release(A) ((A)->lpVtbl->Release(A))
|
||||
#define IXAudio2_CreateSourceVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateSourceVoice(A,B,C,D,E,F,G,H))
|
||||
#define IXAudio2_CreateMasteringVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateMasteringVoice(A,B,C,D,E,F,G,H))
|
||||
#define IXAudio2_StartEngine(A) ((A)->lpVtbl->StartEngine(A))
|
||||
#define IXAudio2_StopEngine(A) ((A)->lpVtbl->StopEngine(A))
|
||||
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IXAudio2SourceVoice
|
||||
typedef interface IXAudio2SourceVoice {
|
||||
const struct IXAudio2SourceVoiceVtbl FAR* lpVtbl;
|
||||
} IXAudio2SourceVoice;
|
||||
typedef const struct IXAudio2SourceVoiceVtbl IXAudio2SourceVoiceVtbl;
|
||||
const struct IXAudio2SourceVoiceVtbl
|
||||
{
|
||||
/* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
|
||||
* says otherwise, and that IXAudio2Voice doesn't inherit from any other
|
||||
* interface!
|
||||
*/
|
||||
|
||||
/* IXAudio2Voice */
|
||||
STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
|
||||
STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
|
||||
STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
|
||||
STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
|
||||
const void *pParameters,
|
||||
UINT32 ParametersByteSize,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
|
||||
void *pParameters,
|
||||
UINT32 ParametersByteSize) PURE;
|
||||
STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
XAUDIO2_FILTER_PARAMETERS *pParameters,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
|
||||
STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
|
||||
STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
|
||||
const float *pVolumes,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
|
||||
float *pVolumes) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
UINT32 SourceChannels,
|
||||
UINT32 DestinationChannels,
|
||||
const float *pLevelMatrix,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
UINT32 SourceChannels,
|
||||
UINT32 DestinationChannels,
|
||||
float *pLevelMatrix) PURE;
|
||||
STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
|
||||
|
||||
/* IXAudio2SourceVoice */
|
||||
STDMETHOD_(HRESULT, Start)(THIS, UINT32 Flags,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(HRESULT, Stop)(THIS, UINT32 Flags,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(HRESULT, SubmitSourceBuffer)(THIS, const XAUDIO2_BUFFER *pBuffer,
|
||||
const XAUDIO2_BUFFER_WMA *pBufferWMA) PURE;
|
||||
STDMETHOD_(HRESULT, FlushSourceBuffers)(THIS) PURE;
|
||||
STDMETHOD_(HRESULT, Discontinuity)(THIS) PURE;
|
||||
STDMETHOD_(HRESULT, ExitLoop)(THIS, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetState)(THIS, XAUDIO2_VOICE_STATE *pVoiceState,
|
||||
UINT32 Flags) PURE;
|
||||
STDMETHOD_(HRESULT, SetFrequencyRatio)(THIS, float Ratio,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetFrequencyRatio)(THIS, float *pRatio) PURE;
|
||||
STDMETHOD_(HRESULT, SetSourceSampleRate)(THIS, UINT32 NewSourceSampleRate) PURE;
|
||||
};
|
||||
|
||||
#define IXAudio2SourceVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
|
||||
#define IXAudio2SourceVoice_Start(A,B,C) ((A)->lpVtbl->Start(A,B,C))
|
||||
#define IXAudio2SourceVoice_Stop(A,B,C) ((A)->lpVtbl->Stop(A,B,C))
|
||||
#define IXAudio2SourceVoice_SubmitSourceBuffer(A,B,C) ((A)->lpVtbl->SubmitSourceBuffer(A,B,C))
|
||||
#define IXAudio2SourceVoice_FlushSourceBuffers(A) ((A)->lpVtbl->FlushSourceBuffers(A))
|
||||
#define IXAudio2SourceVoice_Discontinuity(A) ((A)->lpVtbl->Discontinuity(A))
|
||||
#define IXAudio2SourceVoice_GetState(A,B,C) ((A)->lpVtbl->GetState(A,B,C))
|
||||
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IXAudio2MasteringVoice
|
||||
typedef interface IXAudio2MasteringVoice {
|
||||
const struct IXAudio2MasteringVoiceVtbl FAR* lpVtbl;
|
||||
} IXAudio2MasteringVoice;
|
||||
typedef const struct IXAudio2MasteringVoiceVtbl IXAudio2MasteringVoiceVtbl;
|
||||
const struct IXAudio2MasteringVoiceVtbl
|
||||
{
|
||||
/* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
|
||||
* says otherwise, and that IXAudio2Voice doesn't inherit from any other
|
||||
* interface!
|
||||
*/
|
||||
|
||||
/* IXAudio2Voice */
|
||||
STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
|
||||
STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
|
||||
STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
|
||||
STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
|
||||
const void *pParameters,
|
||||
UINT32 ParametersByteSize,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
|
||||
void *pParameters,
|
||||
UINT32 ParametersByteSize) PURE;
|
||||
STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
XAUDIO2_FILTER_PARAMETERS *pParameters,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
|
||||
STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
|
||||
STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
|
||||
const float *pVolumes,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
|
||||
float *pVolumes) PURE;
|
||||
STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
UINT32 SourceChannels,
|
||||
UINT32 DestinationChannels,
|
||||
const float *pLevelMatrix,
|
||||
UINT32 OperationSet) PURE;
|
||||
STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
|
||||
UINT32 SourceChannels,
|
||||
UINT32 DestinationChannels,
|
||||
float *pLevelMatrix) PURE;
|
||||
STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
|
||||
|
||||
/* IXAudio2SourceVoice */
|
||||
STDMETHOD_(VOID, GetChannelMask)(THIS, DWORD *pChannelMask) PURE;
|
||||
};
|
||||
|
||||
#define IXAudio2MasteringVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
|
||||
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IXAudio2VoiceCallback
|
||||
typedef interface IXAudio2VoiceCallback {
|
||||
const struct IXAudio2VoiceCallbackVtbl FAR* lpVtbl;
|
||||
} IXAudio2VoiceCallback;
|
||||
typedef const struct IXAudio2VoiceCallbackVtbl IXAudio2VoiceCallbackVtbl;
|
||||
const struct IXAudio2VoiceCallbackVtbl
|
||||
{
|
||||
/* MSDN says that IXAudio2VoiceCallback inherits from IXAudio2, but SDL's
|
||||
* own code says otherwise, and that IXAudio2VoiceCallback doesn't inherit
|
||||
* from any other interface!
|
||||
*/
|
||||
|
||||
/* IXAudio2VoiceCallback */
|
||||
STDMETHOD_(VOID, OnVoiceProcessingPassStart)(THIS, UINT32 BytesRequired) PURE;
|
||||
STDMETHOD_(VOID, OnVoiceProcessingPassEnd)(THIS) PURE;
|
||||
STDMETHOD_(VOID, OnStreamEnd)(THIS) PURE;
|
||||
STDMETHOD_(VOID, OnBufferStart)(THIS, void *pBufferContext) PURE;
|
||||
STDMETHOD_(VOID, OnBufferEnd)(THIS, void *pBufferContext) PURE;
|
||||
STDMETHOD_(VOID, OnLoopEnd)(THIS, void *pBufferContext) PURE;
|
||||
STDMETHOD_(VOID, OnVoiceError)(THIS, void *pBufferContext, HRESULT Error) PURE;
|
||||
};
|
||||
|
||||
#pragma pack(pop) /* Undo pragma push */
|
||||
|
||||
#endif /* _SDL_XAUDIO2_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue