SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_audio.h"
#include "SDL_audio_c.h"
#include "SDL_loadso.h"
#include "SDL_assert.h"
#include "../SDL_dataqueue.h"
#include "SDL_cpuinfo.h"
Go to the source code of this file.
Data Structures | |
struct | SDL_AudioStream |
Macros | |
#define | RESAMPLER_ZERO_CROSSINGS 5 |
#define | RESAMPLER_BITS_PER_SAMPLE 16 |
#define | RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1)) |
#define | RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1) |
#define | CASESWAP(b) |
#define | RESAMPLER_FUNCS(chans) |
Typedefs | |
typedef int(* | SDL_ResampleAudioStreamFunc )(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen) |
typedef void(* | SDL_ResetAudioStreamResamplerFunc )(SDL_AudioStream *stream) |
typedef void(* | SDL_CleanupAudioStreamResamplerFunc )(SDL_AudioStream *stream) |
Variables | |
static SDL_SpinLock | ResampleFilterSpinlock = 0 |
static float * | ResamplerFilter = NULL |
static float * | ResamplerFilterDifference = NULL |
#define CASESWAP | ( | b | ) |
Referenced by SDL_Convert_Byteswap().
#define RESAMPLER_BITS_PER_SAMPLE 16 |
Definition at line 376 of file SDL_audiocvt.c.
#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1) |
Definition at line 378 of file SDL_audiocvt.c.
Referenced by SDL_PrepareResampleFilter(), and SDL_ResampleAudio().
#define RESAMPLER_FUNCS | ( | chans | ) |
Definition at line 739 of file SDL_audiocvt.c.
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1)) |
Definition at line 377 of file SDL_audiocvt.c.
Referenced by kaiser_and_sinc(), ResamplerPadding(), and SDL_ResampleAudio().
#define RESAMPLER_ZERO_CROSSINGS 5 |
Definition at line 375 of file SDL_audiocvt.c.
typedef void(* SDL_CleanupAudioStreamResamplerFunc)(SDL_AudioStream *stream) |
Definition at line 1072 of file SDL_audiocvt.c.
typedef int(* SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen) |
Definition at line 1070 of file SDL_audiocvt.c.
typedef void(* SDL_ResetAudioStreamResamplerFunc)(SDL_AudioStream *stream) |
Definition at line 1071 of file SDL_audiocvt.c.
|
static |
Definition at line 382 of file SDL_audiocvt.c.
References e, i, SDL_pow, and SDL_TRUE.
Referenced by kaiser_and_sinc().
|
static |
Definition at line 752 of file SDL_audiocvt.c.
References NULL.
Referenced by SDL_BuildAudioResampleCVT().
|
static |
Definition at line 1099 of file SDL_audiocvt.c.
References NULL, SDL_OutOfMemory, SDL_realloc, SDL_AudioStream::work_buffer_base, and SDL_AudioStream::work_buffer_len.
Referenced by SDL_AudioStreamPut(), and SDL_ResampleAudioStream().
|
static |
Definition at line 404 of file SDL_audiocvt.c.
References bessel(), i, RESAMPLER_SAMPLES_PER_ZERO_CROSSING, SDL_pow, SDL_sinf, and SDL_sqrt.
Referenced by SDL_PrepareResampleFilter().
|
static |
Definition at line 468 of file SDL_audiocvt.c.
References RESAMPLER_SAMPLES_PER_ZERO_CROSSING, and SDL_ceil.
Referenced by SDL_NewAudioStream(), SDL_ResampleAudio(), SDL_ResampleAudioStream(), SDL_ResampleCVT(), and SDL_ResetAudioStreamResampler().
|
static |
Definition at line 591 of file SDL_audiocvt.c.
References SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, NULL, SDL_AUDIOCVT_MAX_FILTERS, and SDL_SetError.
Referenced by SDL_BuildAudioCVT(), SDL_BuildAudioResampleCVT(), SDL_BuildAudioTypeCVTFromFloat(), and SDL_BuildAudioTypeCVTToFloat().
int SDL_AudioStreamAvailable | ( | SDL_AudioStream * | stream | ) |
Definition at line 1476 of file SDL_audiocvt.c.
References SDL_AudioStream::queue, and SDL_CountDataQueue().
Referenced by SDL_CaptureAudio(), and SDL_RunAudio().
void SDL_AudioStreamClear | ( | SDL_AudioStream * | stream | ) |
Definition at line 1444 of file SDL_audiocvt.c.
References SDL_AudioStream::packetlen, SDL_AudioStream::queue, SDL_AudioStream::reset_resampler_func, SDL_ClearDataQueue(), and SDL_InvalidParamError.
Referenced by SDL_CaptureAudio().
int SDL_AudioStreamGet | ( | SDL_AudioStream * | stream, |
void * | buf, | ||
const Uint32 | len | ||
) |
Definition at line 1459 of file SDL_audiocvt.c.
References SDL_AudioStream::dst_sample_frame_size, SDL_AudioStream::queue, SDL_InvalidParamError, SDL_ReadFromDataQueue(), and SDL_SetError.
Referenced by SDL_CaptureAudio(), and SDL_RunAudio().
int SDL_AudioStreamPut | ( | SDL_AudioStream * | stream, |
const void * | buf, | ||
const Uint32 | _buflen | ||
) |
Definition at line 1366 of file SDL_audiocvt.c.
References SDL_AudioCVT::buf, SDL_AudioStream::cvt_after_resampling, SDL_AudioStream::cvt_before_resampling, SDL_AudioStream::dst_rate, EnsureStreamBufferSize(), SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, SDL_AudioCVT::len_mult, SDL_AudioCVT::needed, NULL, SDL_AudioStream::queue, SDL_AudioStream::rate_incr, SDL_AudioStream::resampler_func, SDL_assert, SDL_ceil, SDL_ConvertAudio(), SDL_InvalidParamError, SDL_memcpy, SDL_SetError, SDL_WriteToDataQueue(), SDL_AudioStream::src_rate, and SDL_AudioStream::src_sample_frame_size.
Referenced by SDL_CaptureAudio(), and SDL_RunAudio().
int SDL_BuildAudioCVT | ( | SDL_AudioCVT * | cvt, |
SDL_AudioFormat | src_format, | ||
Uint8 | src_channels, | ||
int | src_rate, | ||
SDL_AudioFormat | dst_format, | ||
Uint8 | dst_channels, | ||
int | dst_rate | ||
) |
This function takes a source format and rate and a destination format and rate, and initializes the cvt
structure with information needed by SDL_ConvertAudio() to convert a buffer of audio data from one format to the other. An unsupported format causes an error and -1 will be returned.
Definition at line 863 of file SDL_audiocvt.c.
References SDL_AudioCVT::dst_format, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, SDL_AudioCVT::needed, NULL, SDL_AudioCVT::rate_incr, SDL_AddAudioCVTFilter(), SDL_AUDIO_MASK_ENDIAN, SDL_BuildAudioResampleCVT(), SDL_BuildAudioTypeCVTFromFloat(), SDL_BuildAudioTypeCVTToFloat(), SDL_ChooseAudioConverters(), SDL_Convert51To71(), SDL_Convert51ToQuad(), SDL_Convert51ToStereo(), SDL_Convert71To51(), SDL_Convert_Byteswap(), SDL_ConvertMonoToStereo(), SDL_ConvertQuadTo51(), SDL_ConvertQuadToStereo(), SDL_ConvertStereoTo51(), SDL_ConvertStereoToMono(), SDL_ConvertStereoToQuad(), SDL_HasSSE3, SDL_InvalidParamError, SDL_SetError, SDL_SupportedAudioFormat(), SDL_SupportedChannelCount(), SDL_zero, SDL_zerop, and SDL_AudioCVT::src_format.
Referenced by SDL_NewAudioStream().
|
static |
Definition at line 767 of file SDL_audiocvt.c.
References ChooseCVTResampler(), SDL_AudioStream::dst_rate, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, NULL, SDL_AddAudioCVTFilter(), SDL_AUDIOCVT_MAX_FILTERS, SDL_ceil, SDL_PrepareResampleFilter(), SDL_SetError, and SDL_AudioStream::src_rate.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 652 of file SDL_audiocvt.c.
References AUDIO_S16, AUDIO_S32, AUDIO_S8, AUDIO_U16, AUDIO_U8, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, NULL, retval, SDL_AddAudioCVTFilter(), SDL_assert, SDL_AUDIO_BITSIZE, SDL_AUDIO_ISBIGENDIAN, SDL_AUDIO_ISFLOAT, SDL_AUDIO_MASK_ENDIAN, SDL_BYTEORDER, SDL_Convert_Byteswap(), SDL_Convert_F32_to_S16, SDL_Convert_F32_to_S32, SDL_Convert_F32_to_S8, SDL_Convert_F32_to_U16, SDL_Convert_F32_to_U8, SDL_LIL_ENDIAN, and SDL_SetError.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 605 of file SDL_audiocvt.c.
References AUDIO_S16, AUDIO_S32, AUDIO_S8, AUDIO_U16, AUDIO_U8, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, NULL, retval, SDL_AddAudioCVTFilter(), SDL_assert, SDL_AUDIO_BITSIZE, SDL_AUDIO_ISBIGENDIAN, SDL_AUDIO_ISFLOAT, SDL_AUDIO_MASK_ENDIAN, SDL_BYTEORDER, SDL_Convert_Byteswap(), SDL_Convert_S16_to_F32, SDL_Convert_S32_to_F32, SDL_Convert_S8_to_F32, SDL_Convert_U16_to_F32, SDL_Convert_U8_to_F32, SDL_LIL_ENDIAN, and SDL_SetError.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 1268 of file SDL_audiocvt.c.
References SDL_AudioStream::resampler_state, and SDL_free().
Referenced by SDL_NewAudioStream().
|
static |
Definition at line 330 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 176 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 98 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 146 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 553 of file SDL_audiocvt.c.
References CASESWAP, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_assert, SDL_AUDIO_BITSIZE, and SDL_AUDIO_MASK_ENDIAN.
Referenced by SDL_BuildAudioCVT(), SDL_BuildAudioTypeCVTFromFloat(), and SDL_BuildAudioTypeCVTToFloat().
int SDL_ConvertAudio | ( | SDL_AudioCVT * | cvt | ) |
Once you have initialized the cvt
structure using SDL_BuildAudioCVT(), created an audio buffer cvt->buf
, and filled it with cvt->len
bytes of audio data in the source format, this function will convert it in-place to the desired format.
The data conversion may expand the size of the audio data, so the buffer cvt->buf
should be allocated after the cvt
structure is initialized by SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult
bytes long.
cvt->buf
is NULL. Definition at line 530 of file SDL_audiocvt.c.
References SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, NULL, SDL_SetError, and SDL_AudioCVT::src_format.
Referenced by SDL_AudioStreamPut().
|
static |
Definition at line 205 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 263 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 123 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 229 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 76 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 300 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, LOG_DEBUG_CONVERT, and SDL_assert.
Referenced by SDL_BuildAudioCVT().
void SDL_FreeAudioStream | ( | SDL_AudioStream * | stream | ) |
Definition at line 1483 of file SDL_audiocvt.c.
References SDL_AudioStream::cleanup_resampler_func, SDL_AudioStream::queue, SDL_free(), SDL_FreeDataQueue(), and SDL_AudioStream::work_buffer_base.
Referenced by close_audio_device(), and SDL_NewAudioStream().
Definition at line 459 of file SDL_audiocvt.c.
References NULL, and SDL_free().
Referenced by SDL_AudioQuit().
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 | ||
) |
Definition at line 1274 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioStream::cleanup_resampler_func, SDL_AudioStream::cvt_after_resampling, SDL_AudioStream::cvt_before_resampling, SDL_AudioStream::dst_channels, SDL_AudioStream::dst_format, SDL_AudioStream::dst_rate, SDL_AudioStream::dst_sample_frame_size, SDL_AudioCVT::needed, NULL, SDL_AudioStream::packetlen, SDL_AudioStream::pre_resample_channels, SDL_AudioStream::queue, SDL_AudioStream::rate_incr, SDL_AudioStream::resampler_func, SDL_AudioStream::resampler_state, ResamplerPadding(), SDL_AudioStream::reset_resampler_func, retval, SDL_AUDIO_BITSIZE, SDL_BuildAudioCVT(), SDL_calloc(), SDL_CleanupAudioStreamResampler(), SDL_FALSE, SDL_free(), SDL_FreeAudioStream(), SDL_min, SDL_NewDataQueue(), SDL_OutOfMemory, SDL_PrepareResampleFilter(), SDL_ResampleAudioStream(), SDL_ResetAudioStreamResampler(), SDL_AudioStream::src_channels, SDL_AudioStream::src_format, SDL_AudioStream::src_rate, and SDL_AudioStream::src_sample_frame_size.
Referenced by open_audio_device().
int SDL_PrepareResampleFilter | ( | void | ) |
Definition at line 430 of file SDL_audiocvt.c.
References kaiser_and_sinc(), NULL, RESAMPLER_FILTER_SIZE, SDL_AtomicLock, SDL_AtomicUnlock, SDL_free(), SDL_malloc, and SDL_OutOfMemory.
Referenced by SDL_BuildAudioResampleCVT(), and SDL_NewAudioStream().
|
static |
Definition at line 475 of file SDL_audiocvt.c.
References i, j, RESAMPLER_FILTER_SIZE, RESAMPLER_SAMPLES_PER_ZERO_CROSSING, and ResamplerPadding().
Referenced by SDL_ResampleAudioStream(), and SDL_ResampleCVT().
|
static |
Definition at line 1214 of file SDL_audiocvt.c.
References SDL_AudioStream::dst_rate, EnsureStreamBufferSize(), NULL, SDL_AudioStream::pre_resample_channels, SDL_AudioStream::resampler_state, ResamplerPadding(), retval, SDL_memcpy, SDL_memset, SDL_OutOfMemory, SDL_ResampleAudio(), SDL_stack_alloc, SDL_stack_free, and SDL_AudioStream::src_rate.
Referenced by SDL_NewAudioStream().
|
static |
Definition at line 697 of file SDL_audiocvt.c.
References AUDIO_F32SYS, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, SDL_AudioCVT::len_mult, ResamplerPadding(), SDL_assert, SDL_AUDIOCVT_MAX_FILTERS, SDL_memcpy, SDL_memset, SDL_OutOfMemory, SDL_ResampleAudio(), SDL_stack_alloc, and SDL_stack_free.
|
static |
Definition at line 1257 of file SDL_audiocvt.c.
References SDL_AudioStream::dst_rate, SDL_AudioStream::pre_resample_channels, SDL_AudioStream::resampler_state, ResamplerPadding(), SDL_memset, and SDL_AudioStream::src_rate.
Referenced by SDL_NewAudioStream().
|
static |
Definition at line 816 of file SDL_audiocvt.c.
References AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S8, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, SDL_FALSE, and SDL_TRUE.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 839 of file SDL_audiocvt.c.
References SDL_FALSE, and SDL_TRUE.
Referenced by SDL_BuildAudioCVT().
|
static |
Definition at line 425 of file SDL_audiocvt.c.
|
static |
Definition at line 426 of file SDL_audiocvt.c.
|
static |
Definition at line 427 of file SDL_audiocvt.c.