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 1660 of file SDL_audio.c.

1661 {
1662  switch (spec->format) {
1663  case AUDIO_U8:
1664  spec->silence = 0x80;
1665  break;
1666  default:
1667  spec->silence = 0x00;
1668  break;
1669  }
1671  spec->size *= spec->channels;
1672  spec->size *= spec->samples;
1673 }

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 1387 of file SDL_audiotypecvt.c.

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

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 1639 of file SDL_audio.c.

1640 {
1641  for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
1642  if (format_list[format_idx][0] == format) {
1643  break;
1644  }
1645  }
1646  format_idx_sub = 0;
1647  return SDL_NextAudioFormat();
1648 }

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.

References NULL, ResamplerFilter, ResamplerFilterDifference, and SDL_free.

Referenced by SDL_AudioQuit().

◆ SDL_NextAudioFormat()

SDL_AudioFormat SDL_NextAudioFormat ( void  )

Definition at line 1651 of file SDL_audio.c.

1652 {
1653  if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
1654  return 0;
1655  }
1657 }

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 }

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 60 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 62 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 58 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 61 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 59 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 55 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 57 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 53 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 56 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 54 of file SDL_audiotypecvt.c.

Referenced by SDL_BuildAudioTypeCVTToFloat().

format_idx
static int format_idx
Definition: SDL_audio.c:1613
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
SDL_AudioSpec::channels
Uint8 channels
Definition: SDL_audio.h:182
format_idx_sub
static int format_idx_sub
Definition: SDL_audio.c:1614
ResamplerFilter
static float * ResamplerFilter
Definition: SDL_audiocvt.c:431
RESAMPLER_FILTER_SIZE
#define RESAMPLER_FILTER_SIZE
Definition: SDL_audiocvt.c:383
NULL
#define NULL
Definition: begin_code.h:164
SDL_AudioSpec::samples
Uint16 samples
Definition: SDL_audio.h:184
ResamplerFilterDifference
static float * ResamplerFilterDifference
Definition: SDL_audiocvt.c:432
SDL_AudioSpec::format
SDL_AudioFormat format
Definition: SDL_audio.h:181
SDL_AtomicLock
#define SDL_AtomicLock
Definition: SDL_dynapi_overrides.h:64
format_list
static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS]
Definition: SDL_audio.c:1615
SDL_NextAudioFormat
SDL_AudioFormat SDL_NextAudioFormat(void)
Definition: SDL_audio.c:1651
SET_CONVERTER_FUNCS
#define SET_CONVERTER_FUNCS(fntype)
AUDIO_U8
#define AUDIO_U8
Definition: SDL_audio.h:89
SDL_AtomicUnlock
#define SDL_AtomicUnlock
Definition: SDL_dynapi_overrides.h:65
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
NUM_FORMATS
#define NUM_FORMATS
Definition: SDL_audio.c:1612
kaiser_and_sinc
static void kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
Definition: SDL_audiocvt.c:409
SDL_AUDIO_BITSIZE
#define SDL_AUDIO_BITSIZE(x)
Definition: SDL_audio.h:75
SDL_HasNEON
#define SDL_HasNEON
Definition: SDL_dynapi_overrides.h:618
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_AudioSpec::silence
Uint8 silence
Definition: SDL_audio.h:183
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
spec
SDL_AudioSpec spec
Definition: loopwave.c:31
SDL_AudioSpec::size
Uint32 size
Definition: SDL_audio.h:186
SDL_HasSSE2
#define SDL_HasSSE2
Definition: SDL_dynapi_overrides.h:108
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
ResampleFilterSpinlock
static SDL_SpinLock ResampleFilterSpinlock
Definition: SDL_audiocvt.c:430