/** The number of channels of the current stream. */
unsigned int channels;
/** Current sample rate in Hz. */
- unsigned int samplerate;
+ unsigned int sample_rate;
};
static int aacdec_execute(struct btr_node *btrn, const char *cmd, char **result)
struct filter_node *fn = btr_context(btrn);
struct private_aacdec_data *padd = fn->private_data;
- if (!strcmp(cmd, "samplerate")) {
- if (padd->samplerate == 0)
+ if (!strcmp(cmd, "sample_rate")) {
+ if (padd->sample_rate == 0)
return -E_BTR_NAVAIL;
- *result = make_message("%u", padd->samplerate);
+ *result = make_message("%u", padd->sample_rate);
return 1;
}
if (!strcmp(cmd, "channels")) {
&channels) < 0)
goto out;
}
- padd->samplerate = rate;
+ padd->sample_rate = rate;
padd->channels = channels;
PARA_INFO_LOG("rate: %u, channels: %d\n",
- padd->samplerate, padd->channels);
+ padd->sample_rate, padd->channels);
padd->initialized = 1;
}
if (padd->decoder_length > 0) {
/* Number of frames that fit into the buffer. */
snd_pcm_uframes_t buffer_frames;
/**
- * The samplerate given by command line option or the decoder
+ * The sample rate given by command line option or the decoder
* of the writer node group.
*/
- unsigned samplerate;
+ unsigned sample_rate;
/**
* The number of channels, given by command line option or the
* decoder of the writer node group.
pad->channels) < 0)
return -E_CHANNEL_COUNT;
if (snd_pcm_hw_params_set_rate_near(pad->handle, hwparams,
- &pad->samplerate, NULL) < 0)
+ &pad->sample_rate, NULL) < 0)
return -E_SET_RATE;
err = snd_pcm_hw_params_get_buffer_time_max(hwparams,
&pad->buffer_time, NULL);
start_threshold = 1;
else
start_threshold = PARA_MIN(pad->buffer_frames,
- (snd_pcm_uframes_t)pad->samplerate);
+ (snd_pcm_uframes_t)pad->sample_rate);
if (snd_pcm_sw_params_set_start_threshold(pad->handle, swparams,
start_threshold) < 0)
return -E_START_THRESHOLD;
if (bytes == 0) /* no data available */
return;
/* defaults */
- pad->samplerate = conf->samplerate_arg;
+ pad->sample_rate = conf->sample_rate_arg;
pad->channels = conf->channels_arg;
- if (!conf->samplerate_given) { /* config option trumps btr_exec */
+ if (!conf->sample_rate_given) { /* config option trumps btr_exec */
int32_t rate;
- if (get_btr_samplerate(btrn, &rate) >= 0)
- pad->samplerate = rate;
+ if (get_btr_sample_rate(btrn, &rate) >= 0)
+ pad->sample_rate = rate;
}
if (!conf->channels_given) {
int32_t ch;
if (get_btr_channels(btrn, &ch) >= 0)
pad->channels = ch;
}
- PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->samplerate);
+ PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->sample_rate);
ret = alsa_init(pad, wn->conf);
if (ret < 0)
goto err;
of channels will be obtained from other resources.
"
-option "samplerate" s
+option "sample_rate" s
#~~~~~~~~~~~~~~~~~~~~~
"force given sample rate"
int typestr="num"
of channels will be obtained from other resources.
"
-option "samplerate" s
+option "sample_rate" s
#~~~~~~~~~~~~~~~~~~~~~
"force given sample rate"
int typestr="num"
default="2"
optional
-option "samplerate" s
+option "sample_rate" s
#~~~~~~~~~~~~~~~~~~~~~
"force given sample rate (only neccessary for
/** The number of channels of the current stream. */
unsigned int channels;
/** Current sample rate in Hz. */
- unsigned int samplerate;
+ unsigned int sample_rate;
};
static int need_bad_data_delay(struct private_mp3dec_data *pmd,
goto next_buffer;
}
fn->min_iqs = 0;
- pmd->samplerate = pmd->frame.header.samplerate;
+ pmd->sample_rate = pmd->frame.header.samplerate;
pmd->channels = MAD_NCHANNELS(&pmd->frame.header);
ret = mad_frame_decode(&pmd->frame, &pmd->stream);
if (ret != 0) {
struct filter_node *fn = btr_context(btrn);
struct private_mp3dec_data *pmd = fn->private_data;
- if (!strcmp(cmd, "samplerate")) {
- if (pmd->samplerate == 0)
+ if (!strcmp(cmd, "sample_rate")) {
+ if (pmd->sample_rate == 0)
return -E_BTR_NAVAIL;
- *result = make_message("%u", pmd->samplerate);
+ *result = make_message("%u", pmd->sample_rate);
return 1;
}
if (!strcmp(cmd, "channels")) {
/** The number of channels of the current stream. */
unsigned int channels;
/** Current sample rate in Hz. */
- unsigned int samplerate;
struct timeval stream_start;
+ unsigned int sample_rate;
};
static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource)
struct filter_node *fn = btr_context(btrn);
struct private_oggdec_data *pod = fn->private_data;
- if (!strcmp(cmd, "samplerate")) {
- if (pod->samplerate == 0)
+ if (!strcmp(cmd, "sample_rate")) {
+ if (pod->sample_rate == 0)
return -E_BTR_NAVAIL;
- *result = make_message("%u", pod->samplerate);
+ *result = make_message("%u", pod->sample_rate);
return 1;
}
if (!strcmp(cmd, "channels")) {
if (oret < 0)
goto out;
pod->channels = ov_info(pod->vf, 0)->channels;
- pod->samplerate = ov_info(pod->vf, 0)->rate;
+ pod->sample_rate = ov_info(pod->vf, 0)->rate;
tv_add(now, &(struct timeval)EMBRACE(0, 300 * 1000), &pod->stream_start);
PARA_NOTICE_LOG("%d channels, %d Hz\n", pod->channels,
- pod->samplerate);
+ pod->sample_rate);
ret = 1;
out:
if (ret <= 0) {
* incorrectly believe that the device is still in 44.1 kHz mode when actually
* the speed is decreased to 22.05 kHz.
*/
-static int oss_init(struct writer_node *wn, unsigned samplerate, unsigned channels)
+static int oss_init(struct writer_node *wn, unsigned sample_rate, unsigned channels)
{
int ret, format = FORMAT;
unsigned ch, rate;
* device, the the highest possible speed is automatically used. The
* value actually used is returned as the new value of the argument.
*/
- rate = samplerate;
+ rate = sample_rate;
ret = ioctl(powd->fd, SNDCTL_DSP_SPEED, &rate);
if (ret < 0) {
ret = -ERRNO_TO_PARA_ERROR(errno);
goto err;
}
- if (rate != samplerate) {
- unsigned min = PARA_MIN(rate, samplerate),
- max = PARA_MAX(rate, samplerate);
+ if (rate != sample_rate) {
+ unsigned min = PARA_MIN(rate, sample_rate),
+ max = PARA_MAX(rate, sample_rate);
/*
* Check whether the returned sample rate differs significantly
* from the requested one.
if (100 * max > 110 * min) /* more than 10% deviation */
goto err;
PARA_NOTICE_LOG("using %dHz rather than %dHz\n", rate,
- samplerate);
+ sample_rate);
}
wn->min_iqs = powd->bytes_per_frame;
return 1;
if (powd->fd < 0) {
int32_t rate, ch;
ret = -1;
- if (!conf->samplerate_given) /* config option trumps btr_exec */
- ret = get_btr_samplerate(wn->btrn, &rate);
+ if (!conf->sample_rate_given) /* config option trumps btr_exec */
+ ret = get_btr_sample_rate(wn->btrn, &rate);
if (ret < 0)
- rate = conf->samplerate_arg;
+ rate = conf->sample_rate_arg;
ret = -1;
if (!conf->channels_given)
ret = get_btr_channels(wn->btrn, &ch);
/** the post_select writes audio data here */
struct osx_buffer *to;
/** sample rate of the current audio stream */
- unsigned samplerate;
+ unsigned sample_rate;
/** number of channels of the current audio stream */
unsigned channels;
};
if (AudioUnitInitialize(powd->audio_unit))
goto e1;
powd->play = 0;
- powd->samplerate = conf->samplerate_arg;
+ powd->sample_rate = conf->sample_rate_arg;
powd->channels = conf->channels_arg;
- if (!conf->samplerate_given) {
+ if (!conf->sample_rate_given) {
int32_t rate;
- if (get_btr_samplerate(btrn, &rate) >= 0)
- powd->samplerate = rate;
+ get_btr_sample_rate(btrn, &rate);
+ powd->sample_rate = rate;
}
if (!conf->channels_given) {
int32_t ch;
- if (get_btr_channels(btrn, &ch) >= 0)
- powd->channels = ch;
+ get_btr_channels(btrn, &ch);
+ powd->channels = ch;
}
/*
* Choose PCM format. We tell the Output Unit what format we're going
* any format conversions necessary from your format to the device's
* format.
*/
- format.mSampleRate = powd->samplerate;
+ format.mSampleRate = powd->sample_rate;
/* The specific encoding type of audio stream */
format.mFormatID = kAudioFormatLinearPCM;
/* flags specific to each format */
sched_min_delay(s);
if (ret <= 0 || numbytes < wn->min_iqs)
return;
- divisor = powd->samplerate * wn->min_iqs / numbytes;
+ divisor = powd->sample_rate * wn->min_iqs / numbytes;
if (divisor)
tv_divide(divisor, &tmp, &delay);
sched_request_timeout(&delay, s);
/** Always write 16 bit header. */
#define BITS 16
-static void make_wav_header(unsigned int channels, unsigned int samplerate,
+static void make_wav_header(unsigned int channels, unsigned int sample_rate,
char *headbuf)
{
unsigned int size = 0x7fffffff;
- int bytespersec = channels * samplerate * BITS / 8;
+ int bytespersec = channels * sample_rate * BITS / 8;
int align = channels * BITS / 8;
- PARA_DEBUG_LOG("writing wave header: %d channels, %d KHz\n", channels, samplerate);
+ PARA_DEBUG_LOG("writing wave header: %d channels, %d KHz\n", channels, sample_rate);
memset(headbuf, 0, WAV_HEADER_LEN);
memcpy(headbuf, "RIFF", 4);
write_u32(headbuf + 4, size - 8);
write_u32(headbuf + 16, 16); /* 16 + extra format bytes (zero) */
write_u16(headbuf + 20, 1); /* format (1 == PCM/uncompressed) */
write_u16(headbuf + 22, channels);
- write_u32(headbuf + 24, samplerate);
+ write_u32(headbuf + 24, sample_rate);
write_u32(headbuf + 28, bytespersec);
write_u16(headbuf + 32, align); /* number of bytes per sample slice */
write_u16(headbuf + 34, BITS); /* significant bits per sample */
goto err;
return;
}
- ret = btr_exec_up(btrn, "samplerate", &buf);
+ ret = btr_exec_up(btrn, "sample_rate", &buf);
if (ret < 0) {
ret = -E_WAV_BAD_FC;
goto err;
struct filter_node *fn = btr_context(btrn);
struct private_wmadec_data *pwd = fn->private_data;
- if (!strcmp(cmd, "samplerate")) {
+ if (!strcmp(cmd, "sample_rate")) {
if (pwd->ahi.sample_rate == 0)
return -E_BTR_NAVAIL;
*result = make_message("%u", pwd->ahi.sample_rate);
/** Number of channels specified in wav header given by \a buf. */
unsigned channels;
/** Sample rate specified in wav header given by \a buf. */
- unsigned samplerate;
+ unsigned sample_rate;
/** The task structure used by the scheduler. */
struct task task;
struct btr_node *btrn;
struct check_wav_task *cwt = btr_context(btrn);
- if (!strcmp(cmd, "samplerate")) {
+ if (!strcmp(cmd, "sample_rate")) {
if (cwt->state != CWS_HAVE_HEADER)
return -E_BTR_NAVAIL;
- *result = make_message("%d", cwt->samplerate);
+ *result = make_message("%d", cwt->sample_rate);
return 1;
}
if (!strcmp(cmd, "channels")) {
goto pushdown;
cwt->min_iqs = 0;
cwt->channels = 2;
- cwt->samplerate = 44100;
+ cwt->sample_rate = 44100;
if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F') {
PARA_NOTICE_LOG("wav header not found\n");
cwt->state = CWS_NO_HEADER;
cwt->state = CWS_HAVE_HEADER;
sprintf(t->status, "check wav: have header");
cwt->channels = (unsigned) a[22];
- cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+ cwt->sample_rate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+ PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->sample_rate);
btr_consume(btrn, WAV_HEADER_LEN);
pushdown:
btr_pushdown(btrn);
}
/*
- * Ask parent btr nodes for the samplerate of the current stream.
+ * Ask parent btr nodes for the sample rate of the current stream.
*/
-int get_btr_samplerate(struct btr_node *btrn, int32_t *result)
+int get_btr_sample_rate(struct btr_node *btrn, int32_t *result)
{
- return get_btr_value(btrn, "samplerate", result);
+ return get_btr_value(btrn, "sample_rate", result);
}
/*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
-/** \file write_common.h exported symbols from write_common.c */
+/** \file write_common.h Exported symbols from write_common.c */
void writer_init(void);
void *check_writer_arg(const char *wa, int *writer_num);
void register_writer_node(struct writer_node *wn, struct btr_node *parent);
int setup_writer_node(const char *arg, struct btr_node *parent,
struct writer_node *wn);
-int get_btr_samplerate(struct btr_node *btrn, int32_t *result);
+int get_btr_sample_rate(struct btr_node *btrn, int32_t *result);
int get_btr_channels(struct btr_node *btrn, int32_t *result);