From: Andre Noll Date: Wed, 30 Jun 2010 12:09:56 +0000 (+0200) Subject: Cosmetics: Rename samplerate to sample_rate. X-Git-Tag: v0.4.4~8^2~4 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=d4d37bb32a8d6219f9f52aa2ee3de55eb7e099c8;p=paraslash.git Cosmetics: Rename samplerate to sample_rate. A subsequent patch will introduce sample_format which looks much nicer than sampleformat. So let's use the underscored variant throughout. --- diff --git a/aacdec_filter.c b/aacdec_filter.c index f33f21eb..79c8bb66 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -52,7 +52,7 @@ struct private_aacdec_data { /** 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) @@ -60,10 +60,10 @@ 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")) { @@ -140,10 +140,10 @@ next_buffer: &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) { diff --git a/alsa_write.c b/alsa_write.c index 7a4b868d..240d5123 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -45,10 +45,10 @@ struct private_alsa_write_data { /* 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. @@ -86,7 +86,7 @@ static int alsa_init(struct private_alsa_write_data *pad, 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); @@ -110,7 +110,7 @@ static int alsa_init(struct private_alsa_write_data *pad, 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; @@ -232,19 +232,19 @@ again: 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; diff --git a/ggo/alsa_write.m4 b/ggo/alsa_write.m4 index afcefccf..54d0f72f 100644 --- a/ggo/alsa_write.m4 +++ b/ggo/alsa_write.m4 @@ -25,7 +25,7 @@ details=" of channels will be obtained from other resources. " -option "samplerate" s +option "sample_rate" s #~~~~~~~~~~~~~~~~~~~~~ "force given sample rate" int typestr="num" diff --git a/ggo/oss_write.ggo b/ggo/oss_write.ggo index 60682186..1f6f5825 100644 --- a/ggo/oss_write.ggo +++ b/ggo/oss_write.ggo @@ -18,7 +18,7 @@ details=" of channels will be obtained from other resources. " -option "samplerate" s +option "sample_rate" s #~~~~~~~~~~~~~~~~~~~~~ "force given sample rate" int typestr="num" diff --git a/ggo/osx_write.ggo b/ggo/osx_write.ggo index 33c495ab..8dca8212 100644 --- a/ggo/osx_write.ggo +++ b/ggo/osx_write.ggo @@ -13,7 +13,7 @@ details = " default="2" optional -option "samplerate" s +option "sample_rate" s #~~~~~~~~~~~~~~~~~~~~~ "force given sample rate (only neccessary for diff --git a/mp3dec_filter.c b/mp3dec_filter.c index 35448da7..f03fbb76 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -50,7 +50,7 @@ struct private_mp3dec_data { /** 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, @@ -165,7 +165,7 @@ next_frame: 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) { @@ -236,10 +236,10 @@ static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result) 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")) { diff --git a/oggdec_filter.c b/oggdec_filter.c index 541b0b23..8a40ce0c 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -35,8 +35,8 @@ struct private_oggdec_data { /** 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) @@ -121,10 +121,10 @@ static int oggdec_execute(struct btr_node *btrn, const char *cmd, char **result) 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")) { @@ -178,10 +178,10 @@ open: 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) { diff --git a/oss_write.c b/oss_write.c index 6525afa4..6ca1e16e 100644 --- a/oss_write.c +++ b/oss_write.c @@ -69,7 +69,7 @@ static void oss_close(struct writer_node *wn) * 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; @@ -115,15 +115,15 @@ static int oss_init(struct writer_node *wn, unsigned samplerate, unsigned channe * 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. @@ -132,7 +132,7 @@ static int oss_init(struct writer_node *wn, unsigned samplerate, unsigned channe 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; @@ -160,10 +160,10 @@ static void oss_post_select(__a_unused struct sched *s, 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); diff --git a/osx_write.c b/osx_write.c index bcff09f7..cde7fcea 100644 --- a/osx_write.c +++ b/osx_write.c @@ -57,7 +57,7 @@ struct private_osx_write_data { /** 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; }; @@ -193,17 +193,17 @@ static int osx_write_open(struct writer_node *wn) 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 @@ -212,7 +212,7 @@ static int osx_write_open(struct writer_node *wn) * 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 */ @@ -324,7 +324,7 @@ static void osx_write_pre_select(struct sched *s, struct task *t) 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); diff --git a/wav_filter.c b/wav_filter.c index abd850b2..63c7b7eb 100644 --- a/wav_filter.c +++ b/wav_filter.c @@ -24,15 +24,15 @@ /** 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); @@ -41,7 +41,7 @@ static void make_wav_header(unsigned int channels, unsigned int samplerate, 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 */ @@ -92,7 +92,7 @@ static void wav_post_select(__a_unused struct sched *s, struct task *t) 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; diff --git a/wmadec_filter.c b/wmadec_filter.c index 45fda79e..88165b9a 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -1208,7 +1208,7 @@ static int wmadec_execute(struct btr_node *btrn, const char *cmd, char **result) 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); diff --git a/write.c b/write.c index 416408a1..7dc9f85c 100644 --- a/write.c +++ b/write.c @@ -37,7 +37,7 @@ struct check_wav_task { /** 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; @@ -72,10 +72,10 @@ static int check_wav_exec(struct btr_node *btrn, const char *cmd, char **result) 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")) { @@ -107,7 +107,7 @@ static void check_wav_post_select(__a_unused struct sched *s, struct task *t) 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; @@ -118,8 +118,8 @@ static void check_wav_post_select(__a_unused struct sched *s, struct task *t) 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); diff --git a/write_common.c b/write_common.c index 1da78b51..0d30eb80 100644 --- a/write_common.c +++ b/write_common.c @@ -160,11 +160,11 @@ static int get_btr_value(struct btr_node *btrn, const char *key, int32_t *result } /* - * 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); } /* diff --git a/write_common.h b/write_common.h index b6f66fa6..785161ef 100644 --- a/write_common.h +++ b/write_common.h @@ -4,7 +4,7 @@ * 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); @@ -12,5 +12,5 @@ void print_writer_helps(int detailed); 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);