21#include "../SDL_internal.h"
34#include "../SDL_dataqueue.h"
37#define DEBUG_AUDIOSTREAM 0
40#define HAVE_SSE3_INTRINSICS 1
43#if HAVE_SSE3_INTRINSICS
48 float *
dst = (
float *) cvt->
buf;
57 if ((((
size_t)
dst) & 15) == 0) {
59 const __m128 divby2 = _mm_set1_ps(0.5f);
61 _mm_store_ps(
dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(
src), _mm_load_ps(
src+4)), divby2));
83 float *
dst = (
float *) cvt->
buf;
105 float *
dst = (
float *) cvt->
buf;
114 const float front_center_distributed =
src[2] * 0.5f;
115 dst[0] = (
src[0] + front_center_distributed +
src[4]) / 2.5f;
116 dst[1] = (
src[1] + front_center_distributed +
src[5]) / 2.5f;
130 float *
dst = (
float *) cvt->
buf;
153 float *
dst = (
float *) cvt->
buf;
161 const float surround_left_distributed =
src[6] * 0.5f;
162 const float surround_right_distributed =
src[7] * 0.5f;
163 dst[0] = (
src[0] + surround_left_distributed) / 1.5f;
164 dst[1] = (
src[1] + surround_right_distributed) / 1.5f;
167 dst[4] = (
src[4] + surround_left_distributed) / 1.5f;
168 dst[5] = (
src[5] + surround_right_distributed) / 1.5f;
183 float *
dst = (
float *) cvt->
buf;
193 const float front_center_distributed =
src[2] * 0.5f;
194 dst[0] = (
src[0] + front_center_distributed) / 1.5f;
195 dst[1] = (
src[1] + front_center_distributed) / 1.5f;
212 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
219 for (
i = cvt->
len_cvt / sizeof (
float);
i; --
i) {
238 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
244 for (
i = cvt->
len_cvt / (
sizeof(
float) * 2);
i; --
i) {
249 ce = (lf + rf) * 0.5f;
251 dst[0] = lf + (lf - ce);
252 dst[1] = rf + (rf - ce);
271 float lf, rf, lb, rb, ce;
272 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
279 for (
i = cvt->
len_cvt / (
sizeof(
float) * 4);
i; --
i) {
286 ce = (lf + rf) * 0.5f;
288 dst[0] = lf + (lf - ce);
289 dst[1] = rf + (rf - ce);
307 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
315 for (
i = cvt->
len_cvt / (
sizeof(
float) * 2);
i; --
i) {
337 float lf, rf, lb, rb, ls, rs;
339 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
346 for (
i = cvt->
len_cvt / (
sizeof(
float) * 6);
i; --
i) {
353 ls = (lf + lb) * 0.5f;
354 rs = (rf + rb) * 0.5f;
380#define RESAMPLER_ZERO_CROSSINGS 5
381#define RESAMPLER_BITS_PER_SAMPLE 16
382#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))
383#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)
389 const double xdiv2 =
x / 2.0;
396 if (diff < 1.0e-21f) {
411 const int lenm1 = tablelen - 1;
412 const int lenm1div2 = lenm1 / 2;
416 for (
i = 1;
i < tablelen;
i++) {
418 table[tablelen -
i] = (float) kaiser;
421 for (
i = 1;
i < tablelen;
i++) {
440 const double dB = 80.0;
441 const double beta = 0.1102 * (dB - 8.7);
475 if (inrate == outrate) {
477 }
else if (inrate > outrate) {
486 const float *lpadding,
const float *rpadding,
487 const float *inbuf,
const int inbuflen,
488 float *outbuf,
const int outbuflen)
490 const double finrate = (double) inrate;
491 const double outtimeincr = 1.0 / ((float) outrate);
492 const double ratio = ((float) outrate) / ((float) inrate);
494 const int framelen = chans * (int)
sizeof (
float);
495 const int inframes = inbuflen / framelen;
496 const int wantedoutframes = (int) ((inbuflen / framelen) * ratio);
497 const int maxoutframes = outbuflen / framelen;
498 const int outframes =
SDL_min(wantedoutframes, maxoutframes);
500 double outtime = 0.0;
503 for (
i = 0;
i < outframes;
i++) {
504 const int srcindex = (int) (outtime * inrate);
505 const double intime = ((double) srcindex) / finrate;
506 const double innexttime = ((double) (srcindex + 1)) / finrate;
507 const double interpolation1 = 1.0 - ((innexttime - outtime) / (innexttime - intime));
509 const double interpolation2 = 1.0 - interpolation1;
512 for (chan = 0; chan < chans; chan++) {
513 float outsample = 0.0f;
518 const int srcframe = srcindex -
j;
520 const float insample = (srcframe < 0) ? lpadding[((paddinglen + srcframe) * chans) + chan] : inbuf[(srcframe * chans) + chan];
525 const int srcframe = srcindex + 1 +
j;
527 const float insample = (srcframe >= inframes) ? rpadding[((srcframe - inframes) * chans) + chan] : inbuf[(srcframe * chans) + chan];
530 *(
dst++) = outsample;
533 outtime += outtimeincr;
536 return outframes * chans *
sizeof (float);
547 return SDL_SetError(
"No buffer allocated for conversion");
566 printf(
"Converting byte order\n");
570 #define CASESWAP(b) \
572 Uint##b *ptr = (Uint##b *) cvt->buf; \
574 for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \
575 *ptr = SDL_Swap##b(*ptr); \
586 default:
SDL_assert(!
"unhandled byteswap datatype!");
break;
592 format &= ~SDL_AUDIO_MASK_ENDIAN;
628 const Uint16 dst_bitsize = 32;
637 default:
SDL_assert(!
"Unexpected audio format!");
break;
641 return SDL_SetError(
"No conversion from source format to float available");
647 if (src_bitsize < dst_bitsize) {
648 const int mult = (dst_bitsize / src_bitsize);
651 }
else if (src_bitsize > dst_bitsize) {
652 cvt->
len_ratio /= (src_bitsize / dst_bitsize);
668 const Uint16 src_bitsize = 32;
676 default:
SDL_assert(!
"Unexpected audio format!");
break;
680 return SDL_SetError(
"No conversion from float to destination format available");
686 if (src_bitsize < dst_bitsize) {
687 const int mult = (dst_bitsize / src_bitsize);
690 }
else if (src_bitsize > dst_bitsize) {
691 cvt->
len_ratio /= (src_bitsize / dst_bitsize);
714 const float *
src = (
const float *) cvt->
buf;
715 const int srclen = cvt->
len_cvt;
719 float *
dst = (
float *) (cvt->
buf + srclen);
720 const int dstlen = (cvt->
len * cvt->
len_mult) - srclen;
726 paddingsamples = requestedpadding * chans;
733 padding = (
float *)
SDL_calloc(paddingsamples ? paddingsamples : 1,
sizeof (
float));
754#define RESAMPLER_FUNCS(chans) \
755 static void SDLCALL \
756 SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
757 SDL_ResampleCVT(cvt, chans, format); \
764#undef RESAMPLER_FUNCS
769 switch (dst_channels) {
770 case 1:
return SDL_ResampleCVT_c1;
771 case 2:
return SDL_ResampleCVT_c2;
772 case 4:
return SDL_ResampleCVT_c4;
773 case 6:
return SDL_ResampleCVT_c6;
774 case 8:
return SDL_ResampleCVT_c8;
783 const int src_rate,
const int dst_rate)
787 if (src_rate == dst_rate) {
793 return SDL_SetError(
"No conversion available for these rates");
814 if (src_rate < dst_rate) {
815 const double mult = ((double) dst_rate) / ((double) src_rate);
819 cvt->
len_ratio /= ((double) src_rate) / ((double) dst_rate);
898 }
else if (src_rate <= 0) {
899 return SDL_SetError(
"Source rate is equal to or less than zero");
900 }
else if (dst_rate <= 0) {
901 return SDL_SetError(
"Destination rate is equal to or less than zero");
909 printf(
"Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
910 src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
921 cvt->
rate_incr = ((double) dst_rate) / ((double) src_rate);
941 if (src_rate == dst_rate && src_channels == dst_channels) {
942 if (src_fmt == dst_fmt) {
962 if (src_channels < dst_channels) {
965 if ((src_channels == 1) && (dst_channels > 1)) {
974 if ((src_channels == 2) && (dst_channels >= 6)) {
983 if ((src_channels == 4) && (dst_channels >= 6)) {
992 if ((src_channels == 6) && (dst_channels == 8)) {
1003 if ((src_channels == 2) && (dst_channels == 4)) {
1011 }
else if (src_channels > dst_channels) {
1015 if ((src_channels == 8) && (dst_channels <= 6)) {
1023 if ((src_channels == 6) && (dst_channels <= 2)) {
1031 if ((src_channels == 6) && (dst_channels == 4)) {
1039 if ((src_channels == 4) && (dst_channels <= 2)) {
1047 if ((src_channels == 2) && (dst_channels == 1)) {
1050 #if HAVE_SSE3_INTRINSICS
1052 filter = SDL_ConvertStereoToMono_SSE3;
1069 if (src_channels != dst_channels) {
1129 if (
stream->work_buffer_len >= newlen) {
1130 ptr =
stream->work_buffer_base;
1138 stream->work_buffer_base = ptr;
1139 stream->work_buffer_len = newlen;
1146#ifdef HAVE_LIBSAMPLERATE_H
1148SDL_ResampleAudioStream_SRC(SDL_AudioStream *
stream,
const void *_inbuf,
const int inbuflen,
void *_outbuf,
const int outbuflen)
1150 const float *inbuf = (
const float *) _inbuf;
1151 float *outbuf = (
float *) _outbuf;
1152 const int framelen =
sizeof(float) *
stream->pre_resample_channels;
1153 SRC_STATE *
state = (SRC_STATE *)
stream->resampler_state;
1157 SDL_assert(inbuf != ((
const float *) outbuf));
1159 data.data_in = (
float *)inbuf;
1160 data.input_frames = inbuflen / framelen;
1161 data.input_frames_used = 0;
1163 data.data_out = outbuf;
1164 data.output_frames = outbuflen / framelen;
1166 data.end_of_input = 0;
1178 return data.output_frames_gen * (
sizeof(float) *
stream->pre_resample_channels);
1182SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *
stream)
1184 SRC_src_reset((SRC_STATE *)
stream->resampler_state);
1188SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *
stream)
1190 SRC_STATE *
state = (SRC_STATE *)
stream->resampler_state;
1192 SRC_src_delete(
state);
1202SetupLibSampleRateResampling(SDL_AudioStream *
stream)
1207 if (SRC_available) {
1215 SDL_CleanupAudioStreamResampler_SRC(
stream);
1220 stream->resampler_func = SDL_ResampleAudioStream_SRC;
1221 stream->reset_resampler_func = SDL_ResetAudioStreamResampler_SRC;
1222 stream->cleanup_resampler_func = SDL_CleanupAudioStreamResampler_SRC;
1232 const Uint8 *inbufend = ((
const Uint8 *) _inbuf) + inbuflen;
1233 const float *inbuf = (
const float *) _inbuf;
1234 float *outbuf = (
float *) _outbuf;
1235 const int chans = (int)
stream->pre_resample_channels;
1236 const int inrate =
stream->src_rate;
1237 const int outrate =
stream->dst_rate;
1238 const int paddingsamples =
stream->resampler_padding_samples;
1239 const int paddingbytes = paddingsamples * sizeof (
float);
1240 float *lpadding = (
float *)
stream->resampler_state;
1241 const float *rpadding = (
const float *) inbufend;
1242 const int cpy =
SDL_min(inbuflen, paddingbytes);
1245 SDL_assert(inbuf != ((
const float *) outbuf));
1250 SDL_memcpy((lpadding + paddingsamples) - (cpy /
sizeof (
float)), inbufend - cpy, cpy);
1258 const int len =
stream->resampler_padding_samples;
1270 const Uint8 src_channels,
1273 const Uint8 dst_channels,
1276 const int packetlen = 4096;
1277 Uint8 pre_resample_channels;
1289 pre_resample_channels =
SDL_min(src_channels, dst_channels);
1293 retval->src_format = src_format;
1294 retval->src_channels = src_channels;
1295 retval->src_rate = src_rate;
1297 retval->dst_format = dst_format;
1298 retval->dst_channels = dst_channels;
1299 retval->dst_rate = dst_rate;
1300 retval->pre_resample_channels = pre_resample_channels;
1301 retval->packetlen = packetlen;
1302 retval->rate_incr = ((double) dst_rate) / ((double) src_rate);
1304 retval->resampler_padding = (
float *)
SDL_calloc(
retval->resampler_padding_samples ?
retval->resampler_padding_samples : 1, sizeof (
float));
1312 retval->staging_buffer_size = ((
retval->resampler_padding_samples /
retval->pre_resample_channels) *
retval->src_sample_frame_size);
1313 if (
retval->staging_buffer_size > 0) {
1323 if (src_rate == dst_rate) {
1325 if (
SDL_BuildAudioCVT(&
retval->cvt_after_resampling, src_format, src_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
1337#ifdef HAVE_LIBSAMPLERATE_H
1338 SetupLibSampleRateResampling(
retval);
1341 if (!
retval->resampler_func) {
1343 if (!
retval->resampler_state) {
1384 int resamplebuflen = 0;
1385 int neededpaddingbytes;
1397 neededpaddingbytes =
stream->resampler_padding_samples *
sizeof (float);
1398 paddingbytes =
stream->first_run ? 0 : neededpaddingbytes;
1402 workbuflen = buflen;
1403 if (
stream->cvt_before_resampling.needed) {
1404 workbuflen *=
stream->cvt_before_resampling.len_mult;
1409 const int framesize =
stream->pre_resample_channels *
sizeof (float);
1410 const int frames = workbuflen / framesize;
1412 #if DEBUG_AUDIOSTREAM
1413 printf(
"AUDIOSTREAM: will resample %d bytes to %d (ratio=%.6f)\n", workbuflen, resamplebuflen,
stream->rate_incr);
1415 workbuflen += resamplebuflen;
1418 if (
stream->cvt_after_resampling.needed) {
1420 workbuflen *=
stream->cvt_after_resampling.len_mult;
1423 workbuflen += neededpaddingbytes;
1425 #if DEBUG_AUDIOSTREAM
1426 printf(
"AUDIOSTREAM: Putting %d bytes of preconverted audio, need %d byte work buffer\n", buflen, workbuflen);
1434 resamplebuf = workbuf;
1438 if (
stream->cvt_before_resampling.needed) {
1439 stream->cvt_before_resampling.buf = workbuf + paddingbytes;
1440 stream->cvt_before_resampling.len = buflen;
1444 buflen =
stream->cvt_before_resampling.len_cvt;
1446 #if DEBUG_AUDIOSTREAM
1447 printf(
"AUDIOSTREAM: After initial conversion we have %d bytes\n", buflen);
1459 buflen += paddingbytes;
1463 SDL_memcpy(
stream->resampler_padding, workbuf + (buflen - neededpaddingbytes), neededpaddingbytes);
1465 resamplebuf = workbuf + buflen;
1467 if (buflen > neededpaddingbytes) {
1468 buflen =
stream->resampler_func(
stream, workbuf, buflen - neededpaddingbytes, resamplebuf, resamplebuflen);
1473 #if DEBUG_AUDIOSTREAM
1474 printf(
"AUDIOSTREAM: After resampling we have %d bytes\n", buflen);
1478 if (
stream->cvt_after_resampling.needed && (buflen > 0)) {
1479 stream->cvt_after_resampling.buf = resamplebuf;
1480 stream->cvt_after_resampling.len = buflen;
1484 buflen =
stream->cvt_after_resampling.len_cvt;
1486 #if DEBUG_AUDIOSTREAM
1487 printf(
"AUDIOSTREAM: After final conversion we have %d bytes\n", buflen);
1491 #if DEBUG_AUDIOSTREAM
1492 printf(
"AUDIOSTREAM: Final output is %d bytes\n", buflen);
1496 const int maxbytes = *maxputbytes;
1497 if (buflen > maxbytes)
1499 *maxputbytes -= buflen;
1517 #if DEBUG_AUDIOSTREAM
1518 printf(
"AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
1525 }
else if (
len == 0) {
1527 }
else if ((
len %
stream->src_sample_frame_size) != 0) {
1528 return SDL_SetError(
"Can't add partial sample frames");
1531 if (!
stream->cvt_before_resampling.needed &&
1533 !
stream->cvt_after_resampling.needed) {
1534 #if DEBUG_AUDIOSTREAM
1535 printf(
"AUDIOSTREAM: no conversion needed at all, queueing %d bytes.\n",
len);
1546 if (!
stream->staging_buffer_filled &&
len >=
stream->staging_buffer_size) {
1551 if ((
stream->staging_buffer_filled +
len) <
stream->staging_buffer_size) {
1558 amount = (
stream->staging_buffer_size -
stream->staging_buffer_filled);
1561 stream->staging_buffer_filled = 0;
1577 #if DEBUG_AUDIOSTREAM
1578 printf(
"AUDIOSTREAM: flushing! staging_buffer_filled=%d bytes\n",
stream->staging_buffer_filled);
1584 if (
stream->staging_buffer_filled > 0) {
1589 const int filled =
stream->staging_buffer_filled;
1590 int actual_input_frames = filled /
stream->src_sample_frame_size;
1592 actual_input_frames +=
stream->resampler_padding_samples /
stream->pre_resample_channels;
1594 if (actual_input_frames > 0) {
1596 int flush_remaining = ((int)
SDL_ceil(actual_input_frames *
stream->rate_incr)) *
stream->dst_sample_frame_size;
1599 printf(
"AUDIOSTREAM: flushing with padding to get max %d bytes!\n", flush_remaining);
1617 stream->staging_buffer_filled = 0;
1627 #if DEBUG_AUDIOSTREAM
1628 printf(
"AUDIOSTREAM: want to get %d converted bytes\n",
len);
1635 }
else if (
len <= 0) {
1637 }
else if ((
len %
stream->dst_sample_frame_size) != 0) {
1638 return SDL_SetError(
"Can't request partial sample frames");
1658 if (
stream->reset_resampler_func) {
1662 stream->staging_buffer_filled = 0;
1671 if (
stream->cleanup_resampler_func) {
#define SDL_assert(condition)
#define SDL_AUDIO_ISBIGENDIAN(x)
#define SDL_AUDIOCVT_MAX_FILTERS
Upper limit of filters in SDL_AudioCVT.
void(* SDL_AudioFilter)(struct SDL_AudioCVT *cvt, SDL_AudioFormat format)
Uint16 SDL_AudioFormat
Audio format flags.
#define SDL_AUDIO_ISFLOAT(x)
#define SDL_AUDIO_MASK_ENDIAN
#define SDL_AUDIO_BITSIZE(x)
SDL_AudioFilter SDL_Convert_F32_to_U16
SDL_AudioFilter SDL_Convert_U16_to_F32
SDL_AudioFilter SDL_Convert_F32_to_S32
#define LOG_DEBUG_CONVERT(from, to)
SDL_AudioFilter SDL_Convert_F32_to_S16
SDL_AudioFilter SDL_Convert_F32_to_U8
SDL_AudioFilter SDL_Convert_F32_to_S8
SDL_AudioFilter SDL_Convert_S8_to_F32
void SDL_ChooseAudioConverters(void)
SDL_AudioFilter SDL_Convert_S32_to_F32
SDL_AudioFilter SDL_Convert_S16_to_F32
SDL_AudioFilter SDL_Convert_U8_to_F32
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate, SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
static void SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
static int SDL_ResampleAudio(const int chans, const int inrate, const int outrate, const float *lpadding, const float *rpadding, const float *inbuf, const int inbuflen, float *outbuf, const int outbuflen)
void(* SDL_ResetAudioStreamResamplerFunc)(SDL_AudioStream *stream)
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING
SDL_AudioStream * SDL_NewAudioStream(const SDL_AudioFormat src_format, const Uint8 src_channels, const int src_rate, const SDL_AudioFormat dst_format, const Uint8 dst_channels, const int dst_rate)
static void SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
void SDL_AudioStreamClear(SDL_AudioStream *stream)
int SDL_PrepareResampleFilter(void)
static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
#define RESAMPLER_FUNCS(chans)
static SDL_AudioFilter ChooseCVTResampler(const int dst_channels)
static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
#define DEBUG_AUDIOSTREAM
static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
void SDL_FreeResampleFilter(void)
static void SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static SDL_bool SDL_SupportedChannelCount(const int channels)
static void SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
void(* SDL_CleanupAudioStreamResamplerFunc)(SDL_AudioStream *stream)
static void SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
static void SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static float * ResamplerFilterDifference
static void SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter)
static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream)
static void SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static double bessel(const double x)
static float * ResamplerFilter
static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
static int ResamplerPadding(const int inrate, const int outrate)
int(* SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen)
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
static void SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, const int src_rate, const int dst_rate)
int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
void SDL_FreeAudioStream(SDL_AudioStream *stream)
static void SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static Uint8 * EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
static void SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static SDL_SpinLock ResampleFilterSpinlock
#define RESAMPLER_FILTER_SIZE
size_t SDL_CountDataQueue(SDL_DataQueue *queue)
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
SDL_DataQueue * SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
void SDL_FreeDataQueue(SDL_DataQueue *queue)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_OutOfMemory()
#define SDL_InvalidParamError(param)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLsizei GLenum GLenum const void * table
#define SDL_MAX_SINT32
A signed 32-bit integer type.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int resampler_padding_samples
SDL_ResampleAudioStreamFunc resampler_func
int src_sample_frame_size
Uint8 pre_resample_channels
SDL_AudioCVT cvt_after_resampling
float * resampler_padding
SDL_AudioFormat src_format
SDL_ResetAudioStreamResamplerFunc reset_resampler_func
SDL_AudioFormat dst_format
SDL_AudioCVT cvt_before_resampling
int staging_buffer_filled
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func
int dst_sample_frame_size
A structure to hold a set of audio conversion filters and buffers.
SDL_AudioFormat src_format
SDL_AudioFormat dst_format
SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS+1]