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;
49 const float *
src = dst;
57 if ((((
size_t) dst) & 15) == 0) {
59 const __m128 divby2 = _mm_set1_ps(0.5
f);
61 _mm_store_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(
src), _mm_load_ps(
src+4)), divby2));
62 i -= 4;
src += 8; dst += 4;
68 *dst = (
src[0] +
src[1]) * 0.5
f;
83 float *
dst = (
float *) cvt->
buf;
84 const float *
src = dst;
91 *(dst++) = (
src[0] +
src[1]) * 0.5f;
105 float *
dst = (
float *) cvt->
buf;
106 const float *
src = dst;
113 for (
i = cvt->
len_cvt / (sizeof (
float) * 6);
i; --
i,
src += 6, dst += 2) {
114 const float front_center_distributed = src[2] * 0.5f;
115 dst[0] = (src[0] + front_center_distributed + src[4]) / 2.5
f;
116 dst[1] = (src[1] + front_center_distributed + src[5]) / 2.5
f;
130 float *
dst = (
float *) cvt->
buf;
131 const float *
src = dst;
137 for (
i = cvt->
len_cvt / (sizeof (
float) * 4);
i; --
i,
src += 4, dst += 2) {
138 dst[0] = (src[0] + src[2]) * 0.5
f;
139 dst[1] = (src[1] + src[3]) * 0.5
f;
153 float *
dst = (
float *) cvt->
buf;
154 const float *
src = dst;
160 for (
i = cvt->
len_cvt / (sizeof (
float) * 8);
i; --
i,
src += 8, dst += 6) {
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.5
f;
164 dst[1] = (src[1] + surround_right_distributed) / 1.5
f;
165 dst[2] = src[2] / 1.5f;
166 dst[3] = src[3] / 1.5f;
167 dst[4] = (src[4] + surround_left_distributed) / 1.5
f;
168 dst[5] = (src[5] + surround_right_distributed) / 1.5
f;
183 float *
dst = (
float *) cvt->
buf;
184 const float *
src = dst;
192 for (
i = cvt->
len_cvt / (sizeof (
float) * 6);
i; --
i,
src += 6, dst += 4) {
193 const float front_center_distributed = src[2] * 0.5f;
194 dst[0] = (src[0] + front_center_distributed) / 1.5
f;
195 dst[1] = (src[1] + front_center_distributed) / 1.5
f;
196 dst[2] = src[4] / 1.5f;
197 dst[3] = src[5] / 1.5f;
212 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
219 for (i = cvt->
len_cvt / sizeof (
float);
i; --
i) {
222 dst[0] = dst[1] = *
src;
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.5
f;
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.5
f;
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.5
f;
354 rs = (rf + rb) * 0.5
f;
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.0
e-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++) {
424 diffs[i - 1] = table[
i] - table[i - 1];
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;
510 const int filterindex2 = (int) (interpolation2 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
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;
606 if (filter ==
NULL) {
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) {
792 if (filter ==
NULL) {
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;
1142 offset = ((
size_t) ptr) & 15;
1143 return offset ? ptr + (16 -
offset) : ptr;
1146 #ifdef HAVE_LIBSAMPLERATE_H 1148 SDL_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;
1167 data.src_ratio = stream->rate_incr;
1169 result = SRC_src_process(
state, &data);
1171 SDL_SetError(
"src_process() failed: %s", SRC_src_strerror(result));
1176 SDL_assert(data.input_frames_used == data.input_frames);
1178 return data.output_frames_gen * (
sizeof(float) * stream->pre_resample_channels);
1182 SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream)
1184 SRC_src_reset((SRC_STATE *)stream->resampler_state);
1188 SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream)
1190 SRC_STATE *
state = (SRC_STATE *)stream->resampler_state;
1192 SRC_src_delete(state);
1195 stream->resampler_state =
NULL;
1196 stream->resampler_func =
NULL;
1197 stream->reset_resampler_func =
NULL;
1198 stream->cleanup_resampler_func =
NULL;
1202 SetupLibSampleRateResampling(SDL_AudioStream *stream)
1207 if (SRC_available) {
1208 state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
1210 SDL_SetError(
"src_new() failed: %s", SRC_src_strerror(result));
1215 SDL_CleanupAudioStreamResampler_SRC(stream);
1219 stream->resampler_state =
state;
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));
1247 retval =
SDL_ResampleAudio(chans, inrate, outrate, lpadding, rpadding, inbuf, inbuflen, outbuf, outbuflen);
1250 SDL_memcpy((lpadding + paddingsamples) - (cpy /
sizeof (
float)), inbufend - cpy, cpy);
1258 const int len = stream->resampler_padding_samples;
1259 SDL_memset(stream->resampler_state,
'\0', len * sizeof (
float));
1280 retval = (SDL_AudioStream *)
SDL_calloc(1,
sizeof (SDL_AudioStream));
1289 pre_resample_channels =
SDL_min(src_channels, dst_channels);
1292 retval->src_sample_frame_size = (
SDL_AUDIO_BITSIZE(src_format) / 8) * src_channels;
1296 retval->dst_sample_frame_size = (
SDL_AUDIO_BITSIZE(dst_format) / 8) * dst_channels;
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));
1306 if (retval->resampler_padding ==
NULL) {
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) {
1314 retval->staging_buffer = (
Uint8 *)
SDL_malloc(retval->staging_buffer_size);
1315 if (retval->staging_buffer ==
NULL) {
1323 if (src_rate == dst_rate) {
1324 retval->cvt_before_resampling.needed =
SDL_FALSE;
1325 if (
SDL_BuildAudioCVT(&retval->cvt_after_resampling, src_format, src_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
1332 if (
SDL_BuildAudioCVT(&retval->cvt_before_resampling, src_format, src_channels, src_rate,
AUDIO_F32SYS, pre_resample_channels, src_rate) < 0) {
1337 #ifdef HAVE_LIBSAMPLERATE_H 1338 SetupLibSampleRateResampling(retval);
1341 if (!retval->resampler_func) {
1342 retval->resampler_state =
SDL_calloc(retval->resampler_padding_samples, sizeof (
float));
1343 if (!retval->resampler_state) {
1351 retval->resampler_state =
NULL;
1362 if (
SDL_BuildAudioCVT(&retval->cvt_after_resampling,
AUDIO_F32SYS, pre_resample_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
1369 if (!retval->queue) {
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;
1407 if (stream->dst_rate != stream->src_rate) {
1409 const int framesize = stream->pre_resample_channels *
sizeof (float);
1410 const int frames = workbuflen / framesize;
1411 resamplebuflen = ((int)
SDL_ceil(frames * stream->rate_incr)) * 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;
1436 SDL_memcpy(workbuf + paddingbytes, buf, buflen);
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);
1451 if (stream->dst_rate != stream->src_rate) {
1458 SDL_memcpy(workbuf, stream->resampler_padding, paddingbytes);
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 &&
1532 (stream->dst_rate == stream->src_rate) &&
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) {
1552 SDL_memcpy(stream->staging_buffer + stream->staging_buffer_filled, buf, len);
1553 stream->staging_buffer_filled +=
len;
1558 amount = (stream->staging_buffer_size - stream->staging_buffer_filled);
1560 SDL_memcpy(stream->staging_buffer + stream->staging_buffer_filled, buf, amount);
1561 stream->staging_buffer_filled = 0;
1565 buf = (
void *)((
Uint8 *)buf + amount);
1577 #if DEBUG_AUDIOSTREAM 1578 printf(
"AUDIOSTREAM: flushing! staging_buffer_filled=%d bytes\n", stream->staging_buffer_filled);
1582 SDL_assert((stream->dst_rate != stream->src_rate) || (stream->staging_buffer_filled == 0));
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);
1602 SDL_memset(stream->staging_buffer + filled,
'\0', stream->staging_buffer_size - filled);
1610 SDL_memset(stream->staging_buffer,
'\0', filled);
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) {
1659 stream->reset_resampler_func(stream);
1662 stream->staging_buffer_filled = 0;
1671 if (stream->cleanup_resampler_func) {
1672 stream->cleanup_resampler_func(stream);
1676 SDL_free(stream->work_buffer_base);
1677 SDL_free(stream->resampler_padding);
static SDL_AudioFilter ChooseCVTResampler(const int dst_channels)
static int ResamplerPadding(const int inrate, const int outrate)
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING
#define LOG_DEBUG_CONVERT(from, to)
int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
void SDL_FreeResampleFilter(void)
void(* SDL_CleanupAudioStreamResamplerFunc)(SDL_AudioStream *stream)
#define SDL_AUDIOCVT_MAX_FILTERS
Upper limit of filters in SDL_AudioCVT.
static void SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
GLenum GLsizei GLenum GLenum const void * table
SDL_AudioFormat src_format
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 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
#define SDL_AUDIO_ISBIGENDIAN(x)
GLint GLint GLint GLint GLint x
void SDL_ChooseAudioConverters(void)
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
SDL_AudioFilter SDL_Convert_F32_to_S32
SDL_AudioFormat dst_format
static void SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
SDL_AudioFilter SDL_Convert_S16_to_F32
SDL_AudioFilter SDL_Convert_U16_to_F32
SDL_DataQueue * SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
static void SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
SDL_AudioCVT cvt_after_resampling
Uint16 SDL_AudioFormat
Audio format flags.
static SDL_SpinLock ResampleFilterSpinlock
static float * ResamplerFilter
void SDL_FreeAudioStream(SDL_AudioStream *stream)
static void SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
#define SDL_MAX_SINT32
A signed 32-bit integer type.
#define SDL_AUDIO_MASK_ENDIAN
#define SDL_InvalidParamError(param)
static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
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)
static void SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
static Uint8 * EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
static float * ResamplerFilterDifference
A structure to hold a set of audio conversion filters and buffers.
static double bessel(const double x)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_AUDIO_ISFLOAT(x)
static void SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream)
static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, const int src_rate, const int dst_rate)
int resampler_padding_samples
int SDL_PrepareResampleFilter(void)
SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS+1]
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
#define SDL_AUDIO_BITSIZE(x)
void(* SDL_ResetAudioStreamResamplerFunc)(SDL_AudioStream *stream)
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)
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
SDL_AudioFilter SDL_Convert_F32_to_S8
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
static void SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
int src_sample_frame_size
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)
#define RESAMPLER_FUNCS(chans)
SDL_AudioFormat src_format
GLenum GLuint GLenum GLsizei const GLchar * buf
static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
#define RESAMPLER_FILTER_SIZE
int dst_sample_frame_size
SDL_AudioFilter SDL_Convert_F32_to_U8
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
void(* SDL_AudioFilter)(struct SDL_AudioCVT *cvt, SDL_AudioFormat format)
SDL_AudioFilter SDL_Convert_S8_to_F32
SDL_ResetAudioStreamResamplerFunc reset_resampler_func
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_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
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)
#define SDL_assert(condition)
SDL_AudioFilter SDL_Convert_U8_to_F32
Uint8 pre_resample_channels
#define SDL_OutOfMemory()
static SDL_bool SDL_SupportedChannelCount(const int channels)
SDL_ResampleAudioStreamFunc resampler_func
void SDL_AudioStreamClear(SDL_AudioStream *stream)
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
SDL_AudioFormat dst_format
SDL_AudioFilter SDL_Convert_F32_to_U16
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func
SDL_AudioCVT cvt_before_resampling
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
static void SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
size_t SDL_CountDataQueue(SDL_DataQueue *queue)
static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter)
float * resampler_padding
static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
static void SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
void SDL_FreeDataQueue(SDL_DataQueue *queue)
SDL_AudioFilter SDL_Convert_S32_to_F32
SDL_AudioFilter SDL_Convert_F32_to_S16
int staging_buffer_filled
static void SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
#define DEBUG_AUDIOSTREAM
int(* SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen)