audio_format: renamed sampleRate to sample_rate
The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
This commit is contained in:
parent
6101dc6c76
commit
de2cb3f375
10
src/audio.c
10
src/audio.c
@ -137,16 +137,16 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
|
|||||||
|
|
||||||
memset(audioFormat, 0, sizeof(*audioFormat));
|
memset(audioFormat, 0, sizeof(*audioFormat));
|
||||||
|
|
||||||
audioFormat->sampleRate = strtol(conf, &test, 10);
|
audioFormat->sample_rate = strtol(conf, &test, 10);
|
||||||
|
|
||||||
if (*test != ':') {
|
if (*test != ':') {
|
||||||
ERROR("error parsing audio output format: %s\n", conf);
|
ERROR("error parsing audio output format: %s\n", conf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audioFormat->sampleRate <= 0) {
|
if (audioFormat->sample_rate <= 0) {
|
||||||
ERROR("sample rate %i is not >= 0\n",
|
ERROR("sample rate %u is not >= 0\n",
|
||||||
(int)audioFormat->sampleRate);
|
audioFormat->sample_rate);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ static int flushAudioBuffer(void)
|
|||||||
|
|
||||||
static size_t audio_buffer_size(const struct audio_format *af)
|
static size_t audio_buffer_size(const struct audio_format *af)
|
||||||
{
|
{
|
||||||
return (af->bits >> 3) * af->channels * (af->sampleRate >> 5);
|
return (af->bits >> 3) * af->channels * (af->sample_rate >> 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_buffer_resize(size_t size)
|
static void audio_buffer_resize(size_t size)
|
||||||
|
@ -142,7 +142,7 @@ static int alsa_openDevice(void *data, struct audio_format *audioFormat)
|
|||||||
snd_pcm_format_t bitformat;
|
snd_pcm_format_t bitformat;
|
||||||
snd_pcm_hw_params_t *hwparams;
|
snd_pcm_hw_params_t *hwparams;
|
||||||
snd_pcm_sw_params_t *swparams;
|
snd_pcm_sw_params_t *swparams;
|
||||||
unsigned int sampleRate = audioFormat->sampleRate;
|
unsigned int sample_rate = audioFormat->sample_rate;
|
||||||
unsigned int channels = audioFormat->channels;
|
unsigned int channels = audioFormat->channels;
|
||||||
snd_pcm_uframes_t alsa_buffer_size;
|
snd_pcm_uframes_t alsa_buffer_size;
|
||||||
snd_pcm_uframes_t alsa_period_size;
|
snd_pcm_uframes_t alsa_period_size;
|
||||||
@ -217,13 +217,13 @@ configure_hw:
|
|||||||
audioFormat->channels = (int8_t)channels;
|
audioFormat->channels = (int8_t)channels;
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_rate_near(ad->pcmHandle, hwparams,
|
err = snd_pcm_hw_params_set_rate_near(ad->pcmHandle, hwparams,
|
||||||
&sampleRate, NULL);
|
&sample_rate, NULL);
|
||||||
if (err < 0 || sampleRate == 0) {
|
if (err < 0 || sample_rate == 0) {
|
||||||
ERROR("ALSA device \"%s\" does not support %i Hz audio\n",
|
ERROR("ALSA device \"%s\" does not support %u Hz audio\n",
|
||||||
ad->device, (int)audioFormat->sampleRate);
|
ad->device, audioFormat->sample_rate);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
audioFormat->sampleRate = sampleRate;
|
audioFormat->sample_rate = sample_rate;
|
||||||
|
|
||||||
buffer_time = ad->buffer_time;
|
buffer_time = ad->buffer_time;
|
||||||
cmd = "snd_pcm_hw_params_set_buffer_time_near";
|
cmd = "snd_pcm_hw_params_set_buffer_time_near";
|
||||||
@ -291,8 +291,8 @@ configure_hw:
|
|||||||
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
|
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
|
||||||
|
|
||||||
DEBUG("ALSA device \"%s\" will be playing %i bit, %u channel audio at "
|
DEBUG("ALSA device \"%s\" will be playing %i bit, %u channel audio at "
|
||||||
"%i Hz\n", ad->device, audioFormat->bits,
|
"%u Hz\n", ad->device, audioFormat->bits,
|
||||||
channels, sampleRate);
|
channels, sample_rate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ static int audioOutputAo_openDevice(void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
format.bits = audio_format->bits;
|
format.bits = audio_format->bits;
|
||||||
format.rate = audio_format->sampleRate;
|
format.rate = audio_format->sample_rate;
|
||||||
format.byte_format = AO_FMT_NATIVE;
|
format.byte_format = AO_FMT_NATIVE;
|
||||||
format.channels = audio_format->channels;
|
format.channels = audio_format->channels;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ static int srate(mpd_unused jack_nframes_t rate, void *data)
|
|||||||
JackData *jd = (JackData *)data;
|
JackData *jd = (JackData *)data;
|
||||||
struct audio_format *audioFormat = jd->audio_format;
|
struct audio_format *audioFormat = jd->audio_format;
|
||||||
|
|
||||||
audioFormat->sampleRate = (int)jack_get_sample_rate(jd->client);
|
audioFormat->sample_rate = (int)jack_get_sample_rate(jd->client);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -188,13 +188,13 @@ static void shutdown_callback(void *arg)
|
|||||||
|
|
||||||
static void set_audioformat(JackData *jd, struct audio_format *audioFormat)
|
static void set_audioformat(JackData *jd, struct audio_format *audioFormat)
|
||||||
{
|
{
|
||||||
audioFormat->sampleRate = (int) jack_get_sample_rate(jd->client);
|
audioFormat->sample_rate = jack_get_sample_rate(jd->client);
|
||||||
DEBUG("samplerate = %d\n", audioFormat->sampleRate);
|
DEBUG("samplerate = %u\n", audioFormat->sample_rate);
|
||||||
audioFormat->channels = 2;
|
audioFormat->channels = 2;
|
||||||
audioFormat->bits = 16;
|
audioFormat->bits = 16;
|
||||||
jd->bps = audioFormat->channels
|
jd->bps = audioFormat->channels
|
||||||
* sizeof(jack_default_audio_sample_t)
|
* sizeof(jack_default_audio_sample_t)
|
||||||
* audioFormat->sampleRate;
|
* audioFormat->sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(const char *msg)
|
static void error_callback(const char *msg)
|
||||||
|
@ -202,11 +202,11 @@ static int mvp_openDevice(struct audio_output *audioOutput,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 0,
|
mvp_setPcmParams(md, audioFormat->sample_rate, audioFormat->channels,
|
||||||
audioFormat->bits);
|
0, audioFormat->bits);
|
||||||
#else
|
#else
|
||||||
mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 1,
|
mvp_setPcmParams(md, audioFormat->sample_rate, audioFormat->channels,
|
||||||
audioFormat->bits);
|
1, audioFormat->bits);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -487,14 +487,14 @@ static int oss_openDevice(void *data,
|
|||||||
OssData *od = data;
|
OssData *od = data;
|
||||||
|
|
||||||
od->channels = (int8_t)audioFormat->channels;
|
od->channels = (int8_t)audioFormat->channels;
|
||||||
od->sampleRate = audioFormat->sampleRate;
|
od->sampleRate = audioFormat->sample_rate;
|
||||||
od->bits = (int8_t)audioFormat->bits;
|
od->bits = (int8_t)audioFormat->bits;
|
||||||
|
|
||||||
if ((ret = oss_open(od)) < 0)
|
if ((ret = oss_open(od)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
audioFormat->channels = od->channels;
|
audioFormat->channels = od->channels;
|
||||||
audioFormat->sampleRate = od->sampleRate;
|
audioFormat->sample_rate = od->sampleRate;
|
||||||
audioFormat->bits = od->bits;
|
audioFormat->bits = od->bits;
|
||||||
|
|
||||||
DEBUG("oss device \"%s\" will be playing %i bit %i channel audio at "
|
DEBUG("oss device \"%s\" will be playing %i bit %i channel audio at "
|
||||||
|
@ -259,7 +259,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamDesc.mSampleRate = audioFormat->sampleRate;
|
streamDesc.mSampleRate = audioFormat->sample_rate;
|
||||||
streamDesc.mFormatID = kAudioFormatLinearPCM;
|
streamDesc.mFormatID = kAudioFormatLinearPCM;
|
||||||
streamDesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
|
streamDesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
@ -283,7 +283,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create a buffer of 1s */
|
/* create a buffer of 1s */
|
||||||
od->bufferSize = (audioFormat->sampleRate) *
|
od->bufferSize = (audioFormat->sample_rate) *
|
||||||
(audioFormat->bits >> 3) * (audioFormat->channels);
|
(audioFormat->bits >> 3) * (audioFormat->channels);
|
||||||
od->buffer = xrealloc(od->buffer, od->bufferSize);
|
od->buffer = xrealloc(od->buffer, od->bufferSize);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ static int pulse_openDevice(void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ss.format = PA_SAMPLE_S16NE;
|
ss.format = PA_SAMPLE_S16NE;
|
||||||
ss.rate = audioFormat->sampleRate;
|
ss.rate = audioFormat->sample_rate;
|
||||||
ss.channels = audioFormat->channels;
|
ss.channels = audioFormat->channels;
|
||||||
|
|
||||||
pd->s = pa_simple_new(pd->server, MPD_PULSE_NAME, PA_STREAM_PLAYBACK,
|
pd->s = pa_simple_new(pd->server, MPD_PULSE_NAME, PA_STREAM_PLAYBACK,
|
||||||
@ -159,7 +159,7 @@ static int pulse_openDevice(void *data,
|
|||||||
"channel audio at %i Hz\n",
|
"channel audio at %i Hz\n",
|
||||||
audio_output_get_name(pd->ao),
|
audio_output_get_name(pd->ao),
|
||||||
audioFormat->bits,
|
audioFormat->bits,
|
||||||
audioFormat->channels, audioFormat->sampleRate);
|
audioFormat->channels, audioFormat->sample_rate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
|
|||||||
snprintf(temp, sizeof(temp), "%u", sd->audio_format.channels);
|
snprintf(temp, sizeof(temp), "%u", sd->audio_format.channels);
|
||||||
shout_set_audio_info(sd->shout_conn, SHOUT_AI_CHANNELS, temp);
|
shout_set_audio_info(sd->shout_conn, SHOUT_AI_CHANNELS, temp);
|
||||||
|
|
||||||
snprintf(temp, sizeof(temp), "%d", sd->audio_format.sampleRate);
|
snprintf(temp, sizeof(temp), "%u", sd->audio_format.sample_rate);
|
||||||
|
|
||||||
shout_set_audio_info(sd->shout_conn, SHOUT_AI_SAMPLERATE, temp);
|
shout_set_audio_info(sd->shout_conn, SHOUT_AI_SAMPLERATE, temp);
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ static int shout_mp3_encoder_init_encoder(struct shout_data *sd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 != lame_set_in_samplerate(ld->gfp,
|
if (0 != lame_set_in_samplerate(ld->gfp,
|
||||||
sd->audio_format.sampleRate)) {
|
sd->audio_format.sample_rate)) {
|
||||||
ERROR("error setting lame sample rate\n");
|
ERROR("error setting lame sample rate\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ static int reinit_encoder(struct shout_data *sd)
|
|||||||
if (sd->quality >= -1.0) {
|
if (sd->quality >= -1.0) {
|
||||||
if (0 != vorbis_encode_init_vbr(&od->vi,
|
if (0 != vorbis_encode_init_vbr(&od->vi,
|
||||||
sd->audio_format.channels,
|
sd->audio_format.channels,
|
||||||
sd->audio_format.sampleRate,
|
sd->audio_format.sample_rate,
|
||||||
sd->quality * 0.1)) {
|
sd->quality * 0.1)) {
|
||||||
ERROR("error initializing vorbis vbr\n");
|
ERROR("error initializing vorbis vbr\n");
|
||||||
vorbis_info_clear(&od->vi);
|
vorbis_info_clear(&od->vi);
|
||||||
@ -196,7 +196,7 @@ static int reinit_encoder(struct shout_data *sd)
|
|||||||
} else {
|
} else {
|
||||||
if (0 != vorbis_encode_init(&od->vi,
|
if (0 != vorbis_encode_init(&od->vi,
|
||||||
sd->audio_format.channels,
|
sd->audio_format.channels,
|
||||||
sd->audio_format.sampleRate, -1.0,
|
sd->audio_format.sample_rate, -1.0,
|
||||||
sd->bitrate * 1000, -1.0)) {
|
sd->bitrate * 1000, -1.0)) {
|
||||||
ERROR("error initializing vorbis encoder\n");
|
ERROR("error initializing vorbis encoder\n");
|
||||||
vorbis_info_clear(&od->vi);
|
vorbis_info_clear(&od->vi);
|
||||||
|
@ -23,27 +23,27 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct audio_format {
|
struct audio_format {
|
||||||
uint32_t sampleRate;
|
uint32_t sample_rate;
|
||||||
uint8_t bits;
|
uint8_t bits;
|
||||||
uint8_t channels;
|
uint8_t channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void audio_format_clear(struct audio_format *af)
|
static inline void audio_format_clear(struct audio_format *af)
|
||||||
{
|
{
|
||||||
af->sampleRate = 0;
|
af->sample_rate = 0;
|
||||||
af->bits = 0;
|
af->bits = 0;
|
||||||
af->channels = 0;
|
af->channels = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool audio_format_defined(const struct audio_format *af)
|
static inline bool audio_format_defined(const struct audio_format *af)
|
||||||
{
|
{
|
||||||
return af->sampleRate != 0;
|
return af->sample_rate != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool audio_format_equals(const struct audio_format *a,
|
static inline bool audio_format_equals(const struct audio_format *a,
|
||||||
const struct audio_format *b)
|
const struct audio_format *b)
|
||||||
{
|
{
|
||||||
return a->sampleRate == b->sampleRate &&
|
return a->sample_rate == b->sample_rate &&
|
||||||
a->bits == b->bits &&
|
a->bits == b->bits &&
|
||||||
a->channels == b->channels;
|
a->channels == b->channels;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af)
|
|||||||
|
|
||||||
static inline double audio_format_time_to_size(const struct audio_format *af)
|
static inline double audio_format_time_to_size(const struct audio_format *af)
|
||||||
{
|
{
|
||||||
return af->sampleRate * af->channels * audio_format_sample_size(af);
|
return af->sample_rate * af->channels * audio_format_sample_size(af);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double audioFormatSizeToTime(const struct audio_format *af)
|
static inline double audioFormatSizeToTime(const struct audio_format *af)
|
||||||
|
@ -37,7 +37,7 @@ unsigned cross_fade_calc(float duration, float total_time,
|
|||||||
assert(duration > 0);
|
assert(duration > 0);
|
||||||
assert(af->bits > 0);
|
assert(af->bits > 0);
|
||||||
assert(af->channels > 0);
|
assert(af->channels > 0);
|
||||||
assert(af->sampleRate > 0);
|
assert(af->sample_rate > 0);
|
||||||
|
|
||||||
chunks = audio_format_time_to_size(af) / CHUNK_SIZE;
|
chunks = audio_format_time_to_size(af) / CHUNK_SIZE;
|
||||||
chunks = (chunks * duration + 0.5);
|
chunks = (chunks * duration + 0.5);
|
||||||
|
@ -162,7 +162,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
|||||||
switch (block->type) {
|
switch (block->type) {
|
||||||
case FLAC__METADATA_TYPE_STREAMINFO:
|
case FLAC__METADATA_TYPE_STREAMINFO:
|
||||||
data->audio_format.bits = (int8_t)si->bits_per_sample;
|
data->audio_format.bits = (int8_t)si->bits_per_sample;
|
||||||
data->audio_format.sampleRate = si->sample_rate;
|
data->audio_format.sample_rate = si->sample_rate;
|
||||||
data->audio_format.channels = (int8_t)si->channels;
|
data->audio_format.channels = (int8_t)si->channels;
|
||||||
data->total_time = ((float)si->total_samples) / (si->sample_rate);
|
data->total_time = ((float)si->total_samples) / (si->sample_rate);
|
||||||
break;
|
break;
|
||||||
|
@ -148,7 +148,7 @@ static size_t adts_find_frame(AacBuffer * b)
|
|||||||
static void adtsParse(AacBuffer * b, float *length)
|
static void adtsParse(AacBuffer * b, float *length)
|
||||||
{
|
{
|
||||||
unsigned int frames, frameLength;
|
unsigned int frames, frameLength;
|
||||||
int sampleRate = 0;
|
int sample_rate = 0;
|
||||||
float framesPerSec;
|
float framesPerSec;
|
||||||
|
|
||||||
/* Read all frames to ensure correct time and bitrate */
|
/* Read all frames to ensure correct time and bitrate */
|
||||||
@ -158,9 +158,9 @@ static void adtsParse(AacBuffer * b, float *length)
|
|||||||
frameLength = adts_find_frame(b);
|
frameLength = adts_find_frame(b);
|
||||||
if (frameLength > 0) {
|
if (frameLength > 0) {
|
||||||
if (frames == 0) {
|
if (frames == 0) {
|
||||||
sampleRate = adtsSampleRates[(b->
|
sample_rate = adtsSampleRates[(b->
|
||||||
buffer[2] & 0x3c)
|
buffer[2] & 0x3c)
|
||||||
>> 2];
|
>> 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameLength > b->bytesIntoBuffer)
|
if (frameLength > b->bytesIntoBuffer)
|
||||||
@ -171,7 +171,7 @@ static void adtsParse(AacBuffer * b, float *length)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
framesPerSec = (float)sampleRate / 1024.0;
|
framesPerSec = (float)sample_rate / 1024.0;
|
||||||
if (framesPerSec != 0)
|
if (framesPerSec != 0)
|
||||||
*length = (float)frames / framesPerSec;
|
*length = (float)frames / framesPerSec;
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ static float getAacFloatTotalTime(char *file)
|
|||||||
float length;
|
float length;
|
||||||
faacDecHandle decoder;
|
faacDecHandle decoder;
|
||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
uint32_t sampleRate;
|
uint32_t sample_rate;
|
||||||
unsigned char channels;
|
unsigned char channels;
|
||||||
InputStream inStream;
|
InputStream inStream;
|
||||||
long bread;
|
long bread;
|
||||||
@ -274,11 +274,11 @@ static float getAacFloatTotalTime(char *file)
|
|||||||
fillAacBuffer(&b);
|
fillAacBuffer(&b);
|
||||||
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
||||||
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
||||||
&sampleRate, &channels);
|
&sample_rate, &channels);
|
||||||
#else
|
#else
|
||||||
bread = faacDecInit(decoder, b.buffer, &sampleRate, &channels);
|
bread = faacDecInit(decoder, b.buffer, &sample_rate, &channels);
|
||||||
#endif
|
#endif
|
||||||
if (bread >= 0 && sampleRate > 0 && channels > 0)
|
if (bread >= 0 && sample_rate > 0 && channels > 0)
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
@ -312,7 +312,7 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
|
|||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
long bread;
|
long bread;
|
||||||
struct audio_format audio_format;
|
struct audio_format audio_format;
|
||||||
uint32_t sampleRate;
|
uint32_t sample_rate;
|
||||||
unsigned char channels;
|
unsigned char channels;
|
||||||
unsigned int sampleCount;
|
unsigned int sampleCount;
|
||||||
char *sampleBuffer;
|
char *sampleBuffer;
|
||||||
@ -346,9 +346,9 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
|
|||||||
|
|
||||||
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
||||||
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
||||||
&sampleRate, &channels);
|
&sample_rate, &channels);
|
||||||
#else
|
#else
|
||||||
bread = faacDecInit(decoder, b.buffer, &sampleRate, &channels);
|
bread = faacDecInit(decoder, b.buffer, &sample_rate, &channels);
|
||||||
#endif
|
#endif
|
||||||
if (bread < 0) {
|
if (bread < 0) {
|
||||||
ERROR("Error not a AAC stream.\n");
|
ERROR("Error not a AAC stream.\n");
|
||||||
@ -386,12 +386,12 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
||||||
sampleRate = frameInfo.samplerate;
|
sample_rate = frameInfo.samplerate;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
audio_format.channels = frameInfo.channels;
|
audio_format.channels = frameInfo.channels;
|
||||||
audio_format.sampleRate = sampleRate;
|
audio_format.sample_rate = sample_rate;
|
||||||
decoder_initialized(mpd_decoder, &audio_format, totalTime);
|
decoder_initialized(mpd_decoder, &audio_format, totalTime);
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
}
|
}
|
||||||
@ -402,11 +402,11 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
|
|||||||
|
|
||||||
if (sampleCount > 0) {
|
if (sampleCount > 0) {
|
||||||
bitRate = frameInfo.bytesconsumed * 8.0 *
|
bitRate = frameInfo.bytesconsumed * 8.0 *
|
||||||
frameInfo.channels * sampleRate /
|
frameInfo.channels * sample_rate /
|
||||||
frameInfo.samples / 1000 + 0.5;
|
frameInfo.samples / 1000 + 0.5;
|
||||||
file_time +=
|
file_time +=
|
||||||
(float)(frameInfo.samples) / frameInfo.channels /
|
(float)(frameInfo.samples) / frameInfo.channels /
|
||||||
sampleRate;
|
sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleBufferLen = sampleCount * 2;
|
sampleBufferLen = sampleCount * 2;
|
||||||
@ -446,7 +446,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
long bread;
|
long bread;
|
||||||
struct audio_format audio_format;
|
struct audio_format audio_format;
|
||||||
uint32_t sampleRate;
|
uint32_t sample_rate;
|
||||||
unsigned char channels;
|
unsigned char channels;
|
||||||
unsigned int sampleCount;
|
unsigned int sampleCount;
|
||||||
char *sampleBuffer;
|
char *sampleBuffer;
|
||||||
@ -484,9 +484,9 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
|
|
||||||
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
||||||
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
||||||
&sampleRate, &channels);
|
&sample_rate, &channels);
|
||||||
#else
|
#else
|
||||||
bread = faacDecInit(decoder, b.buffer, &sampleRate, &channels);
|
bread = faacDecInit(decoder, b.buffer, &sample_rate, &channels);
|
||||||
#endif
|
#endif
|
||||||
if (bread < 0) {
|
if (bread < 0) {
|
||||||
ERROR("Error not a AAC stream.\n");
|
ERROR("Error not a AAC stream.\n");
|
||||||
@ -522,12 +522,12 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
||||||
sampleRate = frameInfo.samplerate;
|
sample_rate = frameInfo.samplerate;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
audio_format.channels = frameInfo.channels;
|
audio_format.channels = frameInfo.channels;
|
||||||
audio_format.sampleRate = sampleRate;
|
audio_format.sample_rate = sample_rate;
|
||||||
decoder_initialized(mpd_decoder, &audio_format,
|
decoder_initialized(mpd_decoder, &audio_format,
|
||||||
totalTime);
|
totalTime);
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
@ -539,11 +539,11 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
|
|
||||||
if (sampleCount > 0) {
|
if (sampleCount > 0) {
|
||||||
bitRate = frameInfo.bytesconsumed * 8.0 *
|
bitRate = frameInfo.bytesconsumed * 8.0 *
|
||||||
frameInfo.channels * sampleRate /
|
frameInfo.channels * sample_rate /
|
||||||
frameInfo.samples / 1000 + 0.5;
|
frameInfo.samples / 1000 + 0.5;
|
||||||
file_time +=
|
file_time +=
|
||||||
(float)(frameInfo.samples) / frameInfo.channels /
|
(float)(frameInfo.samples) / frameInfo.channels /
|
||||||
sampleRate;
|
sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleBufferLen = sampleCount * 2;
|
sampleBufferLen = sampleCount * 2;
|
||||||
|
@ -71,14 +71,14 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
AF_SAMPFMT_TWOSCOMP, 16);
|
AF_SAMPFMT_TWOSCOMP, 16);
|
||||||
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
||||||
audio_format.bits = (uint8_t)bits;
|
audio_format.bits = (uint8_t)bits;
|
||||||
audio_format.sampleRate =
|
audio_format.sample_rate =
|
||||||
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
|
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
|
||||||
audio_format.channels =
|
audio_format.channels =
|
||||||
(uint8_t)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
(uint8_t)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
||||||
|
|
||||||
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
|
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
|
||||||
|
|
||||||
total_time = ((float)frame_count / (float)audio_format.sampleRate);
|
total_time = ((float)frame_count / (float)audio_format.sample_rate);
|
||||||
|
|
||||||
bitRate = (uint16_t)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
|
bitRate = (uint16_t)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
current = decoder_seek_where(decoder) *
|
current = decoder_seek_where(decoder) *
|
||||||
audio_format.sampleRate;
|
audio_format.sample_rate;
|
||||||
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
current += ret;
|
current += ret;
|
||||||
decoder_data(decoder, NULL, 1,
|
decoder_data(decoder, NULL, 1,
|
||||||
chunk, ret * fs,
|
chunk, ret * fs,
|
||||||
(float)current / (float)audio_format.sampleRate,
|
(float)current / (float)audio_format.sample_rate,
|
||||||
bitRate, NULL);
|
bitRate, NULL);
|
||||||
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
|
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
|
||||||
|
|
||||||
|
@ -350,11 +350,11 @@ static int flac_decode_internal(struct decoder * decoder,
|
|||||||
break;
|
break;
|
||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
|
||||||
FLAC__uint64 sampleToSeek = decoder_seek_where(decoder) *
|
FLAC__uint64 sampleToSeek = decoder_seek_where(decoder) *
|
||||||
data.audio_format.sampleRate + 0.5;
|
data.audio_format.sample_rate + 0.5;
|
||||||
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
data.audio_format.sampleRate;
|
data.audio_format.sample_rate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
} else
|
} else
|
||||||
|
@ -186,12 +186,12 @@ static int mod_decode(struct decoder * decoder, char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
audio_format.sampleRate = 44100;
|
audio_format.sample_rate = 44100;
|
||||||
audio_format.channels = 2;
|
audio_format.channels = 2;
|
||||||
|
|
||||||
secPerByte =
|
secPerByte =
|
||||||
1.0 / ((audio_format.bits * audio_format.channels / 8.0) *
|
1.0 / ((audio_format.bits * audio_format.channels / 8.0) *
|
||||||
(float)audio_format.sampleRate);
|
(float)audio_format.sample_rate);
|
||||||
|
|
||||||
decoder_initialized(decoder, &audio_format, 0);
|
decoder_initialized(decoder, &audio_format, 0);
|
||||||
|
|
||||||
|
@ -1030,7 +1030,7 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
|
|||||||
struct audio_format * af)
|
struct audio_format * af)
|
||||||
{
|
{
|
||||||
af->bits = 16;
|
af->bits = 16;
|
||||||
af->sampleRate = (data->frame).header.samplerate;
|
af->sample_rate = (data->frame).header.samplerate;
|
||||||
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
af->channels = MAD_NCHANNELS(&(data->frame).header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
struct audio_format audio_format;
|
struct audio_format audio_format;
|
||||||
unsigned char *mp4Buffer;
|
unsigned char *mp4Buffer;
|
||||||
unsigned int mp4BufferSize;
|
unsigned int mp4BufferSize;
|
||||||
uint32_t sampleRate;
|
uint32_t sample_rate;
|
||||||
unsigned char channels;
|
unsigned char channels;
|
||||||
long sampleId;
|
long sampleId;
|
||||||
long numSamples;
|
long numSamples;
|
||||||
@ -149,7 +149,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
mp4ff_get_decoder_config(mp4fh, track, &mp4Buffer, &mp4BufferSize);
|
mp4ff_get_decoder_config(mp4fh, track, &mp4Buffer, &mp4BufferSize);
|
||||||
|
|
||||||
if (faacDecInit2
|
if (faacDecInit2
|
||||||
(decoder, mp4Buffer, mp4BufferSize, &sampleRate, &channels) < 0) {
|
(decoder, mp4Buffer, mp4BufferSize, &sample_rate, &channels) < 0) {
|
||||||
ERROR("Error not a AAC stream.\n");
|
ERROR("Error not a AAC stream.\n");
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
@ -157,7 +157,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_format.sampleRate = sampleRate;
|
audio_format.sample_rate = sample_rate;
|
||||||
audio_format.channels = channels;
|
audio_format.channels = channels;
|
||||||
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
||||||
scale = mp4ff_time_scale(mp4fh, track);
|
scale = mp4ff_time_scale(mp4fh, track);
|
||||||
@ -255,7 +255,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
||||||
scale = frameInfo.samplerate;
|
scale = frameInfo.samplerate;
|
||||||
#endif
|
#endif
|
||||||
audio_format.sampleRate = scale;
|
audio_format.sample_rate = scale;
|
||||||
audio_format.channels = frameInfo.channels;
|
audio_format.channels = frameInfo.channels;
|
||||||
decoder_initialized(mpd_decoder, &audio_format,
|
decoder_initialized(mpd_decoder, &audio_format,
|
||||||
total_time);
|
total_time);
|
||||||
|
@ -154,7 +154,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
audio_format.bits = 16;
|
audio_format.bits = 16;
|
||||||
audio_format.channels = info.channels;
|
audio_format.channels = info.channels;
|
||||||
audio_format.sampleRate = info.sample_freq;
|
audio_format.sample_rate = info.sample_freq;
|
||||||
|
|
||||||
replayGainInfo = newReplayGainInfo();
|
replayGainInfo = newReplayGainInfo();
|
||||||
replayGainInfo->albumGain = info.gain_album * 0.01;
|
replayGainInfo->albumGain = info.gain_album * 0.01;
|
||||||
@ -168,7 +168,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
while (!eof) {
|
while (!eof) {
|
||||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
|
||||||
samplePos = decoder_seek_where(mpd_decoder) *
|
samplePos = decoder_seek_where(mpd_decoder) *
|
||||||
audio_format.sampleRate;
|
audio_format.sample_rate;
|
||||||
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
||||||
decoder_clear(mpd_decoder);
|
decoder_clear(mpd_decoder);
|
||||||
s16 = (int16_t *) chunk;
|
s16 = (int16_t *) chunk;
|
||||||
@ -201,10 +201,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
if (chunkpos >= MPC_CHUNK_SIZE) {
|
if (chunkpos >= MPC_CHUNK_SIZE) {
|
||||||
total_time = ((float)samplePos) /
|
total_time = ((float)samplePos) /
|
||||||
audio_format.sampleRate;
|
audio_format.sample_rate;
|
||||||
|
|
||||||
bitRate = vbrUpdateBits *
|
bitRate = vbrUpdateBits *
|
||||||
audio_format.sampleRate / 1152 / 1000;
|
audio_format.sample_rate / 1152 / 1000;
|
||||||
|
|
||||||
decoder_data(mpd_decoder, inStream,
|
decoder_data(mpd_decoder, inStream,
|
||||||
inStream->seekable,
|
inStream->seekable,
|
||||||
@ -224,10 +224,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP &&
|
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP &&
|
||||||
chunkpos > 0) {
|
chunkpos > 0) {
|
||||||
total_time = ((float)samplePos) / audio_format.sampleRate;
|
total_time = ((float)samplePos) / audio_format.sample_rate;
|
||||||
|
|
||||||
bitRate =
|
bitRate =
|
||||||
vbrUpdateBits * audio_format.sampleRate / 1152 / 1000;
|
vbrUpdateBits * audio_format.sample_rate / 1152 / 1000;
|
||||||
|
|
||||||
decoder_data(mpd_decoder, NULL, inStream->seekable,
|
decoder_data(mpd_decoder, NULL, inStream->seekable,
|
||||||
chunk, chunkpos, total_time, bitRate,
|
chunk, chunkpos, total_time, bitRate,
|
||||||
|
@ -316,12 +316,12 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
}
|
}
|
||||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
|
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
|
||||||
FLAC__uint64 sampleToSeek = decoder_seek_where(mpd_decoder) *
|
FLAC__uint64 sampleToSeek = decoder_seek_where(mpd_decoder) *
|
||||||
data.audio_format.sampleRate + 0.5;
|
data.audio_format.sample_rate + 0.5;
|
||||||
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
||||||
(decoder, sampleToSeek)) {
|
(decoder, sampleToSeek)) {
|
||||||
decoder_clear(mpd_decoder);
|
decoder_clear(mpd_decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
data.audio_format.sampleRate;
|
data.audio_format.sample_rate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
decoder_command_finished(mpd_decoder);
|
decoder_command_finished(mpd_decoder);
|
||||||
} else
|
} else
|
||||||
|
@ -278,7 +278,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
/*printf("new song!\n"); */
|
/*printf("new song!\n"); */
|
||||||
vorbis_info *vi = ov_info(&vf, -1);
|
vorbis_info *vi = ov_info(&vf, -1);
|
||||||
audio_format.channels = vi->channels;
|
audio_format.channels = vi->channels;
|
||||||
audio_format.sampleRate = vi->rate;
|
audio_format.sample_rate = vi->rate;
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
float total_time = ov_time_total(&vf, -1);
|
float total_time = ov_time_total(&vf, -1);
|
||||||
if (total_time < 0)
|
if (total_time < 0)
|
||||||
@ -311,7 +311,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
decoder_data(decoder, inStream,
|
decoder_data(decoder, inStream,
|
||||||
inStream->seekable,
|
inStream->seekable,
|
||||||
chunk, chunkpos,
|
chunk, chunkpos,
|
||||||
ov_pcm_tell(&vf) / audio_format.sampleRate,
|
ov_pcm_tell(&vf) / audio_format.sample_rate,
|
||||||
bitRate, replayGainInfo);
|
bitRate, replayGainInfo);
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP)
|
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP)
|
||||||
|
@ -140,7 +140,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
int position, outsamplesize;
|
int position, outsamplesize;
|
||||||
int Bps;
|
int Bps;
|
||||||
|
|
||||||
audio_format.sampleRate = WavpackGetSampleRate(wpc);
|
audio_format.sample_rate = WavpackGetSampleRate(wpc);
|
||||||
audio_format.channels = WavpackGetReducedChannels(wpc);
|
audio_format.channels = WavpackGetReducedChannels(wpc);
|
||||||
audio_format.bits = WavpackGetBitsPerSample(wpc);
|
audio_format.bits = WavpackGetBitsPerSample(wpc);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
samplesreq = sizeof(chunk) / (4 * audio_format.channels);
|
samplesreq = sizeof(chunk) / (4 * audio_format.channels);
|
||||||
|
|
||||||
decoder_initialized(decoder, &audio_format,
|
decoder_initialized(decoder, &audio_format,
|
||||||
(float)allsamples / audio_format.sampleRate);
|
(float)allsamples / audio_format.sample_rate);
|
||||||
|
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
|
|
||||||
where = decoder_seek_where(decoder) *
|
where = decoder_seek_where(decoder) *
|
||||||
audio_format.sampleRate;
|
audio_format.sample_rate;
|
||||||
if (WavpackSeekSample(wpc, where)) {
|
if (WavpackSeekSample(wpc, where)) {
|
||||||
position = where;
|
position = where;
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
@ -200,8 +200,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
int bitrate = (int)(WavpackGetInstantBitrate(wpc) /
|
int bitrate = (int)(WavpackGetInstantBitrate(wpc) /
|
||||||
1000 + 0.5);
|
1000 + 0.5);
|
||||||
position += samplesgot;
|
position += samplesgot;
|
||||||
file_time = (float)position /
|
file_time = (float)position / audio_format.sample_rate;
|
||||||
audio_format.sampleRate;
|
|
||||||
|
|
||||||
format_samples(Bps, chunk,
|
format_samples(Bps, chunk,
|
||||||
samplesgot * audio_format.channels);
|
samplesgot * audio_format.channels);
|
||||||
|
@ -503,13 +503,13 @@ size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inFormat->sampleRate == outFormat->sampleRate) {
|
if (inFormat->sample_rate == outFormat->sample_rate) {
|
||||||
assert(outSize >= len);
|
assert(outSize >= len);
|
||||||
memcpy(outBuffer, buf, len);
|
memcpy(outBuffer, buf, len);
|
||||||
} else {
|
} else {
|
||||||
len = pcm_convertSampleRate(outFormat->channels,
|
len = pcm_convertSampleRate(outFormat->channels,
|
||||||
inFormat->sampleRate, buf, len,
|
inFormat->sample_rate, buf, len,
|
||||||
outFormat->sampleRate, outBuffer,
|
outFormat->sample_rate, outBuffer,
|
||||||
outSize, convState);
|
outSize, convState);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -521,8 +521,8 @@ size_t pcm_convertAudioFormat(const struct audio_format *inFormat,
|
|||||||
size_t pcm_sizeOfConvBuffer(const struct audio_format *inFormat, size_t inSize,
|
size_t pcm_sizeOfConvBuffer(const struct audio_format *inFormat, size_t inSize,
|
||||||
const struct audio_format *outFormat)
|
const struct audio_format *outFormat)
|
||||||
{
|
{
|
||||||
const double ratio = (double)outFormat->sampleRate /
|
const double ratio = (double)outFormat->sample_rate /
|
||||||
(double)inFormat->sampleRate;
|
(double)inFormat->sample_rate;
|
||||||
const int shift = 2 * outFormat->channels;
|
const int shift = 2 * outFormat->channels;
|
||||||
size_t outSize = inSize;
|
size_t outSize = inSize;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ static void do_play(void)
|
|||||||
closeAudioDevice();
|
closeAudioDevice();
|
||||||
}
|
}
|
||||||
pc.totalTime = dc.totalTime;
|
pc.totalTime = dc.totalTime;
|
||||||
pc.sampleRate = dc.audioFormat.sampleRate;
|
pc.sampleRate = dc.audioFormat.sample_rate;
|
||||||
pc.bits = dc.audioFormat.bits;
|
pc.bits = dc.audioFormat.bits;
|
||||||
pc.channels = dc.audioFormat.channels;
|
pc.channels = dc.audioFormat.channels;
|
||||||
sizeToTime = audioFormatSizeToTime(&ob.audioFormat);
|
sizeToTime = audioFormatSizeToTime(&ob.audioFormat);
|
||||||
|
@ -40,7 +40,7 @@ Timer *timer_new(const struct audio_format *af)
|
|||||||
timer = xmalloc(sizeof(Timer));
|
timer = xmalloc(sizeof(Timer));
|
||||||
timer->time = 0;
|
timer->time = 0;
|
||||||
timer->started = 0;
|
timer->started = 0;
|
||||||
timer->rate = af->sampleRate * (af->bits / CHAR_BIT) * af->channels;
|
timer->rate = af->sample_rate * (af->bits / CHAR_BIT) * af->channels;
|
||||||
|
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user