SDL 2.0
SDL_audio_c.h File Reference
#include "../SDL_internal.h"
+ Include dependency graph for SDL_audio_c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEBUG_CONVERT   0
 
#define LOG_DEBUG_CONVERT(from, to)
 

Functions

SDL_AudioFormat SDL_FirstAudioFormat (SDL_AudioFormat format)
 
SDL_AudioFormat SDL_NextAudioFormat (void)
 
void SDL_CalculateAudioSpec (SDL_AudioSpec *spec)
 
void SDL_ChooseAudioConverters (void)
 
int SDL_PrepareResampleFilter (void)
 
void SDL_FreeResampleFilter (void)
 

Variables

SDL_AudioFilter SDL_Convert_S8_to_F32
 
SDL_AudioFilter SDL_Convert_U8_to_F32
 
SDL_AudioFilter SDL_Convert_S16_to_F32
 
SDL_AudioFilter SDL_Convert_U16_to_F32
 
SDL_AudioFilter SDL_Convert_S32_to_F32
 
SDL_AudioFilter SDL_Convert_F32_to_S8
 
SDL_AudioFilter SDL_Convert_F32_to_U8
 
SDL_AudioFilter SDL_Convert_F32_to_S16
 
SDL_AudioFilter SDL_Convert_F32_to_U16
 
SDL_AudioFilter SDL_Convert_F32_to_S32
 

Macro Definition Documentation

◆ DEBUG_CONVERT

#define DEBUG_CONVERT   0

Definition at line 28 of file SDL_audio_c.h.

◆ LOG_DEBUG_CONVERT

#define LOG_DEBUG_CONVERT (   from,
  to 
)

Definition at line 34 of file SDL_audio_c.h.

Function Documentation

◆ SDL_CalculateAudioSpec()

void SDL_CalculateAudioSpec ( SDL_AudioSpec spec)

Definition at line 1668 of file SDL_audio.c.

1669{
1670 switch (spec->format) {
1671 case AUDIO_U8:
1672 spec->silence = 0x80;
1673 break;
1674 default:
1675 spec->silence = 0x00;
1676 break;
1677 }
1679 spec->size *= spec->channels;
1680 spec->size *= spec->samples;
1681}
#define AUDIO_U8
Definition: SDL_audio.h:89
#define SDL_AUDIO_BITSIZE(x)
Definition: SDL_audio.h:75
SDL_AudioSpec spec
Definition: loopwave.c:31
Uint32 size
Definition: SDL_audio.h:186
Uint16 samples
Definition: SDL_audio.h:184
Uint8 channels
Definition: SDL_audio.h:182
Uint8 silence
Definition: SDL_audio.h:183
SDL_AudioFormat format
Definition: SDL_audio.h:181

References AUDIO_U8, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::samples, SDL_AUDIO_BITSIZE, SDL_AudioSpec::silence, SDL_AudioSpec::size, and spec.

Referenced by open_audio_device(), and prepare_audiospec().

◆ SDL_ChooseAudioConverters()

void SDL_ChooseAudioConverters ( void  )

Definition at line 1386 of file SDL_audiotypecvt.c.

1387{
1388 static SDL_bool converters_chosen = SDL_FALSE;
1389
1390 if (converters_chosen) {
1391 return;
1392 }
1393
1394#define SET_CONVERTER_FUNCS(fntype) \
1395 SDL_Convert_S8_to_F32 = SDL_Convert_S8_to_F32_##fntype; \
1396 SDL_Convert_U8_to_F32 = SDL_Convert_U8_to_F32_##fntype; \
1397 SDL_Convert_S16_to_F32 = SDL_Convert_S16_to_F32_##fntype; \
1398 SDL_Convert_U16_to_F32 = SDL_Convert_U16_to_F32_##fntype; \
1399 SDL_Convert_S32_to_F32 = SDL_Convert_S32_to_F32_##fntype; \
1400 SDL_Convert_F32_to_S8 = SDL_Convert_F32_to_S8_##fntype; \
1401 SDL_Convert_F32_to_U8 = SDL_Convert_F32_to_U8_##fntype; \
1402 SDL_Convert_F32_to_S16 = SDL_Convert_F32_to_S16_##fntype; \
1403 SDL_Convert_F32_to_U16 = SDL_Convert_F32_to_U16_##fntype; \
1404 SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \
1405 converters_chosen = SDL_TRUE
1406
1407#if HAVE_SSE2_INTRINSICS
1408 if (SDL_HasSSE2()) {
1409 SET_CONVERTER_FUNCS(SSE2);
1410 return;
1411 }
1412#endif
1413
1414#if HAVE_NEON_INTRINSICS
1415 if (SDL_HasNEON()) {
1416 SET_CONVERTER_FUNCS(NEON);
1417 return;
1418 }
1419#endif
1420
1421#if NEED_SCALAR_CONVERTER_FALLBACKS
1422 SET_CONVERTER_FUNCS(Scalar);
1423#endif
1424
1425#undef SET_CONVERTER_FUNCS
1426
1427 SDL_assert(converters_chosen == SDL_TRUE);
1428}
#define SDL_assert(condition)
Definition: SDL_assert.h:169
#define SET_CONVERTER_FUNCS(fntype)
#define SDL_HasNEON
#define SDL_HasSSE2
SDL_bool
Definition: SDL_stdinc.h:162
@ SDL_TRUE
Definition: SDL_stdinc.h:164
@ SDL_FALSE
Definition: SDL_stdinc.h:163

References SDL_assert, SDL_FALSE, SDL_HasNEON, SDL_HasSSE2, SDL_TRUE, and SET_CONVERTER_FUNCS.

Referenced by SDL_BuildAudioCVT().

◆ SDL_FirstAudioFormat()

SDL_AudioFormat SDL_FirstAudioFormat ( SDL_AudioFormat  format)

Definition at line 1647 of file SDL_audio.c.

1648{
1650 if (format_list[format_idx][0] == format) {
1651 break;
1652 }
1653 }
1654 format_idx_sub = 0;
1655 return SDL_NextAudioFormat();
1656}
static int format_idx_sub
Definition: SDL_audio.c:1622
static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS]
Definition: SDL_audio.c:1623
#define NUM_FORMATS
Definition: SDL_audio.c:1620
static int format_idx
Definition: SDL_audio.c:1621
SDL_AudioFormat SDL_NextAudioFormat(void)
Definition: SDL_audio.c:1659
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572

References format_idx, format_idx_sub, format_list, NUM_FORMATS, and SDL_NextAudioFormat().

◆ SDL_FreeResampleFilter()

void SDL_FreeResampleFilter ( void  )

Definition at line 464 of file SDL_audiocvt.c.

465{
470}
static float * ResamplerFilterDifference
Definition: SDL_audiocvt.c:432
static float * ResamplerFilter
Definition: SDL_audiocvt.c:431
#define SDL_free
#define NULL
Definition: begin_code.h:167

References NULL, ResamplerFilter, ResamplerFilterDifference, and SDL_free.

Referenced by SDL_AudioQuit().

◆ SDL_NextAudioFormat()

SDL_AudioFormat SDL_NextAudioFormat ( void  )

Definition at line 1659 of file SDL_audio.c.

1660{
1662 return 0;
1663 }
1665}

References format_idx, format_idx_sub, format_list, and NUM_FORMATS.

Referenced by SDL_FirstAudioFormat().

◆ SDL_PrepareResampleFilter()

int SDL_PrepareResampleFilter ( void  )

Definition at line 435 of file SDL_audiocvt.c.

436{
438 if (!ResamplerFilter) {
439 /* if dB > 50, beta=(0.1102 * (dB - 8.7)), according to Matlab. */
440 const double dB = 80.0;
441 const double beta = 0.1102 * (dB - 8.7);
442 const size_t alloclen = RESAMPLER_FILTER_SIZE * sizeof (float);
443
444 ResamplerFilter = (float *) SDL_malloc(alloclen);
445 if (!ResamplerFilter) {
447 return SDL_OutOfMemory();
448 }
449
450 ResamplerFilterDifference = (float *) SDL_malloc(alloclen);
455 return SDL_OutOfMemory();
456 }
458 }
460 return 0;
461}
static void kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
Definition: SDL_audiocvt.c:409
static SDL_SpinLock ResampleFilterSpinlock
Definition: SDL_audiocvt.c:430
#define RESAMPLER_FILTER_SIZE
Definition: SDL_audiocvt.c:383
#define SDL_AtomicLock
#define SDL_malloc
#define SDL_AtomicUnlock
#define SDL_OutOfMemory()
Definition: SDL_error.h:52

References kaiser_and_sinc(), NULL, ResampleFilterSpinlock, RESAMPLER_FILTER_SIZE, ResamplerFilter, ResamplerFilterDifference, SDL_AtomicLock, SDL_AtomicUnlock, SDL_free, SDL_malloc, and SDL_OutOfMemory.

Referenced by SDL_BuildAudioResampleCVT(), and SDL_NewAudioStream().

Variable Documentation

◆ SDL_Convert_F32_to_S16

SDL_AudioFilter SDL_Convert_F32_to_S16
extern

Definition at line 59 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTFromFloat().

◆ SDL_Convert_F32_to_S32

SDL_AudioFilter SDL_Convert_F32_to_S32
extern

Definition at line 61 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTFromFloat().

◆ SDL_Convert_F32_to_S8

SDL_AudioFilter SDL_Convert_F32_to_S8
extern

Definition at line 57 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTFromFloat().

◆ SDL_Convert_F32_to_U16

SDL_AudioFilter SDL_Convert_F32_to_U16
extern

Definition at line 60 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTFromFloat().

◆ SDL_Convert_F32_to_U8

SDL_AudioFilter SDL_Convert_F32_to_U8
extern

Definition at line 58 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTFromFloat().

◆ SDL_Convert_S16_to_F32

SDL_AudioFilter SDL_Convert_S16_to_F32
extern

Definition at line 54 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().

◆ SDL_Convert_S32_to_F32

SDL_AudioFilter SDL_Convert_S32_to_F32
extern

Definition at line 56 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().

◆ SDL_Convert_S8_to_F32

SDL_AudioFilter SDL_Convert_S8_to_F32
extern

Definition at line 52 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().

◆ SDL_Convert_U16_to_F32

SDL_AudioFilter SDL_Convert_U16_to_F32
extern

Definition at line 55 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().

◆ SDL_Convert_U8_to_F32

SDL_AudioFilter SDL_Convert_U8_to_F32
extern

Definition at line 53 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().