ref: 4d743c4f762900849beb2f84f7300a5cdbe21cd4
parent: ce1f8f35ab24334a43694eea3b67dcd36c788f89
author: rrt <rrt>
date: Sun Dec 10 19:34:09 EST 2006
Fix read and write return types: now st_size_t, like the size inputs. To support this change, turn on lots more compiler warnings, and fix all the warnings generated.
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -26,7 +26,7 @@
/* 8SVXSTARTREAD */
/*======================================================================*/
-int st_svxstartread(ft_t ft)
+static int st_svxstartread(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
@@ -211,11 +211,10 @@
/*======================================================================*/
/* 8SVXREAD */
/*======================================================================*/
-st_ssize_t st_svxread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_svxread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
{
unsigned char datum;
- int done = 0;
- int i;
+ size_t done = 0, i;
svx_t p = (svx_t ) ft->priv;
@@ -236,9 +235,9 @@
/*======================================================================*/
/* 8SVXSTOPREAD */
/*======================================================================*/
-int st_svxstopread(ft_t ft)
+static int st_svxstopread(ft_t ft)
{
- int i;
+ size_t i;
svx_t p = (svx_t ) ft->priv;
@@ -252,10 +251,10 @@
/*======================================================================*/
/* 8SVXSTARTWRITE */
/*======================================================================*/
-int st_svxstartwrite(ft_t ft)
+static int st_svxstartwrite(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
- int i;
+ size_t i;
/* 8svx is in big endian format. Swaps wahst
* read in on little endian machines.
@@ -288,13 +287,12 @@
/* 8SVXWRITE */
/*======================================================================*/
-st_ssize_t st_svxwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_svxwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
svx_t p = (svx_t ) ft->priv;
unsigned char datum;
- int done = 0;
- int i;
+ size_t done = 0, i;
p->nsamples += len;
@@ -313,12 +311,11 @@
/* 8SVXSTOPWRITE */
/*======================================================================*/
-int st_svxstopwrite(ft_t ft)
+static int st_svxstopwrite(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
- int i;
- int len;
+ size_t i, len;
char svxbuf[512];
/* append all channel pieces to channel 0 */
--- a/src/FFT.c
+++ b/src/FFT.c
@@ -62,7 +62,7 @@
static int IsPowerOfTwo(int x);
static int NumberOfBitsNeeded(int PowerOfTwo);
static int ReverseBits(int index, int NumBits);
-static void InitFFT();
+static void InitFFT(void);
int IsPowerOfTwo(int x)
{
@@ -103,7 +103,7 @@
* freed, to use as a lookup table for bit-reversal. The good news is that
* we bascially need this until the very end, so the fact that it's not freed
* is OK. */
-void InitFFT()
+void InitFFT(void)
{
int len, b;
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -139,6 +139,7 @@
EXEEXT = @EXEEXT@
GETOPT_LONG_FALSE = @GETOPT_LONG_FALSE@
GETOPT_LONG_TRUE = @GETOPT_LONG_TRUE@
+GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -166,9 +167,6 @@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
@@ -179,19 +177,26 @@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
+htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
+localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
+psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
@@ -230,9 +235,9 @@
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/Makefile
+ $(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
--- a/src/adpcm.c
+++ b/src/adpcm.c
@@ -72,7 +72,7 @@
{ 392,-232}
};
-inline st_sample_t AdpcmDecode(st_sample_t c, MsState_t *state,
+static inline st_sample_t AdpcmDecode(st_sample_t c, MsState_t *state,
st_sample_t sample1, st_sample_t sample2)
{
st_sample_t vlin;
@@ -248,14 +248,13 @@
return (int) sqrt(d2);
}
-inline void AdpcmMashChannel(
+static inline void AdpcmMashChannel(
int ch, /* channel number to encode, REQUIRE 0 <= ch < chans */
int chans, /* total channels */
const SAMPL *ip, /* ip[] is interleaved input samples */
int n, /* samples to encode PER channel, REQUIRE */
int *st, /* input/output steps, 16<=st[i] */
- unsigned char *obuff, /* output buffer[blockAlign] */
- int opt /* non-zero allows some cpu-intensive code to improve output */
+ unsigned char *obuff /* output buffer[blockAlign] */
)
{
SAMPL v[2];
@@ -305,8 +304,7 @@
int n, /* samples to encode PER channel */
int *st, /* input/output steps, 16<=st[i] */
unsigned char *obuff, /* output buffer[blockAlign] */
- int blockAlign, /* >= 7*chans + chans*(n-2)/2.0 */
- int opt /* non-zero allows some cpu-intensive code to improve output */
+ int blockAlign /* >= 7*chans + chans*(n-2)/2.0 */
)
{
int ch;
@@ -318,7 +316,7 @@
for (p=obuff+7*chans; p<obuff+blockAlign; p++) *p=0;
for (ch=0; ch<chans; ch++)
- AdpcmMashChannel(ch, chans, ip, n, st+ch, obuff, opt);
+ AdpcmMashChannel(ch, chans, ip, n, st+ch, obuff);
}
/*
@@ -334,8 +332,7 @@
unsigned short chans,
unsigned short blockAlign,
unsigned short samplesPerBlock
-)
-{
+){
st_size_t m, n;
if (samplesPerBlock) {
@@ -345,7 +342,7 @@
n = 0;
m = blockAlign;
}
- if (m >= 7*chans) {
+ if (m >= (size_t)(7*chans)) {
m -= 7*chans; /* bytes beyond block-header */
m = (2*m)/chans + 2; /* nibbles/chans + 2 in header */
if (samplesPerBlock && m > samplesPerBlock) m = samplesPerBlock;
--- a/src/adpcm.h
+++ b/src/adpcm.h
@@ -26,8 +26,7 @@
int n, /* samples to encode PER channel, REQUIRE */
int *st, /* input/output steps, 16<=st[i] */
unsigned char *obuff, /* output buffer[blockAlign] */
- int blockAlign, /* >= 7*chans + n/2 */
- int opt /* non-zero allows some cpu-intensive code to improve output */
+ int blockAlign /* >= 7*chans + n/2 */
);
/* Some helper functions for computing samples/block and blockalign */
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -74,7 +74,7 @@
static int commentChunk(char **text, char *chunkDescription, ft_t ft);
static void reportInstrument(ft_t ft);
-int st_aiffseek(ft_t ft, st_size_t offset)
+static int st_aiffseek(ft_t ft, st_size_t offset)
{
aiff_t aiff = (aiff_t ) ft->priv;
st_size_t new_offset, channel_block, alignment;
@@ -99,7 +99,7 @@
return(ft->st_errno);
}
-int st_aiffstartread(ft_t ft)
+static int st_aiffstartread(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
char buf[5];
@@ -408,7 +408,7 @@
if (foundcomm) {
ft->info.channels = channels;
ft->info.rate = rate;
- if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
st_report("AIFF only supports signed data. Forcing to signed.");
ft->info.encoding = ST_ENCODING_SIGN2;
if (bits <= 8)
@@ -441,9 +441,9 @@
return(ST_EOF);
}
} else {
- if ((ft->info.channels == -1)
+ if ((ft->info.channels == 0)
|| (ft->info.rate == 0)
- || (ft->info.encoding == -1)
+ || (ft->info.encoding == ST_ENCODING_UNKNOWN)
|| (ft->info.size == -1)) {
st_report("You must specify # channels, sample rate, signed/unsigned,");
st_report("and 8/16 on the command line.");
@@ -633,7 +633,7 @@
st_debug("%-10s \"%s\"", chunkDescription, *text);
/* make sure we read the whole chunk */
if (totalReadLength < chunksize) {
- int i;
+ size_t i;
char c;
for (i=0; i < chunksize - totalReadLength; i++ ) {
st_readbuf(ft, &c, 1, 1);
@@ -642,14 +642,12 @@
return(ST_SUCCESS);
}
-st_ssize_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len)
{
aiff_t aiff = (aiff_t ) ft->priv;
st_ssize_t done;
- if (len < 0)
- return ST_EOF;
- else if ((st_size_t)len > aiff->nsamples)
+ if ((st_size_t)len > aiff->nsamples)
len = aiff->nsamples;
done = st_rawread(ft, buf, len);
if (done == 0 && aiff->nsamples != 0)
@@ -658,7 +656,7 @@
return done;
}
-int st_aiffstopread(ft_t ft)
+static int st_aiffstopread(ft_t ft)
{
char buf[5];
uint32_t chunksize;
@@ -701,7 +699,7 @@
Strictly spoken this is not legal, but the playaiff utility
will still be able to play the resulting file. */
-int st_aiffstartwrite(ft_t ft)
+static int st_aiffstartwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
@@ -726,7 +724,7 @@
ft->info.encoding = ST_ENCODING_SIGN2;
ft->info.size = ST_SIZE_WORD;
}
- if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
st_report("AIFF only supports signed data. Forcing to signed.");
ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
@@ -739,7 +737,7 @@
return(aiffwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels)));
}
-st_ssize_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
aiff_t aiff = (aiff_t ) ft->priv;
aiff->nsamples += len;
@@ -747,7 +745,7 @@
return(len);
}
-int st_aiffstopwrite(ft_t ft)
+static int st_aiffstopwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
@@ -914,7 +912,7 @@
return(ST_SUCCESS);
}
-int st_aifcstartwrite(ft_t ft)
+static int st_aifcstartwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
@@ -939,7 +937,7 @@
ft->info.encoding = ST_ENCODING_SIGN2;
ft->info.size = ST_SIZE_WORD;
}
- if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
st_report("AIFC only supports signed data. Forcing to signed.");
ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
@@ -952,7 +950,7 @@
return(aifcwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels)));
}
-int st_aifcstopwrite(ft_t ft)
+static int st_aifcstopwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -23,13 +23,13 @@
typedef struct alsa_priv
{
snd_pcm_t *pcm_handle;
- void *buf;
- st_ssize_t buf_size;
+ char *buf;
+ st_size_t buf_size;
} *alsa_priv_t;
static int get_format(ft_t ft, snd_pcm_format_mask_t *fmask, int *fmt);
-int st_alsasetup(ft_t ft, snd_pcm_stream_t mode)
+static int st_alsasetup(ft_t ft, snd_pcm_stream_t mode)
{
int fmt = SND_PCM_FORMAT_S16;
int err;
@@ -85,7 +85,7 @@
snd_pcm_hw_params_get_channels_min(hw_params, &min_chan);
snd_pcm_hw_params_get_channels_max(hw_params, &max_chan);
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = min_chan;
else
if (ft->info.channels > max_chan)
@@ -113,11 +113,8 @@
snd_pcm_hw_params_get_rate_min(hw_params, &min_rate, &dir);
snd_pcm_hw_params_get_rate_max(hw_params, &max_rate, &dir);
- if (min_rate != -1 && rate < min_rate)
- rate = min_rate;
- else
- if (max_rate != -1 && rate > max_rate)
- rate = max_rate;
+ rate = max(rate, min_rate);
+ rate = min(rate, max_rate);
if (rate != ft->info.rate)
{
st_report("alsa: Hardware does not support %d. Forcing sample rate to %d.", ft->info.rate, rate);
@@ -288,12 +285,12 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_alsastartread(ft_t ft)
+static int st_alsastartread(ft_t ft)
{
return st_alsasetup(ft, SND_PCM_STREAM_CAPTURE);
}
-st_ssize_t st_alsaread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_alsaread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
{
st_size_t len;
int err;
@@ -364,8 +361,7 @@
return len;
}
-int st_alsastopread(ft)
-ft_t ft;
+static int st_alsastopread(ft_t ft)
{
alsa_priv_t alsa = (alsa_priv_t)ft->priv;
@@ -376,12 +372,12 @@
return ST_SUCCESS;
}
-int st_alsastartwrite(ft_t ft)
+static int st_alsastartwrite(ft_t ft)
{
return st_alsasetup(ft, SND_PCM_STREAM_PLAYBACK);
}
-st_ssize_t st_alsawrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_alsawrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
{
st_size_t len;
int err;
@@ -452,8 +448,7 @@
}
-int st_alsastopwrite(ft)
-ft_t ft;
+static int st_alsastopwrite(ft_t ft)
{
alsa_priv_t alsa = (alsa_priv_t)ft->priv;
@@ -472,7 +467,7 @@
if (ft->info.size == -1)
ft->info.size = ST_SIZE_WORD;
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
{
if (ft->info.size == ST_SIZE_WORD)
ft->info.encoding = ST_ENCODING_SIGN2;
--- a/src/au.c
+++ b/src/au.c
@@ -107,7 +107,7 @@
return(ST_SUCCESS);
}
-int st_auseek(ft_t ft, st_size_t offset)
+static int st_auseek(ft_t ft, st_size_t offset)
{
au_t au = (au_t ) ft->priv;
@@ -137,7 +137,7 @@
return(ft->st_errno);
}
-int st_austartread(ft_t ft)
+static int st_austartread(ft_t ft)
{
/* The following 6 variables represent a Sun sound header on disk.
The numbers are written as big-endians.
@@ -245,8 +245,8 @@
/* Read the number of channels */
st_readdw(ft, &channels);
- if (ft->info.channels == -1 || ft->info.channels == (int) channels)
- ft->info.channels = (int) channels;
+ if (ft->info.channels == 0 || ft->info.channels == channels)
+ ft->info.channels = channels;
else
st_report("User options overriding channels read in .au header");
@@ -297,7 +297,7 @@
if it is not, the unspecified size remains in the header
(this is legal). */
-int st_austartwrite(ft_t ft)
+static int st_austartwrite(ft_t ft)
{
au_t p = (au_t ) ft->priv;
int rc;
@@ -344,7 +344,7 @@
return (p->in_bits > 0);
}
-st_ssize_t st_auread(ft_t ft, st_sample_t *buf, st_size_t samp)
+static st_size_t st_auread(ft_t ft, st_sample_t *buf, st_size_t samp)
{
au_t p = (au_t ) ft->priv;
unsigned char code;
@@ -362,7 +362,7 @@
return done;
}
-st_ssize_t st_auwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static st_size_t st_auwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
au_t p = (au_t ) ft->priv;
p->data_size += samp * ft->info.size;
@@ -369,7 +369,7 @@
return(st_rawwrite(ft, buf, samp));
}
-int st_austopwrite(ft_t ft)
+static int st_austopwrite(ft_t ft)
{
au_t p = (au_t ) ft->priv;
int rc;
@@ -411,7 +411,7 @@
else if (encoding == ST_ENCODING_FLOAT && size == ST_SIZE_32BIT)
sun_encoding = SUN_FLOAT;
else
- sun_encoding = -1;
+ sun_encoding = ST_ENCODING_UNKNOWN;
return sun_encoding;
}
--- a/src/auto.c
+++ b/src/auto.c
@@ -23,7 +23,7 @@
#define LASTCHAR '/'
#endif
-int st_autostartread(ft_t ft)
+static int st_autostartread(ft_t ft)
{
char *type = NULL;
char header[20];
@@ -179,7 +179,7 @@
return ((* ft->h->startread)(ft));
}
-int st_autostartwrite(ft_t ft)
+static int st_autostartwrite(ft_t ft)
{
st_fail_errno(ft,ST_EFMT,"Type AUTO can only be used for input!");
return(ST_EOF);
--- a/src/avg.c
+++ b/src/avg.c
@@ -50,7 +50,7 @@
/*
* Process options
*/
-int st_avg_getopts(eff_t effp, int n, char **argv)
+static int st_avg_getopts(eff_t effp, int n, char **argv)
{
avg_t avg = (avg_t) effp->priv;
double* pans = &avg->sources[0][0];
@@ -118,7 +118,7 @@
/*
* Start processing
*/
-int st_avg_start(eff_t effp)
+static int st_avg_start(eff_t effp)
{
/*
Hmmm, this is tricky. Lemme think:
@@ -508,7 +508,7 @@
* Process either isamp or osamp samples, whichever is smaller.
*/
-int st_avg_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_avg_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
avg_t avg = (avg_t) effp->priv;
@@ -542,7 +542,7 @@
*
* Should have statistics on right, left, and output amplitudes.
*/
-int st_avg_stop(eff_t effp)
+static int st_avg_stop(eff_t effp UNUSED)
{
return (ST_SUCCESS); /* nothing to do */
}
--- a/src/avr.c
+++ b/src/avr.c
@@ -63,7 +63,7 @@
*/
-int st_avrstartread(ft_t ft)
+static int st_avrstartread(ft_t ft)
{
avr_t avr = (avr_t)ft->priv;
int rc;
@@ -148,7 +148,7 @@
return(ST_SUCCESS);
}
-int st_avrstartwrite(ft_t ft)
+static int st_avrstartwrite(ft_t ft)
{
avr_t avr = (avr_t)ft->priv;
int rc;
@@ -260,7 +260,7 @@
return(ST_SUCCESS);
}
-st_ssize_t st_avrwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_avrwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
{
avr_t avr = (avr_t)ft->priv;
@@ -269,7 +269,7 @@
return (st_rawwrite (ft, buf, nsamp));
}
-int st_avrstopwrite(ft_t ft)
+static int st_avrstopwrite(ft_t ft)
{
avr_t avr = (avr_t)ft->priv;
int rc;
--- a/src/band.c
+++ b/src/band.c
@@ -61,7 +61,7 @@
/*
* Process options
*/
-int st_band_getopts(eff_t effp, int n, char **argv)
+static int st_band_getopts(eff_t effp, int n, char **argv)
{
band_t band = (band_t) effp->priv;
@@ -88,7 +88,7 @@
/*
* Prepare processing.
*/
-int st_band_start(eff_t effp)
+static int st_band_start(eff_t effp)
{
band_t band = (band_t) effp->priv;
if (band->center > effp->ininfo.rate/2)
@@ -135,7 +135,7 @@
* Return number of samples processed.
*/
-int st_band_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_band_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
band_t band = (band_t) effp->priv;
@@ -162,7 +162,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_band_stop(eff_t effp)
+static int st_band_stop(eff_t effp UNUSED)
{
return (ST_SUCCESS); /* nothing to do */
}
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -38,7 +38,7 @@
static st_effect_t st_bandpass_effect;
-int st_bandpass_getopts (eff_t effp, int n, char **argv)
+static int st_bandpass_getopts (eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -61,7 +61,7 @@
return (ST_SUCCESS);
}
-int st_bandpass_start (eff_t effp)
+static int st_bandpass_start(eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
double c;
--- a/src/breject.c
+++ b/src/breject.c
@@ -38,7 +38,7 @@
static st_effect_t st_bandreject_effect;
-int st_bandreject_getopts(eff_t effp, int n, char **argv)
+static int st_bandreject_getopts(eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -61,7 +61,7 @@
return (ST_SUCCESS);
}
-int st_bandreject_start(eff_t effp)
+static int st_bandreject_start(eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
double c;
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -39,7 +39,7 @@
* mono/stereo/quad.
*/
-int st_cdrstartread(ft_t ft)
+static int st_cdrstartread(ft_t ft)
{
int rc;
@@ -78,7 +78,7 @@
* Return number of samples read.
*/
-st_ssize_t st_cdrread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_cdrread(ft_t ft, st_sample_t *buf, st_size_t len)
{
return st_rawread(ft, buf, len);
@@ -88,13 +88,13 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_cdrstopread(ft_t ft)
+static int st_cdrstopread(ft_t ft)
{
/* Needed because of rawread() */
return st_rawstopread(ft);
}
-int st_cdrstartwrite(ft_t ft)
+static int st_cdrstartwrite(ft_t ft)
{
cdr_t cdr = (cdr_t) ft->priv;
int rc;
@@ -121,7 +121,7 @@
return(ST_SUCCESS);
}
-st_ssize_t st_cdrwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_cdrwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
cdr_t cdr = (cdr_t) ft->priv;
@@ -135,7 +135,7 @@
* samples. We write -32768 for each sample to pad it out.
*/
-int st_cdrstopwrite(ft_t ft)
+static int st_cdrstopwrite(ft_t ft)
{
cdr_t cdr = (cdr_t) ft->priv;
int padsamps = SECTORSIZE - (cdr->samples % SECTORSIZE);
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -92,7 +92,7 @@
/*
* Process options
*/
-int st_chorus_getopts(eff_t effp, int n, char **argv)
+static int st_chorus_getopts(eff_t effp, int n, char **argv)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -136,7 +136,7 @@
/*
* Prepare for processing.
*/
-int st_chorus_start(eff_t effp)
+static int st_chorus_start(eff_t effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -254,7 +254,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_chorus_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_chorus_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
@@ -293,7 +293,7 @@
/*
* Drain out reverb lines.
*/
-int st_chorus_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_chorus_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
st_size_t done;
@@ -336,7 +336,7 @@
/*
* Clean up chorus effect.
*/
-int st_chorus_stop(eff_t effp)
+static int st_chorus_stop(eff_t effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
--- a/src/compand.c
+++ b/src/compand.c
@@ -70,7 +70,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_compand_getopts(eff_t effp, int n, char **argv)
+static int st_compand_getopts(eff_t effp, int n, char **argv)
{
compand_t l = (compand_t) effp->priv;
@@ -191,7 +191,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_compand_start(eff_t effp)
+static int st_compand_start(eff_t effp)
{
compand_t l = (compand_t) effp->priv;
int i;
@@ -264,7 +264,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_compand_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_compand_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
@@ -271,7 +271,7 @@
int len = (*isamp > *osamp) ? *osamp : *isamp;
int filechans = effp->outinfo.channels;
int idone,odone;
- int64_t checkbuf; //if st_sample_t of type int32_t
+ int64_t checkbuf; /* if st_sample_t of type int32_t */
for (idone = 0,odone = 0; idone < len; ibuf += filechans) {
int chan;
@@ -326,7 +326,7 @@
{
if (l->delay_buf_cnt >= l->delay_buf_size)
{
- l->delay_buf_full=1; //delay buffer is now definetly full
+ l->delay_buf_full=1; /* delay buffer is now definetly full */
checkbuf = l->delay_buf[l->delay_buf_ptr]*(outv/v)*l->outgain;
ST_SAMPLE_CLIP_COUNT(checkbuf, effp->clippedCount);
obuf[odone] = checkbuf;
@@ -337,7 +337,7 @@
else
{
l->delay_buf_cnt++;
- idone++; //no "odone++" because we did not fill obuf[...]
+ idone++; /* no "odone++" because we did not fill obuf[...] */
}
l->delay_buf[l->delay_buf_ptr++] = ibuf[chan];
l->delay_buf_ptr %= l->delay_buf_size;
@@ -352,7 +352,7 @@
/*
* Drain out compander delay lines.
*/
-int st_compand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_compand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
st_size_t done;
@@ -380,7 +380,7 @@
/*
* Clean up compander effect.
*/
-int st_compand_stop(eff_t effp)
+static int st_compand_stop(eff_t effp)
{
compand_t l = (compand_t) effp->priv;
--- a/src/copy.c
+++ b/src/copy.c
@@ -19,7 +19,7 @@
/*
* Process options
*/
-int st_copy_getopts(eff_t effp, int n, char **argv)
+static int st_copy_getopts(eff_t effp UNUSED, int n, char **argv UNUSED)
{
if (n)
{
@@ -32,11 +32,11 @@
/*
* Start processing
*/
-int st_copy_start(eff_t effp)
+static int st_copy_start(eff_t effp UNUSED)
{
/* nothing to do */
/* stuff data into delaying effects here */
- return (ST_SUCCESS);
+ return (ST_SUCCESS);
}
/*
@@ -45,7 +45,7 @@
* Place in buf[].
* Return number of samples read.
*/
-int st_copy_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_copy_flow(eff_t effp UNUSED, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
int done;
@@ -54,16 +54,6 @@
memcpy(obuf, ibuf, done * sizeof(st_sample_t));
*isamp = *osamp = done;
return (ST_SUCCESS);
-}
-
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_copy_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
}
static st_effect_t st_copy_effect = {
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -153,7 +153,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstartread(ft_t ft)
+static int st_cvsdstartread(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
float *fp1;
@@ -179,7 +179,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstartwrite(ft_t ft)
+static int st_cvsdstartwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
float *fp1;
@@ -201,7 +201,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstopwrite(ft_t ft)
+static int st_cvsdstopwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
@@ -217,8 +217,8 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstopread(ft_t ft)
-{
+static int st_cvsdstopread(ft_t ft)
+{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
st_debug("cvsd: min value %f, max value %f",
@@ -229,10 +229,10 @@
/* ---------------------------------------------------------------------- */
-st_ssize_t st_cvsdread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_cvsdread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
- int done = 0;
+ st_size_t done = 0;
float oval;
while (done < nsamp) {
@@ -288,10 +288,10 @@
/* ---------------------------------------------------------------------- */
-st_ssize_t st_cvsdwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_cvsdwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
- int done = 0;
+ st_size_t done = 0;
float inval;
for(;;) {
@@ -519,7 +519,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstartread(ft_t ft)
+static int st_dvmsstartread(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
struct dvms_header hdr;
@@ -558,7 +558,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstartwrite(ft_t ft)
+static int st_dvmsstartwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
struct dvms_header hdr;
@@ -584,7 +584,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstopwrite(ft_t ft)
+static int st_dvmsstopwrite(ft_t ft)
{
struct dvms_header hdr;
int rc;
--- a/src/dat.c
+++ b/src/dat.c
@@ -1,7 +1,9 @@
-
/*
- * July 5, 1991
- * Copyright 1991 Lance Norskog And Sundry Contributors
+ * Sound Tools text format file. Tom Littlejohn, March 93.
+ *
+ * Reads/writes sound files as text for use with FFT and graph.
+ *
+ * Copyright 1998-2006 Chris Bagwell and SoX Contributors
* This source code is freely redistributable and may be used for
* any purpose. This copyright notice must be maintained.
* Lance Norskog And Sundry Contributors are not responsible for
@@ -8,20 +10,6 @@
* the consequences of using this software.
*/
-/*
- * Sound Tools text format file. Tom Littlejohn, March 93.
- *
- * Reads/writes sound files as text for use with fft and graph.
- *
- * June 28, 93: force output to mono.
- *
- * September 24, 1998: cbagwell - Set up extra output format info so that
- * reports are accurate. Also warn user when forcing to mono.
- *
- * November 25, 2005: tomchristie - Work with multiple channels
- *
- */
-
#include "st_i.h"
#include <string.h>
@@ -34,7 +22,7 @@
char prevline[LINEWIDTH];
} *dat_t;
-int st_datstartread(ft_t ft)
+static int st_datstartread(ft_t ft)
{
char inpstr[LINEWIDTH];
long rate;
@@ -61,7 +49,7 @@
}
/* Default channels to 1 if not found */
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
ft->info.size = ST_SIZE_64BIT;
@@ -70,7 +58,7 @@
return (ST_SUCCESS);
}
-int st_datstartwrite(ft_t ft)
+static int st_datstartwrite(ft_t ft)
{
dat_t dat = (dat_t) ft->priv;
char s[LINEWIDTH];
@@ -88,7 +76,7 @@
return (ST_SUCCESS);
}
-st_ssize_t st_datread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_datread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
{
char inpstr[LINEWIDTH];
int inpPtr = 0;
@@ -96,8 +84,8 @@
double sampval = 0.0;
int retc = 0;
char sc = 0;
- int done = 0;
- int i=0;
+ st_size_t done = 0;
+ st_size_t i=0;
/* Always read a complete set of channels */
nsamp -= (nsamp % ft->info.channels);
@@ -135,13 +123,13 @@
return (done);
}
-st_ssize_t st_datwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static st_size_t st_datwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
{
dat_t dat = (dat_t) ft->priv;
- int done = 0;
+ st_size_t done = 0;
double sampval=0.0;
char s[LINEWIDTH];
- int i=0;
+ st_size_t i=0;
/* Always write a complete set of channels */
nsamp -= (nsamp % ft->info.channels);
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -30,7 +30,7 @@
/*
* Process options: dcshift (double) type (amplitude, power, dB)
*/
-int st_dcshift_getopts(eff_t effp, int n, char **argv)
+static int st_dcshift_getopts(eff_t effp, int n, char **argv)
{
dcs_t dcs = (dcs_t) effp->priv;
dcs->dcshift = 1.0; /* default is no change */
@@ -72,7 +72,7 @@
/*
* Start processing
*/
-int st_dcshift_start(eff_t effp)
+static int st_dcshift_start(eff_t effp)
{
dcs_t dcs = (dcs_t) effp->priv;
@@ -99,7 +99,7 @@
/*
* Process data.
*/
-int st_dcshift_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_dcshift_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
dcs_t dcs = (dcs_t) effp->priv;
@@ -166,7 +166,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_dcshift_stop(eff_t effp)
+static int st_dcshift_stop(eff_t effp)
{
dcs_t dcs = (dcs_t) effp->priv;
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -112,22 +112,6 @@
assert_static(sizeof(struct deemphstuff) <= ST_MAX_EFFECT_PRIVSIZE,
/* else */ deemph_PRIVSIZE_too_big);
-/*
- * Process options
- *
- * Don't do initialization now.
- * The 'info' fields are not yet filled in.
- */
-int st_deemph_getopts(eff_t effp, int n, char **argv)
-{
- if (n)
- {
- st_fail(st_deemph_effect.usage);
- return (ST_EOF);
- }
- return (ST_SUCCESS);
-}
-
/* filter coefficients */
#define a1 -0.62786881719628784282
#define b0 0.45995451989513153057
@@ -137,7 +121,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_deemph_start(eff_t effp)
+static int st_deemph_start(eff_t effp)
{
/* check the input format */
@@ -188,7 +172,7 @@
* Return number of samples processed.
*/
-int st_deemph_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_deemph_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
deemph_t deemph = (deemph_t) effp->priv;
@@ -208,35 +192,15 @@
return (ST_SUCCESS);
}
-/*
- * Drain out remaining samples if the effect generates any.
- */
-
-int st_deemph_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
-{
- /* nothing to do */
- return (ST_EOF);
-}
-
-/*
- * Do anything required when you stop reading samples.
- * (free allocated memory, etc.)
- */
-int st_deemph_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
-}
-
static st_effect_t st_deemph_effect = {
"deemph",
"Usage: Deemphasis filtering effect takes no options",
0,
- st_deemph_getopts,
+ st_effect_nothing_getopts,
st_deemph_start,
st_deemph_flow,
st_effect_nothing_drain,
- st_deemph_stop
+ st_effect_nothing
};
const st_effect_t *st_deemph_effect_fn(void)
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -1,13 +1,4 @@
/*
- * November 9, 2000
- * Copyright (C) 2000 Edward Beingessner And Sundry Contributors
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Edward Beingessner And Sundry Contributors are not responsible for
- * the consequences of using this software.
- */
-
-/*
* earwax - makes listening to headphones easier
*
* This effect takes a stereo sound that is meant to be listened to
@@ -23,7 +14,13 @@
* Note:
* This filter only works for 44.1 kHz stereo signals (cd format)
*
-*/
+ * November 9, 2000
+ * Copyright (C) 2000 Edward Beingessner And Sundry Contributors
+ * This source code is freely redistributable and may be used for
+ * any purpose. This copyright notice must be maintained.
+ * Edward Beingessner And Sundry Contributors are not responsible for
+ * the consequences of using this software.
+ */
#include "st_i.h"
@@ -76,22 +73,9 @@
} *earwax_t;
/*
- * Process options
- */
-int st_earwax_getopts(eff_t effp, int n, char **argv)
-{
- /* no options */
- if (n){
- st_fail(st_earwax_effect.usage);
- return (ST_EOF);
- }
- return (ST_SUCCESS);
-}
-
-/*
* Prepare for processing.
*/
-int st_earwax_start(eff_t effp)
+static int st_earwax_start(eff_t effp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i;
@@ -125,7 +109,7 @@
* Return number of samples processed.
*/
-int st_earwax_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_earwax_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
@@ -157,7 +141,7 @@
/*
* Drain out taps.
*/
-int st_earwax_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_earwax_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i,j;
@@ -178,7 +162,7 @@
/*
* Clean up taps.
*/
-int st_earwax_stop(eff_t effp)
+static int st_earwax_stop(eff_t effp)
{
earwax_t earwax = (earwax_t) effp->priv;
@@ -191,7 +175,7 @@
"earwax",
"Usage: The earwax filtering effect takes no options",
ST_EFF_MCHAN,
- st_earwax_getopts,
+ st_effect_nothing_getopts,
st_earwax_start,
st_earwax_flow,
st_earwax_drain,
--- a/src/echo.c
+++ b/src/echo.c
@@ -82,7 +82,7 @@
/*
* Process options
*/
-int st_echo_getopts(eff_t effp, int n, char **argv)
+static int st_echo_getopts(eff_t effp, int n, char **argv)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -113,7 +113,7 @@
/*
* Prepare for processing.
*/
-int st_echo_start(eff_t effp)
+static int st_echo_start(eff_t effp)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -143,7 +143,7 @@
st_fail("echo: delay must be positive!");
return (ST_EOF);
}
- if ( echo->samples[i] > DELAY_BUFSIZ )
+ if ( echo->samples[i] > (st_ssize_t)DELAY_BUFSIZ )
{
st_fail("echo: delay must be less than %g seconds!",
DELAY_BUFSIZ / (float) effp->ininfo.rate );
@@ -185,7 +185,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_echo_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_echo_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
@@ -222,7 +222,7 @@
/*
* Drain out reverb lines.
*/
-int st_echo_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_echo_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
double d_in, d_out;
@@ -262,7 +262,7 @@
/*
* Clean up reverb effect.
*/
-int st_echo_stop(eff_t effp)
+static int st_echo_stop(eff_t effp)
{
echo_t echo = (echo_t) effp->priv;
--- a/src/echos.c
+++ b/src/echos.c
@@ -52,7 +52,7 @@
static st_effect_t st_echos_effect;
-#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
+#define DELAY_BUFSIZ ( 50 * ST_MAXRATE )
#define MAX_ECHOS 7 /* 24 bit x ( 1 + MAX_ECHOS ) = */
/* 24 bit x 8 = 32 bit !!! */
@@ -72,7 +72,7 @@
/*
* Process options
*/
-int st_echos_getopts(eff_t effp, int n, char **argv)
+static int st_echos_getopts(eff_t effp, int n, char **argv)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -107,7 +107,7 @@
/*
* Prepare for processing.
*/
-int st_echos_start(eff_t effp)
+static int st_echos_start(eff_t effp)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -136,7 +136,7 @@
st_fail("echos: delay must be positive!");
return (ST_EOF);
}
- if ( echos->samples[i] > DELAY_BUFSIZ )
+ if ( echos->samples[i] > (st_ssize_t)DELAY_BUFSIZ )
{
st_fail("echos: delay must be less than %g seconds!",
DELAY_BUFSIZ / (float) effp->ininfo.rate );
@@ -177,7 +177,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_echos_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_echos_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
@@ -220,7 +220,7 @@
/*
* Drain out reverb lines.
*/
-int st_echos_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_echos_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
double d_in, d_out;
@@ -266,7 +266,7 @@
/*
* Clean up echos effect.
*/
-int st_echos_stop(eff_t effp)
+static int st_echos_stop(eff_t effp)
{
echos_t echos = (echos_t) effp->priv;
--- a/src/equalizer.c
+++ b/src/equalizer.c
@@ -55,17 +55,17 @@
/* Filter parameters */
typedef struct filterparams {
- float rate; // Sample rate
- float Q; // Q-factor
- float cfreq; // Central frequency (Hz)
- float gain; // Gain (dB)
- double x[3]; // In where x[2] <=> x[ n - 2 ]
- double y[3]; // Out
- double b[3]; // From this point, equation constants...
+ float rate; /* Sample rate */
+ float Q; /* Q-factor */
+ float cfreq; /* Central frequency (Hz) */
+ float gain; /* Gain (dB) */
+ double x[3]; /* In where x[2] <=> x[ n - 2 ] */
+ double y[3]; /* Out */
+ double b[3]; /* From this point, equation constants... */
double a[3];
} *equalizer_t;
-int st_equalizer_getopts(eff_t effp, int n, char **argv)
+static int st_equalizer_getopts(eff_t effp, int n, char **argv)
{
equalizer_t eq = (equalizer_t) effp->priv;
int i;
@@ -81,13 +81,13 @@
sscanf(argv[i++], "%f", &eq->Q);
sscanf(argv[i++], "%f", &eq->gain);
- // TODO: Would be nice to validate the params..
+ /* FIXME: Would be nice to validate the params.. */
return (ST_SUCCESS);
}
-// Set the filter constants
-int st_equalizer_start(eff_t effp)
+/* Set the filter constants */
+static int st_equalizer_start(eff_t effp)
{
equalizer_t eq = (equalizer_t) effp->priv;
double w0;
@@ -94,7 +94,7 @@
double amp;
double alpha;
- // Sample rate
+ /* Sample rate */
eq->rate = effp->ininfo.rate;
w0 = 2*M_PI*eq->cfreq/eq->rate;
@@ -109,7 +109,7 @@
st_debug("amp: %f", amp);
st_debug("alpha: %f", alpha);
- // Initialisation
+ /* Initialisation */
eq->b[0] = 1 + alpha*amp;
eq->b[1] = -2*cos(w0);
eq->b[2] = 1 - alpha*amp;
@@ -117,12 +117,12 @@
eq->a[1] = -2*cos(w0);
eq->a[2] = 1 - alpha/amp;
- eq->x[0] = 0; // x[n]
- eq->x[1] = 0; // x[n-1]
- eq->x[2] = 0; // x[n-2]
- eq->y[0] = 0; // y[n]
- eq->y[1] = 0; // y[n-1]
- eq->y[2] = 0; // y[n-2]
+ eq->x[0] = 0; /* x[n] */
+ eq->x[1] = 0; /* x[n-1] */
+ eq->x[2] = 0; /* x[n-2] */
+ eq->y[0] = 0; /* y[n] */
+ eq->y[1] = 0; /* y[n-1] */
+ eq->y[2] = 0; /* y[n-2] */
if (effp->globalinfo.octave_plot_effect)
{
@@ -147,7 +147,7 @@
return (ST_SUCCESS);
}
-int st_equalizer_flow(eff_t effp, const st_sample_t *ibuf,
+static int st_equalizer_flow(eff_t effp, const st_sample_t *ibuf,
st_sample_t *obuf, st_size_t *isamp,
st_size_t *osamp)
{
--- a/src/fade.c
+++ b/src/fade.c
@@ -29,7 +29,7 @@
/* Private data for fade file */
typedef struct fadestuff
{ /* These are measured as samples */
- st_size_t in_start, in_stop, out_start, out_stop, samplesdone;
+ st_size_t in_start, in_stop, out_start, out_stop, samplesdone;
char *in_stop_str, *out_start_str, *out_stop_str;
char in_fadetype, out_fadetype;
char do_out;
@@ -46,7 +46,7 @@
* The 'info' fields are not yet filled in.
*/
-int st_fade_getopts(eff_t effp, int n, char **argv)
+static int st_fade_getopts(eff_t effp, int n, char **argv)
{
fade_t fade = (fade_t) effp->priv;
@@ -143,7 +143,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_fade_start(eff_t effp)
+static int st_fade_start(eff_t effp)
{
fade_t fade = (fade_t) effp->priv;
@@ -201,12 +201,11 @@
return(ST_EOF);
} /* endif fade time sanity */
- /* If lead-in is required it is handled as negative sample numbers */
- fade->samplesdone = (fade->in_start < 0 ? fade->in_start :0);
+ fade->samplesdone = fade->in_start;
fade->endpadwarned = 0;
- /* st_debug("fade: in_start = %d in_stop = %d out_start = %d out_stop = %d", fade->in_start, fade->in_stop, fade->out_start, fade->out_stop); */
+ st_debug("fade: in_start = %d in_stop = %d out_start = %d out_stop = %d", fade->in_start, fade->in_stop, fade->out_start, fade->out_stop);
return(ST_SUCCESS);
}
@@ -215,13 +214,14 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_fade_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_fade_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
/* len is total samples, chcnt counts channels */
- int len = 0, chcnt = 0, t_output = 1, more_output = 1;
+ int len = 0, t_output = 1, more_output = 1;
st_sample_t t_ibuf;
+ st_size_t chcnt = 0;
len = ((*isamp > *osamp) ? *osamp : *isamp);
@@ -230,7 +230,7 @@
for(; len && more_output; len--)
{
- t_ibuf = (fade->samplesdone < 0 ? 0 : *ibuf);
+ t_ibuf = *ibuf;
if ((fade->samplesdone >= fade->in_start) &&
(!fade->do_out || fade->samplesdone < fade->out_stop))
@@ -265,14 +265,8 @@
t_output = 0;
} /* endif something to output */
- /* samplesdone < 0 means we are inventing samples right now
- * and so not consuming (happens when in_start < 0).
- */
- if (fade->samplesdone >= 0 )
- { /* Something to input */
- *isamp += 1;
- ibuf++;
- } /* endif something accepted as input */
+ *isamp += 1;
+ ibuf++;
if (t_output)
{ /* Output generated, update pointers and counters */
@@ -301,10 +295,11 @@
/*
* Drain out remaining samples if the effect generates any.
*/
-int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
- int len, t_chan = 0;
+ int len;
+ st_size_t t_chan = 0;
len = *osamp;
*osamp = 0;
@@ -341,7 +336,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-int st_fade_stop(eff_t effp)
+static int st_fade_stop(eff_t effp)
{
fade_t fade = (fade_t) effp->priv;
--- a/src/filter.c
+++ b/src/filter.c
@@ -54,7 +54,7 @@
/*
* Process options
*/
-int st_filter_getopts(eff_t effp, int n, char **argv)
+static int st_filter_getopts(eff_t effp, int n, char **argv)
{
filter_t f = (filter_t) effp->priv;
@@ -104,7 +104,7 @@
/*
* Prepare processing.
*/
-int st_filter_start(eff_t effp)
+static int st_filter_start(eff_t effp)
{
filter_t f = (filter_t) effp->priv;
double *Fp0, *Fp1;
@@ -114,7 +114,7 @@
f->rate = effp->ininfo.rate;
/* adjust upper frequency to Nyquist if necessary */
- if (f->freq1 > f->rate/2 || f->freq1 <= 0)
+ if (f->freq1 > (st_sample_t)f->rate/2 || f->freq1 <= 0)
f->freq1 = f->rate/2;
if ((f->freq0 < 0) || (f->freq0 > f->freq1))
@@ -126,7 +126,7 @@
Xh = f->Nwin/2;
Fp0 = (double *) malloc(sizeof(double) * (Xh + 2)) + 1;
- if (f->freq0 > f->rate/200) {
+ if (f->freq0 > (st_sample_t)f->rate/200) {
Xh0 = makeFilter(Fp0, Xh, 2.0*(double)f->freq0/f->rate, f->beta, 1, 0);
if (Xh0 <= 1)
{
@@ -138,7 +138,7 @@
}
Fp1 = (double *) malloc(sizeof(double) * (Xh + 2)) + 1;
/* need Fp[-1] and Fp[Xh] for makeFilter */
- if (f->freq1 < f->rate/2) {
+ if (f->freq1 < (st_sample_t)f->rate/2) {
Xh1 = makeFilter(Fp1, Xh, 2.0*(double)f->freq1/f->rate, f->beta, 1, 0);
if (Xh1 <= 1)
{
@@ -182,11 +182,11 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_filter_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_filter_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
- long i, Nx, Nproc;
+ st_size_t i, Nx, Nproc;
/* constrain amount we actually process */
/* st_debug("Xh %d, Xt %d, isamp %d, ",f->Xh, f->Xt, *isamp); */
@@ -234,7 +234,7 @@
/*
* Process tail of input samples.
*/
-int st_filter_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_filter_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
long isamp_res, osamp_res;
@@ -271,7 +271,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_filter_stop(eff_t effp)
+static int st_filter_stop(eff_t effp)
{
filter_t f = (filter_t) effp->priv;
--- a/src/flac.c
+++ b/src/flac.c
@@ -58,8 +58,7 @@
}
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
{
- int i;
- int comment_size = 0;
+ size_t i, comment_size = 0;
if (metadata->data.vorbis_comment.num_comments == 0)
{
@@ -176,10 +175,10 @@
}
-static st_ssize_t st_format_read(ft_t const format, st_sample_t * sampleBuffer, st_size_t const requested)
+static st_size_t st_format_read(ft_t const format, st_sample_t * sampleBuffer, st_size_t const requested)
{
Decoder * decoder = (Decoder *) format->priv;
- int actual = 0;
+ size_t actual = 0;
while (!decoder->eof && actual < requested)
{
@@ -247,7 +246,7 @@
-FLAC__StreamEncoderWriteStatus flac_stream_encoder_write_callback(FLAC__StreamEncoder const * const flac, const FLAC__byte buffer[], unsigned const bytes, unsigned const samples, unsigned const current_frame, void * const client_data)
+static FLAC__StreamEncoderWriteStatus flac_stream_encoder_write_callback(FLAC__StreamEncoder const * const flac, const FLAC__byte buffer[], unsigned const bytes, unsigned const samples, unsigned const current_frame, void * const client_data)
{
ft_t const format = (ft_t) client_data;
(void) flac, (void) samples, (void) current_frame;
@@ -257,7 +256,7 @@
-void flac_stream_encoder_metadata_callback(FLAC__StreamEncoder const * encoder, FLAC__StreamMetadata const * metadata, void * client_data)
+static void flac_stream_encoder_metadata_callback(FLAC__StreamEncoder const * encoder, FLAC__StreamMetadata const * metadata, void * client_data)
{
(void) encoder, (void) metadata, (void) client_data;
}
@@ -341,7 +340,7 @@
{ /* Check if rate is streamable: */
static const unsigned streamable_rates[] =
{8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
- int i;
+ size_t i;
bool streamable = false;
for (i = 0; !streamable && i < array_length(streamable_rates); ++i)
{
@@ -356,7 +355,7 @@
if (format->length != 0)
{
- FLAC__stream_encoder_set_total_samples_estimate(encoder->flac, format->length);
+ FLAC__stream_encoder_set_total_samples_estimate(encoder->flac, (FLAC__uint64)format->length);
}
if (format->comment != NULL && * format->comment != '\0')
@@ -423,7 +422,7 @@
-static st_ssize_t st_format_write(ft_t const format, st_sample_t const * const sampleBuffer, st_size_t const len)
+static st_size_t st_format_write(ft_t const format, st_sample_t const * const sampleBuffer, st_size_t const len)
{
Encoder * encoder = (Encoder *) format->priv;
unsigned i;
@@ -439,7 +438,7 @@
}
}
FLAC__stream_encoder_process_interleaved(encoder->flac, encoder->decoded_samples, len / format->info.channels);
- return FLAC__stream_encoder_get_state(encoder->flac) == FLAC__STREAM_ENCODER_OK ? len : -1;
+ return FLAC__stream_encoder_get_state(encoder->flac) == FLAC__STREAM_ENCODER_OK ? len : 0;
}
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -5,38 +5,38 @@
* See LICENSE file for further copyright information.
*/
-static char const st_flanger_usage[] =
- "Usage: \n"
- " .\n"
- " /|regen\n"
- " / |\n"
- " +--( |------------+\n"
- " | \\ | | .\n"
- " _V_ \\| _______ | |\\ width ___\n"
- " | | ' | | | | \\ | |\n"
- " +-->| + |---->| DELAY |--+-->| )----->| |\n"
- " | |___| |_______| | / | |\n"
- " | delay : depth |/ | |\n"
- " In | : interp ' | | Out\n"
- " --->+ __:__ | + |--->\n"
- " | | |speed | |\n"
- " | | ~ |shape | |\n"
- " | |_____|phase | |\n"
- " +------------------------------------->| |\n"
- " |___|\n"
- "\n"
- "Usage: flanger [delay depth regen width speed shape phase interp]\n"
- "\n"
- " RANGE DEFAULT DESCRIPTION\n"
- "delay 0 10 0 base delay in milliseconds\n"
- "depth 0 10 2 added swept delay in milliseconds\n"
- "regen -95 +95 0 percentage regeneration (delayed signal feedback)\n"
- "width 0 100 71 percentage of delayed signal mixed with original\n"
- "speed 0.1 10 0.5 sweeps per second (Hz) \n"
- "shape -- sin swept wave shape: sine|triangle\n"
- "phase 0 100 25 swept wave percentage phase-shift for multi-channel\n"
- " (e.g. stereo) flange; 0 = 100 = same phase on each channel\n"
- "interp -- lin delay-line interpolation: linear|quadratic";
+#define st_flanger_usage \
+ "Usage: \n" \
+ " .\n" \
+ " /|regen\n" \
+ " / |\n" \
+ " +--( |------------+\n" \
+ " | \\ | | .\n" \
+ " _V_ \\| _______ | |\\ width ___\n" \
+ " | | ' | | | | \\ | |\n" \
+ " +-->| + |---->| DELAY |--+-->| )----->| |\n" \
+ " | |___| |_______| | / | |\n" \
+ " | delay : depth |/ | |\n" \
+ " In | : interp ' | | Out\n" \
+ " --->+ __:__ | + |--->\n" \
+ " | | |speed | |\n" \
+ " | | ~ |shape | |\n" \
+ " | |_____|phase | |\n" \
+ " +------------------------------------->| |\n" \
+ " |___|\n" \
+ "\n" \
+ "Usage: flanger [delay depth regen width speed shape phase interp]\n" \
+ "\n" \
+ " RANGE DEFAULT DESCRIPTION\n" \
+ "delay 0 10 0 base delay in milliseconds\n" \
+ "depth 0 10 2 added swept delay in milliseconds\n" \
+ "regen -95 +95 0 percentage regeneration (delayed signal feedback)\n" \
+ "width 0 100 71 percentage of delayed signal mixed with original\n" \
+ "speed 0.1 10 0.5 sweeps per second (Hz) \n" \
+ "shape -- sin swept wave shape: sine|triangle\n" \
+ "phase 0 100 25 swept wave percentage phase-shift for multi-channel\n" \
+ " (e.g. stereo) flange; 0 = 100 = same phase on each channel\n" \
+ "interp -- lin delay-line interpolation: linear|quadratic"
/* TODO: Slide in the delay at the start? */
@@ -88,7 +88,7 @@
static enum_item const interp_enum[] = {
ENUM_ITEM(INTERP_,LINEAR)
ENUM_ITEM(INTERP_,QUADRATIC)
- {0}};
+ {0, 0}};
@@ -121,7 +121,7 @@
-static int st_flanger_getopts(eff_t effp, int argc, char const * const * argv)
+static int st_flanger_getopts(eff_t effp, int argc, char *argv[])
{
flanger_t f = (flanger_t) effp->priv;
--- a/src/g72x.c
+++ b/src/g72x.c
@@ -373,7 +373,7 @@
state_ptr->dq[cnt] = state_ptr->dq[cnt-1];
/* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */
if (mag == 0) {
- state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20;
+ state_ptr->dq[0] = (dq >= 0) ? 0x20 : (short)0xFC20;
} else {
exp = quan(mag, power2, 15);
state_ptr->dq[0] = (dq >= 0) ?
@@ -393,7 +393,7 @@
exp = quan(mag, power2, 15);
state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400;
} else
- state_ptr->sr[0] = 0xFC20;
+ state_ptr->sr[0] = (short)(0xFC20);
/* DELAY A */
state_ptr->pk[1] = state_ptr->pk[0];
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -63,7 +63,7 @@
if (!ft->info.rate)
ft->info.rate = 8000;
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
p->channels = ft->info.channels;
@@ -88,12 +88,12 @@
return (ST_SUCCESS);
}
-int st_gsmstartread(ft_t ft)
+static int st_gsmstartread(ft_t ft)
{
return gsmstart_rw(ft,0);
}
-int st_gsmstartwrite(ft_t ft)
+static int st_gsmstartwrite(ft_t ft)
{
return gsmstart_rw(ft,1);
}
@@ -105,9 +105,9 @@
* Return number of samples read.
*/
-st_ssize_t st_gsmread(ft_t ft, st_sample_t *buf, st_size_t samp)
+static st_size_t st_gsmread(ft_t ft, st_sample_t *buf, st_size_t samp)
{
- int done = 0;
+ size_t done = 0;
int r, ch, chans;
gsm_signal *gbuff;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
@@ -183,9 +183,9 @@
return (ST_SUCCESS);
}
-st_ssize_t st_gsmwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static st_size_t st_gsmwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
- int done = 0;
+ size_t done = 0;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
while (done < samp)
@@ -206,7 +206,7 @@
return done;
}
-int st_gsmstopread(ft_t ft)
+static int st_gsmstopread(ft_t ft)
{
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
int ch;
@@ -219,7 +219,7 @@
return (ST_SUCCESS);
}
-int st_gsmstopwrite(ft_t ft)
+static int st_gsmstopwrite(ft_t ft)
{
int rc;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -37,7 +37,7 @@
st_la_format_fn,
st_lu_format_fn,
st_maud_format_fn,
-#if defined(HAVE_LIBMAD) || defined(HAVE_LAME)
+#if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME)
st_mp3_format_fn,
#endif
st_nul_format_fn,
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -50,7 +50,7 @@
static int skipbytes(ft_t, int);
-int st_hcomstartread(ft_t ft)
+static int st_hcomstartread(ft_t ft)
{
struct readpriv *p = (struct readpriv *) ft->priv;
int i;
@@ -174,7 +174,7 @@
return(ST_SUCCESS);
}
-st_ssize_t st_hcomread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_hcomread(ft_t ft, st_sample_t *buf, st_size_t len)
{
register struct readpriv *p = (struct readpriv *) ft->priv;
int done = 0;
@@ -238,7 +238,7 @@
return done;
}
-int st_hcomstopread(ft_t ft)
+static int st_hcomstopread(ft_t ft)
{
register struct readpriv *p = (struct readpriv *) ft->priv;
@@ -265,7 +265,7 @@
#define BUFINCR (10*BUFSIZ)
-int st_hcomstartwrite(ft_t ft)
+static int st_hcomstartwrite(ft_t ft)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
@@ -302,7 +302,7 @@
return (ST_SUCCESS);
}
-st_ssize_t st_hcomwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_hcomwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
st_sample_t datum;
@@ -514,7 +514,7 @@
/* End of hcom utility routines */
-int st_hcomstopwrite(ft_t ft)
+static int st_hcomstopwrite(ft_t ft)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
unsigned char *compressed_data = p->data;
--- a/src/highp.c
+++ b/src/highp.c
@@ -44,7 +44,7 @@
/*
* Process options
*/
-int st_highp_getopts(eff_t effp, int n, char **argv)
+static int st_highp_getopts(eff_t effp, int n, char **argv)
{
highp_t highp = (highp_t) effp->priv;
@@ -59,7 +59,7 @@
/*
* Prepare processing.
*/
-int st_highp_start(eff_t effp)
+static int st_highp_start(eff_t effp)
{
highp_t highp = (highp_t) effp->priv;
if (highp->cutoff > effp->ininfo.rate/2)
@@ -100,7 +100,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_highp_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_highp_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
highp_t highp = (highp_t) effp->priv;
@@ -125,16 +125,6 @@
return (ST_SUCCESS);
}
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_highp_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
-}
-
static st_effect_t st_highp_effect = {
"highp",
"Usage: highp cutoff",
@@ -143,7 +133,7 @@
st_highp_start,
st_highp_flow,
st_effect_nothing_drain,
- st_highp_stop
+ st_effect_nothing
};
const st_effect_t *st_highp_effect_fn(void)
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -1,5 +1,4 @@
/*
-
High-pass effect file for SoX
Copyright (C) 1999 Jan Paul Schmidt <jps@fundament.org>
@@ -38,7 +37,7 @@
static st_effect_t st_highpass_effect;
-int st_highpass_getopts(eff_t effp, int n, char **argv)
+static int st_highpass_getopts(eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -56,9 +55,7 @@
return (ST_SUCCESS);
}
-
-
-int st_highpass_start(eff_t effp)
+static int st_highpass_start(eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
double c;
--- a/src/ima_rw.c
+++ b/src/ima_rw.c
@@ -164,8 +164,7 @@
const SAMPL *ibuff, /* ibuff[] is interleaved input samples */
int n, /* samples to encode PER channel, REQUIRE n % 8 == 1 */
int *st, /* input/output state, REQUIRE 0 <= *st <= ISSTMAX */
- unsigned char *obuff, /* output buffer[blockAlign], or NULL for no output */
- int sho /* nonzero for debug printout */
+ unsigned char *obuff /* output buffer[blockAlign], or NULL for no output */
)
{
const SAMPL *ip, *itop;
@@ -258,7 +257,6 @@
int snext,d;
int s0,d0;
int s32,d32;
- int sho = 0;
s32 = s0 = *st;
if (opt>0) {
@@ -265,7 +263,7 @@
int low,hi,w;
int low0,hi0;
snext = s0;
- d32 = d0 = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL, sho);
+ d32 = d0 = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL);
w = 0;
low=hi=s0;
@@ -275,7 +273,7 @@
if (!w && low>low0) {
int d;
snext = --low;
- d = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL, sho);
+ d = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL);
if (d<d0) {
d0=d; s0=low;
low0 = low-opt; if (low0<0) low0=0;
@@ -285,7 +283,7 @@
if (w && hi<hi0) {
int d;
snext = ++hi;
- d = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL, sho);
+ d = ImaMashS(ch, chans, ip[0], ip,n,&snext, NULL);
if (d<d0) {
d0=d; s0=hi;
low0 = hi-opt; if (low0<0) low0=0;
@@ -296,7 +294,7 @@
}
*st = s0;
}
- d = ImaMashS(ch, chans, ip[0], ip,n,st, obuff, 0);
+ d = ImaMashS(ch, chans, ip[0], ip,n,st, obuff);
}
/* mash one block. if you want to use opt>0, 9 is a reasonable value */
--- a/src/libgsm/Makefile.in
+++ b/src/libgsm/Makefile.in
@@ -101,6 +101,7 @@
EXEEXT = @EXEEXT@
GETOPT_LONG_FALSE = @GETOPT_LONG_FALSE@
GETOPT_LONG_TRUE = @GETOPT_LONG_TRUE@
+GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -128,9 +129,6 @@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
@@ -141,19 +139,26 @@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
+htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
+localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
+psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
@@ -178,9 +183,9 @@
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/libgsm/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libgsm/Makefile'; \
cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/libgsm/Makefile
+ $(AUTOMAKE) --gnu src/libgsm/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
--- a/src/libgsm/code.c
+++ b/src/libgsm/code.c
@@ -54,21 +54,19 @@
word so[160];
Gsm_Preprocess (S, s, so);
- Gsm_LPC_Analysis (S, so, LARc);
+ Gsm_LPC_Analysis (so, LARc);
Gsm_Short_Term_Analysis_Filter (S, LARc, so);
for (k = 0; k <= 3; k++, xMc += 13) {
- Gsm_Long_Term_Predictor ( S,
- so+k*40, /* d [0..39] IN */
+ Gsm_Long_Term_Predictor (so+k*40, /* d [0..39] IN */
dp, /* dp [-120..-1] IN */
- e + 5, /* e [0..39] OUT */
- dpp, /* dpp [0..39] OUT */
+ e + 5, /* e [0..39] OUT */
+ dpp, /* dpp [0..39] OUT */
Nc++,
bc++);
- Gsm_RPE_Encoding ( S,
- e + 5, /* e ][0..39][ IN/OUT */
+ Gsm_RPE_Encoding ( e + 5, /* e ][0..39][ IN/OUT */
xmaxc++, Mc++, xMc );
/*
* Gsm_Update_of_reconstructed_short_time_residual_signal
--- a/src/libgsm/decode.c
+++ b/src/libgsm/decode.c
@@ -49,7 +49,7 @@
for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) {
- Gsm_RPE_Decoding( S, *xmaxcr, *Mcr, xMcr, erp );
+ Gsm_RPE_Decoding( *xmaxcr, *Mcr, xMcr, erp );
Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp );
for (k = 0; k <= 39; k++) wt[ j * 40 + k ] = drp[ k ];
--- a/src/libgsm/long_term.c
+++ b/src/libgsm/long_term.c
@@ -198,9 +198,6 @@
}
void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */
-
- struct gsm_state * S,
-
word * d, /* [0..39] residual signal IN */
word * dp, /* [-120..-1] d' IN */
--- a/src/libgsm/lpc.c
+++ b/src/libgsm/lpc.c
@@ -269,7 +269,6 @@
}
void Gsm_LPC_Analysis (
- struct gsm_state *S,
word * s, /* 0..159 signals IN/OUT */
word * LARc) /* 0..7 LARc's OUT */
{
--- a/src/libgsm/preprocess.c
+++ b/src/libgsm/preprocess.c
@@ -90,7 +90,7 @@
L_s2 += GSM_MULT_R( lsp, 32735 );
L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
- L_z2 = GSM_L_ADD( L_temp, L_s2 );
+ L_z2 = GSM_L_ADD( L_temp, L_s2 );
/* Compute sof[k] with rounding
*/
--- a/src/libgsm/private.h
+++ b/src/libgsm/private.h
@@ -86,7 +86,7 @@
>= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \
: ((b) <= 0 ? (a) + (b) \
: (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \
- ? MAX_LONGWORD : utmp))
+ ? MAX_LONGWORD : (longword)utmp))
#define GSM_ADD(a, b) \
((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \
@@ -112,7 +112,6 @@
word * xMc /* [13*4] normalized RPE samples OUT */);
extern void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */
- struct gsm_state * S,
word * d, /* [0..39] residual signal IN */
word * dp, /* [-120..-1] d' IN */
word * e, /* [0..40] OUT */
@@ -121,7 +120,6 @@
word * bc /* gain factor OUT */);
extern void Gsm_LPC_Analysis (
- struct gsm_state * S,
word * s, /* 0..159 signals IN/OUT */
word * LARc); /* 0..7 LARc's OUT */
@@ -167,7 +165,6 @@
word * drp); /* [-120..-1] IN, [0..40] OUT */
void Gsm_RPE_Decoding (
- struct gsm_state *S,
word xmaxcr,
word Mcr,
word * xMcr, /* [0..12], 3 bits IN */
@@ -174,7 +171,6 @@
word * erp); /* [0..39] OUT */
void Gsm_RPE_Encoding (
- struct gsm_state * S,
word * e, /* -5..-1][0..39][40..44 IN/OUT */
word * xmaxc, /* OUT */
word * Mc, /* OUT */
--- a/src/libgsm/rpe.c
+++ b/src/libgsm/rpe.c
@@ -430,9 +430,6 @@
#endif /* Has been inlined in code.c */
void Gsm_RPE_Encoding (
-
- struct gsm_state * S,
-
word * e, /* -5..-1][0..39][40..44 IN/OUT */
word * xmaxc, /* OUT */
word * Mc, /* OUT */
@@ -453,8 +450,6 @@
}
void Gsm_RPE_Decoding (
- struct gsm_state * S,
-
word xmaxcr,
word Mcr,
word * xMcr, /* [0..12], 3 bits IN */
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -42,7 +42,7 @@
/*
* Process options
*/
-int st_lowp_getopts(eff_t effp, int n, char **argv)
+static int st_lowp_getopts(eff_t effp, int n, char **argv)
{
lowp_t lowp = (lowp_t) effp->priv;
@@ -57,7 +57,7 @@
/*
* Prepare processing.
*/
-int st_lowp_start(eff_t effp)
+static int st_lowp_start(eff_t effp)
{
lowp_t lowp = (lowp_t) effp->priv;
if (lowp->cutoff > effp->ininfo.rate / 2)
@@ -96,7 +96,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_lowp_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_lowp_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
lowp_t lowp = (lowp_t) effp->priv;
@@ -118,16 +118,6 @@
return (ST_SUCCESS);
}
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_lowp_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
-}
-
static st_effect_t st_lowp_effect = {
"lowp",
"Usage: lowp cutoff",
@@ -136,7 +126,7 @@
st_lowp_start,
st_lowp_flow,
st_effect_nothing_drain,
- st_lowp_stop
+ st_effect_nothing
};
const st_effect_t *st_lowp_effect_fn(void)
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -26,7 +26,7 @@
static st_effect_t st_lowpass_effect;
-int st_lowpass_getopts(eff_t effp, int n, char **argv)
+static int st_lowpass_getopts(eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -44,7 +44,7 @@
return (ST_SUCCESS);
}
-int st_lowpass_start(eff_t effp)
+static int st_lowpass_start(eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
double c;
--- a/src/mask.c
+++ b/src/mask.c
@@ -29,7 +29,7 @@
/*
* Process options
*/
-int st_mask_getopts(eff_t effp, int n, char **argv)
+static int st_mask_getopts(eff_t effp UNUSED, int n, char **argv UNUSED)
{
if (n)
{
@@ -46,7 +46,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_mask_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_mask_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
int len, done;
--- a/src/maud.c
+++ b/src/maud.c
@@ -1,6 +1,9 @@
/*
- * July 5, 1991
- * Copyright 1991 Lance Norskog And Sundry Contributors
+ * Sound Tools MAUD file format driver, by Lutz Vieweg 1993
+ *
+ * supports: mono and stereo, linear, a-law and u-law reading and writing
+ *
+ * Copyright 1998-2006 Chris Bagwell and SoX Contributors
* This source code is freely redistributable and may be used for
* any purpose. This copyright notice must be maintained.
* Lance Norskog And Sundry Contributors are not responsible for
@@ -7,16 +10,6 @@
* the consequences of using this software.
*/
-/*
- * Sound Tools MAUD file format driver, by Lutz Vieweg 1993
- *
- * supports: mono and stereo, linear, a-law and u-law reading and writing
- *
- * March 3, 1999 - cbagwell
- * Changed to use rawread for reading.
- *
- */
-
#include "st_i.h"
#include <string.h>
#include <stdlib.h>
@@ -40,7 +33,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_maudstartread(ft_t ft)
+static int st_maudstartread(ft_t ft)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
@@ -218,30 +211,8 @@
return(ST_SUCCESS);
}
-/*
- * Read up to len samples from file.
- * Convert to signed longs.
- * Place in buf[].
- * Return number of samples read.
- */
-
-st_ssize_t st_maudread(ft_t ft, st_sample_t *buf, st_size_t len)
+static int st_maudstartwrite(ft_t ft)
{
- return (st_rawread(ft, buf, len));
-}
-
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_maudstopread(ft_t ft)
-{
- /* Needed because of rawread() */
- return st_rawstopread(ft);
-}
-
-int st_maudstartwrite(ft_t ft)
-{
struct maudstuff * p = (struct maudstuff *) ft->priv;
int rc;
@@ -282,7 +253,7 @@
return (ST_SUCCESS);
}
-st_ssize_t st_maudwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_maudwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
@@ -291,7 +262,7 @@
return st_rawwrite(ft, buf, len);
}
-int st_maudstopwrite(ft_t ft)
+static int st_maudstopwrite(ft_t ft)
{
int rc;
@@ -401,8 +372,8 @@
NULL,
ST_FILE_STEREO,
st_maudstartread,
- st_maudread,
- st_maudstopread,
+ st_rawread,
+ st_rawstopread,
st_maudstartwrite,
st_maudwrite,
st_maudstopwrite,
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -199,7 +199,7 @@
}
typedef struct comp_band {
- int expectedChannels; /* Also flags that channels aren't to be treated
+ st_size_t expectedChannels; /* Also flags that channels aren't to be treated
individually when = 1 and input not mono */
int transferPoints; /* Number of points specified on the transfer
function */
@@ -213,9 +213,9 @@
double topfreq; /* upper bound crossover frequency */
struct butterworth_crossover filter;
st_sample_t *delay_buf; /* Old samples, used for delay processing */
- st_ssize_t delay_size; /* lookahead for this band (in samples) - function of delay, above */
+ st_size_t delay_size; /* lookahead for this band (in samples) - function of delay, above */
st_ssize_t delay_buf_ptr; /* Index into delay_buf */
- st_ssize_t delay_buf_cnt; /* No. of active entries in delay_buf */
+ st_size_t delay_buf_cnt; /* No. of active entries in delay_buf */
} *comp_band_t;
typedef struct {
@@ -235,7 +235,7 @@
static int st_mcompand_getopts_1(comp_band_t l, int n, char **argv)
{
char *s;
- int rates, tfers, i, commas;
+ st_size_t rates, tfers, i, commas;
/* Start by checking the attack and decay rates */
@@ -379,7 +379,7 @@
return ST_SUCCESS;
}
-int st_mcompand_getopts(eff_t effp, int n, char **argv)
+static int st_mcompand_getopts(eff_t effp, int n, char **argv)
{
char *subargv[6], *cp;
int subargc, i, len;
@@ -431,11 +431,12 @@
* Prepare processing.
* Do all initializations.
*/
-int st_mcompand_start(eff_t effp)
+static int st_mcompand_start(eff_t effp)
{
compand_t c = (compand_t) effp->priv;
comp_band_t l;
- int band, i;
+ st_size_t i;
+ int band;
for (band=0;band<c->nBands;++band) {
l = &c->bands[band];
@@ -573,7 +574,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_mcompand_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_mcompand_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp) {
compand_t c = (compand_t) effp->priv;
comp_band_t l;
@@ -628,7 +629,7 @@
return ST_SUCCESS;
}
-static int st_mcompand_drain_1(eff_t effp, compand_t c, comp_band_t l, st_sample_t *obuf, int maxdrain, int band)
+static int st_mcompand_drain_1(eff_t effp, compand_t c, comp_band_t l, st_sample_t *obuf, int maxdrain)
{
int done;
double out;
@@ -652,7 +653,7 @@
/*
* Drain out compander delay lines.
*/
-int st_mcompand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_mcompand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
int band, drained, mostdrained = 0;
compand_t c = (compand_t)effp->priv;
@@ -661,7 +662,7 @@
memset(obuf,0,*osamp * sizeof *obuf);
for (band=0;band<c->nBands;++band) {
l = &c->bands[band];
- drained = st_mcompand_drain_1(effp, c,l,obuf,*osamp,0);
+ drained = st_mcompand_drain_1(effp, c,l,obuf,*osamp);
if (drained > mostdrained)
mostdrained = drained;
}
@@ -677,7 +678,7 @@
/*
* Clean up compander effect.
*/
-int st_mcompand_stop(eff_t effp)
+static int st_mcompand_stop(eff_t effp)
{
compand_t c = (compand_t) effp->priv;
comp_band_t l;
--- a/src/misc.c
+++ b/src/misc.c
@@ -15,6 +15,7 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stddef.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
@@ -83,16 +84,16 @@
* Returns number of elements read, not bytes read.
*/
-st_ssize_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len)
+size_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len)
{
return fread(buf, size, len, ft->fp);
}
/* Write a buffer of data of length len and each element is size bytes.
- * Returns number of elements writen, not bytes writen.
+ * Returns number of elements writen, not bytes written.
*/
-st_ssize_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len)
+size_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len)
{
return fwrite(buf, size, len, ft->fp);
}
@@ -157,13 +158,11 @@
return (ST_EOF);
}
if (in == 0 || in == '\n')
- {
break;
- }
*sc = in;
sc++;
- } while (sc - c < len);
+ } while (sc - c < (ptrdiff_t)len);
*sc = 0;
return(ST_SUCCESS);
}
@@ -306,7 +305,7 @@
}
/* generic swap routine. Swap l and place in to f (datatype length = n) */
-void st_swapb(char *l, char *f, int n)
+static void st_swapb(char *l, char *f, int n)
{
register int i;
@@ -358,18 +357,28 @@
/* dummy format routines for do-nothing functions */
-int st_format_nothing(ft_t ft) { return(ST_SUCCESS); }
-st_ssize_t st_format_nothing_read_io(ft_t ft, st_sample_t *buf, st_size_t len) { return(0); }
-st_ssize_t st_format_nothing_write_io(ft_t ft, const st_sample_t *buf, st_size_t len) { return(0); }
-int st_format_nothing_seek(ft_t ft, st_size_t offset) { st_fail_errno(ft, ST_ENOTSUP, "operation not supported"); return(ST_EOF); }
+int st_format_nothing(ft_t ft UNUSED) { return(ST_SUCCESS); }
+st_size_t st_format_nothing_read_io(ft_t ft UNUSED, st_sample_t *buf UNUSED, st_size_t len UNUSED) { return(0); }
+st_size_t st_format_nothing_write_io(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t len UNUSED) { return(0); }
+int st_format_nothing_seek(ft_t ft UNUSED, st_size_t offset UNUSED) { st_fail_errno(ft, ST_ENOTSUP, "operation not supported"); return(ST_EOF); }
/* dummy effect routine for do-nothing functions */
-int st_effect_nothing(eff_t effp) { return(ST_SUCCESS); }
-int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+int st_effect_nothing(eff_t effp UNUSED) { return(ST_SUCCESS); }
+int st_effect_nothing_drain(eff_t effp UNUSED, st_sample_t *obuf UNUSED, st_size_t *osamp)
{ /* Inform no more samples to drain */ *osamp = 0; return(ST_EOF); }
+int st_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED)
+{
+ if (n) {
+ st_fail(effp->h->usage);
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
+}
+
+
/* here for linear interp. might be useful for other things */
-st_sample_t st_gcd(st_sample_t a, st_sample_t b)
+REGPARM(2) st_sample_t st_gcd(st_sample_t a, st_sample_t b)
{
if (b == 0)
return a;
@@ -377,7 +386,7 @@
return st_gcd(b, a % b);
}
-st_sample_t st_lcm(st_sample_t a, st_sample_t b)
+REGPARM(2) st_sample_t st_lcm(st_sample_t a, st_sample_t b)
{
/* parenthesize this way to avoid st_sample_t overflow in product term */
return a * (b / st_gcd(a, b));
@@ -429,7 +438,7 @@
void st_generate_wave_table(
st_wave_t wave_type,
st_data_t data_type,
- void * table,
+ void *table,
uint32_t table_size,
double min,
double max,
@@ -457,19 +466,47 @@
case 3: d = d - 1.5; break;
}
break;
+
+ default: /* Oops! FIXME */
+ d = 0.0; /* Make sure we have a value */
+ break;
}
d = d * (max - min) + min;
switch (data_type)
{
- case ST_FLOAT : *(float *)table = d; table += sizeof(float ); continue;
- case ST_DOUBLE: *(double *)table = d; table += sizeof(double); continue;
+ case ST_FLOAT:
+ {
+ float *fp = (float *)table;
+ *fp++ = (float)d;
+ table = fp;
+ continue;
+ }
+ case ST_DOUBLE:
+ {
+ double *dp = (double *)table;
+ *dp++ = d;
+ table = dp;
+ continue;
+ }
default: break;
}
d += d < 0? -0.5 : +0.5;
switch (data_type)
{
- case ST_SHORT : *(short *)table = d; table += sizeof(short ); continue;
- case ST_INT : *(int *)table = d; table += sizeof(int ); continue;
+ case ST_SHORT:
+ {
+ short *sp = table;
+ *sp++ = (short)d;
+ table = sp;
+ continue;
+ }
+ case ST_INT:
+ {
+ int *ip = table;
+ *ip++ = (int)d;
+ table = ip;
+ continue;
+ }
default: break;
}
}
@@ -542,5 +579,5 @@
enum_item const st_wave_enum[] = {
ENUM_ITEM(ST_WAVE_,SINE)
ENUM_ITEM(ST_WAVE_,TRIANGLE)
- {0}};
+ {0, 0}};
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -14,13 +14,13 @@
#include <string.h>
-#if defined(HAVE_LIBMAD) || defined(HAVE_LAME)
+#if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME)
#ifdef HAVE_LIBMAD
#include <mad.h>
#endif
-#ifdef HAVE_LAME
+#ifdef HAVE_LIBMP3LAME
#include <lame/lame.h>
#include <math.h>
#endif
@@ -38,9 +38,9 @@
st_ssize_t cursamp;
st_size_t FrameCount;
#endif /*HAVE_LIBMAD*/
-#ifdef HAVE_LAME
+#ifdef HAVE_LIBMP3LAME
lame_global_flags *gfp;
-#endif /*HAVE_LAME*/
+#endif /*HAVE_LIBMP3LAME*/
};
#ifdef HAVE_LIBMAD
@@ -159,7 +159,7 @@
return rc;
}
-int st_mp3startread(ft_t ft)
+static int st_mp3startread(ft_t ft)
{
struct mp3priv *p = (struct mp3priv *) ft->priv;
size_t ReadSize;
@@ -279,12 +279,12 @@
* Place in buf[].
* Return number of samples read.
*/
-st_ssize_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len)
{
struct mp3priv *p = (struct mp3priv *) ft->priv;
- st_ssize_t donow,i,done=0;
+ st_size_t donow,i,done=0;
mad_fixed_t sample;
- int chan;
+ size_t chan;
do {
donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels);
@@ -342,7 +342,7 @@
return done;
}
-int st_mp3stopread(ft_t ft)
+static int st_mp3stopread(ft_t ft)
{
struct mp3priv *p=(struct mp3priv*) ft->priv;
@@ -359,7 +359,7 @@
return ST_SUCCESS;
}
#else /*HAVE_LIBMAD*/
-int st_mp3startread(ft_t ft)
+static int st_mp3startread(ft_t ft)
{
st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support");
return ST_EOF;
@@ -378,17 +378,18 @@
}
#endif /*HAVE_LIBMAD*/
-#ifdef HAVE_LAME
-void null_error_func(const char* string, va_list va){
+#ifdef HAVE_LIBMP3LAME
+static void null_error_func(const char* string UNUSED, va_list va UNUSED)
+{
return;
}
-int st_mp3startwrite(ft_t ft)
+static int st_mp3startwrite(ft_t ft)
{
struct mp3priv *p = (struct mp3priv *) ft->priv;
- if (ft->info.encoding != ST_ENCODING_MP3){
- if(ft->info.encoding != -1)
+ if (ft->info.encoding != ST_ENCODING_MP3) {
+ if(ft->info.encoding != ST_ENCODING_UNKNOWN)
st_report("Encoding forced to MP3");
ft->info.encoding = ST_ENCODING_MP3;
}
@@ -399,7 +400,7 @@
return(ST_EOF);
}
- if (ft->info.channels != -1){
+ if (ft->info.channels != ST_ENCODING_UNKNOWN) {
if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) {
st_fail_errno(ft,ST_EOF,"Unsupported number of channels");
return(ST_EOF);
@@ -431,16 +432,16 @@
return(ST_SUCCESS);
}
-st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static st_size_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
struct mp3priv *p = (struct mp3priv *)ft->priv;
char *mp3buffer;
- int mp3buffer_size;
+ st_size_t mp3buffer_size;
short signed int *buffer_l, *buffer_r = NULL;
int nsamples = samp/ft->info.channels;
int i,j;
st_ssize_t done = 0;
- int written;
+ st_size_t written;
/* NOTE: This logic assumes that "short int" is 16-bits
* on all platforms. It happens to be for all that I know
@@ -504,7 +505,7 @@
if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r,
nsamples, (unsigned char *)mp3buffer,
- mp3buffer_size)) < 0){
+ mp3buffer_size)) < mp3buffer_size){
st_fail_errno(ft,ST_EOF,"Encoding failed");
goto end;
}
@@ -528,7 +529,7 @@
return done;
}
-int st_mp3stopwrite(ft_t ft)
+static int st_mp3stopwrite(ft_t ft)
{
struct mp3priv *p = (struct mp3priv *) ft->priv;
char mp3buffer[7200];
@@ -537,7 +538,7 @@
if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){
st_fail_errno(ft,ST_EOF,"Encoding failed");
}
- else if (st_writebuf(ft, mp3buffer, 1, written) < written){
+ else if ((int)st_writebuf(ft, mp3buffer, 1, written) < written){
st_fail_errno(ft,ST_EOF,"File write failed");
}
@@ -545,25 +546,25 @@
return ST_SUCCESS;
}
-#else /* HAVE_LAME */
-int st_mp3startwrite(ft_t ft)
+#else /* HAVE_LIBMP3LAME */
+static int st_mp3startwrite(ft_t ft UNUSED)
{
- st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support");
+ st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
return ST_EOF;
}
-st_ssize_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static st_size_t st_mp3write(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t samp UNUSED)
{
- st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support");
- return ST_EOF;
+ st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
+ return 0;
}
-int st_mp3stopwrite(ft_t ft)
+static int st_mp3stopwrite(ft_t ft)
{
- st_fail_errno(ft,ST_EOF,"Sorry, no MP3 encoding support");
+ st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
return ST_EOF;
}
-#endif /* HAVE_LAME */
+#endif /* HAVE_LIBMP3LAME */
/* MP3 */
static const char *mp3names[] = {
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -39,7 +39,7 @@
/*
* Get the filename, if any. We don't open it until st_noiseprof_start.
*/
-int st_noiseprof_getopts(eff_t effp, int n, char **argv)
+static int st_noiseprof_getopts(eff_t effp, int n, char **argv)
{
profdata_t data = (profdata_t) effp->priv;
@@ -57,7 +57,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_noiseprof_start(eff_t effp)
+static int st_noiseprof_start(eff_t effp)
{
profdata_t data = (profdata_t) effp->priv;
int channels = effp->ininfo.channels;
@@ -88,7 +88,7 @@
}
/* Collect statistics from the complete window on channel chan. */
-static void collect_data(profdata_t data, chandata_t* chan) {
+static void collect_data(chandata_t* chan) {
float *out = (float*)calloc(FREQCOUNT, sizeof(float));
int i;
@@ -109,13 +109,13 @@
/*
* Grab what we can from ibuf, and process if we have a whole window.
*/
-int st_noiseprof_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_noiseprof_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
profdata_t data = (profdata_t) effp->priv;
int samp = min(*isamp, *osamp);
int tracks = effp->ininfo.channels;
- int track_samples = samp / tracks;
+ st_size_t track_samples = samp / tracks;
int ncopy = 0;
int i;
@@ -133,7 +133,7 @@
ST_SAMPLE_TO_FLOAT_DWORD(ibuf[i+j*tracks], effp->clippedCount);
}
if (ncopy + data->bufdata == WINDOWSIZE) {
- collect_data(data, chan);
+ collect_data(chan);
}
}
@@ -152,7 +152,7 @@
* Finish off the last window.
*/
-int st_noiseprof_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_noiseprof_drain(eff_t effp, st_sample_t *obuf UNUSED, st_size_t *osamp)
{
profdata_t data = (profdata_t) effp->priv;
int tracks = effp->ininfo.channels;
@@ -169,7 +169,7 @@
for (j = data->bufdata+1; j < WINDOWSIZE; j ++) {
data->chandata[i].window[j] = 0;
}
- collect_data(data, &(data->chandata[i]));
+ collect_data(&(data->chandata[i]));
}
if (data->bufdata == WINDOWSIZE || data->bufdata == 0)
@@ -181,10 +181,10 @@
/*
* Print profile and clean up.
*/
-int st_noiseprof_stop(eff_t effp)
+static int st_noiseprof_stop(eff_t effp)
{
profdata_t data = (profdata_t) effp->priv;
- int i;
+ st_size_t i;
for (i = 0; i < effp->ininfo.channels; i ++) {
int j;
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -38,7 +38,7 @@
* Get the options. Filename is mandatory, though a reasonable default would
* be stdin (if the input file isn't coming from there, of course!)
*/
-int st_noisered_getopts(eff_t effp, int n, char **argv)
+static int st_noisered_getopts(eff_t effp, int n, char **argv)
{
reddata_t data = (reddata_t) effp->priv;
@@ -67,7 +67,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_noisered_start(eff_t effp)
+static int st_noisered_start(eff_t effp)
{
reddata_t data = (reddata_t) effp->priv;
int fchannels = 0;
@@ -245,17 +245,17 @@
/*
* Read in windows, and call process_window once we get a whole one.
*/
-int st_noisered_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_noisered_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
reddata_t data = (reddata_t) effp->priv;
- int samp = min(*isamp, *osamp);
- int tracks = effp->ininfo.channels;
- int track_samples = samp / tracks;
- int ncopy = min(track_samples, WINDOWSIZE-data->bufdata);
- int whole_window = (ncopy + data->bufdata == WINDOWSIZE);
+ st_size_t samp = min(*isamp, *osamp);
+ st_size_t tracks = effp->ininfo.channels;
+ st_size_t track_samples = samp / tracks;
+ st_size_t ncopy = min(track_samples, WINDOWSIZE-data->bufdata);
+ st_size_t whole_window = (ncopy + data->bufdata == WINDOWSIZE);
int oldbuf = data->bufdata;
- int i;
+ st_size_t i;
assert(effp->ininfo.channels == effp->outinfo.channels);
if (whole_window) {
@@ -267,7 +267,7 @@
/* Reduce noise on every channel. */
for (i = 0; i < tracks; i ++) {
chandata_t* chan = &(data->chandata[i]);
- int j;
+ st_size_t j;
if (chan->window == NULL) {
chan->window = (float*)calloc(WINDOWSIZE, sizeof(float));
}
@@ -298,7 +298,7 @@
* We have up to half a window left to dump.
*/
-int st_noisered_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_noisered_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
reddata_t data = (reddata_t)effp->priv;
int i;
@@ -315,10 +315,10 @@
/*
* Clean up.
*/
-int st_noisered_stop(eff_t effp)
+static int st_noisered_stop(eff_t effp)
{
reddata_t data = (reddata_t) effp->priv;
- int i;
+ st_size_t i;
for (i = 0; i < effp->ininfo.channels; i ++) {
chandata_t* chan = &(data->chandata[i]);
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -17,19 +17,19 @@
#include "st_i.h"
#include <string.h>
-int st_nulstartread(ft_t ft)
+static int st_nulstartread(ft_t ft)
{
/* If format parameters are not given, set somewhat arbitrary
* (but commonly used) defaults: */
if (ft->info.rate == 0) ft->info.rate = 44100;
- if (ft->info.channels == -1) ft->info.channels = 2;
+ if (ft->info.channels == 0) ft->info.channels = 2;
if (ft->info.size == -1) ft->info.size = ST_SIZE_WORD;
- if (ft->info.encoding == -1) ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN) ft->info.encoding = ST_ENCODING_SIGN2;
return ST_SUCCESS;
}
-st_ssize_t st_nulread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_nulread(ft_t ft UNUSED, st_sample_t *buf, st_size_t len)
{
/* Reading from null generates silence i.e. (st_sample_t)0. */
memset(buf, 0, sizeof(st_sample_t) * len);
@@ -36,7 +36,7 @@
return len; /* Return number of samples "read". */
}
-st_ssize_t st_nulwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_nulwrite(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t len)
{
/* Writing to null just discards the samples */
return len; /* Return number of samples "written". */
--- a/src/oss.c
+++ b/src/oss.c
@@ -51,7 +51,7 @@
if (ft->info.size == ST_SIZE_BYTE) {
sampletype = AFMT_U8;
samplesize = 8;
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_UNSIGNED;
if (ft->info.encoding != ST_ENCODING_UNSIGNED) {
st_report("OSS driver only supports unsigned with bytes");
@@ -62,7 +62,7 @@
else if (ft->info.size == ST_SIZE_WORD) {
sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
samplesize = 16;
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_SIGN2;
if (ft->info.encoding != ST_ENCODING_SIGN2) {
st_report("OSS driver only supports signed with words");
@@ -79,7 +79,7 @@
st_report("Forcing to signed linear word");
}
- if (ft->info.channels == -1) ft->info.channels = 1;
+ if (ft->info.channels == 0) ft->info.channels = 1;
else if (ft->info.channels > 2) ft->info.channels = 2;
if (ioctl(fileno(ft->fp), SNDCTL_DSP_RESET, 0) < 0)
@@ -204,7 +204,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_ossdspstartread(ft_t ft)
+static int st_ossdspstartread(ft_t ft)
{
int rc;
rc = ossdspinit(ft);
@@ -211,7 +211,7 @@
return rc;
}
-int st_ossdspstartwrite(ft_t ft)
+static int st_ossdspstartwrite(ft_t ft)
{
return ossdspinit(ft);
}
--- a/src/pan.c
+++ b/src/pan.c
@@ -30,7 +30,7 @@
/*
* Process options
*/
-int st_pan_getopts(eff_t effp, int n, char **argv)
+static int st_pan_getopts(eff_t effp, int n, char **argv)
{
pan_t pan = (pan_t) effp->priv;
@@ -49,7 +49,7 @@
/*
* Start processing
*/
-int st_pan_start(eff_t effp)
+static int st_pan_start(eff_t effp)
{
if (effp->outinfo.channels==1)
st_warn("PAN onto a mono channel...");
@@ -73,7 +73,7 @@
/*
* Process either isamp or osamp samples, whichever is smaller.
*/
-int st_pan_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_pan_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
pan_t pan = (pan_t) effp->priv;
@@ -408,15 +408,8 @@
}
/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- *
- * Should have statistics on right, left, and output amplitudes.
+ * FIXME: Add a stop function with statistics on right, left, and output amplitudes.
*/
-int st_pan_stop(eff_t effp)
-{
- return ST_SUCCESS;
-}
static st_effect_t st_pan_effect = {
"pan",
@@ -426,7 +419,7 @@
st_pan_start,
st_pan_flow,
st_effect_nothing_drain,
- st_pan_stop
+ st_effect_nothing
};
const st_effect_t *st_pan_effect_fn(void)
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -81,7 +81,7 @@
/*
* Process options
*/
-int st_phaser_getopts(eff_t effp, int n, char **argv)
+static int st_phaser_getopts(eff_t effp, int n, char **argv)
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -114,7 +114,7 @@
/*
* Prepare for processing.
*/
-int st_phaser_start(eff_t effp)
+static int st_phaser_start(eff_t effp)
{
phaser_t phaser = (phaser_t) effp->priv;
unsigned int i;
@@ -192,7 +192,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_phaser_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_phaser_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -227,7 +227,7 @@
/*
* Drain out reverb lines.
*/
-int st_phaser_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_phaser_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
st_size_t done;
@@ -266,7 +266,7 @@
/*
* Clean up phaser effect.
*/
-int st_phaser_stop(eff_t effp)
+static int st_phaser_stop(eff_t effp)
{
phaser_t phaser = (phaser_t) effp->priv;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -246,7 +246,7 @@
/*
* Process options
*/
-int st_pitch_getopts(eff_t effp, int n, char **argv)
+static int st_pitch_getopts(eff_t effp, int n, char **argv)
{
pitch_t pitch = (pitch_t) effp->priv;
@@ -329,7 +329,7 @@
/*
* Start processing
*/
-int st_pitch_start(eff_t effp)
+static int st_pitch_start(eff_t effp)
{
pitch_t pitch = (pitch_t) effp->priv;
register int sample_rate = effp->outinfo.rate;
@@ -445,7 +445,7 @@
/* Processes input.
*/
-int st_pitch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_pitch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
@@ -522,7 +522,7 @@
/* at the end...
*/
-int st_pitch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_pitch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
st_size_t i;
@@ -566,7 +566,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_pitch_stop(eff_t effp)
+static int st_pitch_stop(eff_t effp)
{
pitch_t pitch = (pitch_t) effp->priv;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -80,7 +80,7 @@
static int win_width = 1024;
static Float cutoff = 0.95;
-int st_poly_getopts(eff_t effp, int n, char **argv)
+static int st_poly_getopts(eff_t effp UNUSED, int n, char **argv)
{
/* 0: nuttall
1: hamming */
@@ -179,9 +179,9 @@
return (q-q0);
}
-static int permute(int *m, int *l, int ct, int ct1, int amalg)
+static int permute(int *m, int *l, int ct, int ct1, size_t amalg)
{
- int k, n;
+ size_t k, n;
int *p;
int *q;
@@ -221,7 +221,7 @@
static int optimize_factors(int numer, int denom, int *l1, int *l2)
{
int f_min,c_min,u_min,ct1,ct2;
- int amalg;
+ size_t amalg;
int k;
static int m1[MF],m2[MF];
static int b1[MF],b2[MF];
@@ -239,7 +239,7 @@
ct1 = prime(numer,l1);
ct2 = prime(denom,l2);
- for (amalg = max(9,l2[0]); amalg<= 9+l2[ct2-1]; amalg++) {
+ for (amalg = max(9,l2[0]); amalg <= (size_t)(9+l2[ct2-1]); amalg++) {
for (k = 0; k<100000; k++) {
int u,u1,u2,j,f,cost;
cost = 0;
@@ -369,7 +369,7 @@
#define RIBLEN 2048
-int st_poly_start(eff_t effp)
+static int st_poly_start(eff_t effp)
{
poly_t rate = (poly_t) effp->priv;
static int l1[MF], l2[MF];
@@ -523,7 +523,7 @@
}
-int st_poly_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_poly_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
poly_t rate = (poly_t) effp->priv;
@@ -534,7 +534,7 @@
s0 = rate->stage[0]; /* the first stage */
s1 = rate->stage[rate->total]; /* the 'last' stage is output buffer */
{
- int in_size, gap, k;
+ st_size_t in_size, gap, k;
in_size = *isamp;
gap = s0->size - s0->held; /* space available in this 'input' buffer */
@@ -558,7 +558,7 @@
}
if (s0->held == s0->size && s1->held == 0) {
- int k;
+ st_size_t k;
/* input buffer full, output buffer empty, so do process */
for(k=0; k<rate->total; k++) {
@@ -587,7 +587,7 @@
st_size_t out_size;
st_size_t oskip;
Float *out_buf;
- int k;
+ st_size_t k;
oskip = rate->oskip;
out_size = s1->held;
@@ -626,7 +626,7 @@
/*
* Process tail of input samples.
*/
-int st_poly_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_poly_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
st_size_t in_size;
/* Call "flow" with NULL input. */
@@ -638,11 +638,11 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_poly_stop(eff_t effp)
+static int st_poly_stop(eff_t effp)
{
poly_t rate = (poly_t) effp->priv;
polystage *s;
- int k;
+ st_size_t k;
for(k = 0; k <= rate->total; k++) {
s = rate->stage[k];
--- a/src/prc.c
+++ b/src/prc.c
@@ -40,8 +40,8 @@
/* 16 bytes header = 3 UIDs plus checksum, standard Symbian/EPOC file
header */
static const char prc_header[]={
- 0x37,0x00,0x00,0x10,0x6d,0x00,0x00,0x10,
- 0x7e,0x00,0x00,0x10,0xcf,0xac,0x08,0x55
+ '\x37','\x00','\x00','\x10','\x6d','\x00','\x00','\x10',
+ '\x7e','\x00','\x00','\x10','\xcf','\xac','\x08','\x55'
};
int prc_checkheader(ft_t ft, char *head)
@@ -52,7 +52,7 @@
static void prcwriteheader(ft_t ft);
-int st_prcseek(ft_t ft, st_size_t offset)
+static int st_prcseek(ft_t ft, st_size_t offset)
{
prc_t prc = (prc_t ) ft->priv;
st_size_t new_offset, channel_block, alignment;
@@ -72,7 +72,7 @@
return st_seeki(ft, new_offset, SEEK_SET);
}
-int st_prcstartread(ft_t ft)
+static int st_prcstartread(ft_t ft)
{
prc_t p = (prc_t ) ft->priv;
char head[sizeof(prc_header)];
@@ -116,7 +116,7 @@
st_report("PRC must use 8000 sample rate. Overriding");
ft->info.rate = 8000;
- if (ft->info.channels != -1 && ft->info.channels != 1)
+ if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 0)
st_report("PRC must only supports 1 channel. Overriding");
ft->info.channels = 1;
@@ -135,7 +135,7 @@
if it is not, the unspecified size remains in the header
(this is illegal). */
-int st_prcstartwrite(ft_t ft)
+static int st_prcstartwrite(ft_t ft)
{
prc_t p = (prc_t ) ft->priv;
int rc;
@@ -160,7 +160,7 @@
if (ft->info.rate != 0)
st_report("PRC must use 8000 sample rate. Overriding");
- if (ft->info.channels != -1 && ft->info.channels != 1)
+ if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 0)
st_report("PRC must only supports 1 channel. Overriding");
ft->info.encoding = ST_ENCODING_ALAW;
@@ -171,13 +171,8 @@
return ST_SUCCESS;
}
-st_ssize_t st_prcread(ft_t ft, st_sample_t *buf, st_size_t samp)
+static st_size_t st_prcwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
- return st_rawread(ft, buf, samp);
-}
-
-st_ssize_t st_prcwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
-{
prc_t p = (prc_t ) ft->priv;
p->length += samp * ft->info.size;
st_debug("length now = %d", p->length);
@@ -184,7 +179,7 @@
return st_rawwrite(ft, buf, samp);
}
-int st_prcstopwrite(ft_t ft)
+static int st_prcstopwrite(ft_t ft)
{
/* Call before seeking to flush buffer */
st_rawstopwrite(ft);
@@ -229,7 +224,7 @@
NULL,
ST_FILE_SEEK,
st_prcstartread,
- st_prcread,
+ st_rawread,
st_rawstopread,
st_prcstartwrite,
st_prcwrite,
--- a/src/raw.c
+++ b/src/raw.c
@@ -134,7 +134,7 @@
return ST_SUCCESS;
}
-void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -148,7 +148,7 @@
}
}
-void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -162,7 +162,7 @@
}
}
-void st_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -176,7 +176,7 @@
}
}
-void st_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -190,7 +190,7 @@
}
}
-void st_inv_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_inv_ulaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -204,7 +204,7 @@
}
}
-void st_inv_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_inv_alaw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -219,7 +219,7 @@
}
-void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -235,7 +235,7 @@
}
}
-void st_sw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_sw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -266,12 +266,12 @@
datum >>= 8;
}
- return swap? st_swap24(datum) : datum;
+ return swap ? (int24_t)(st_swap24(datum)) : datum;
}
-void st_u24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
+static void st_u24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount UNUSED)
{
while (len--)
{
@@ -282,7 +282,7 @@
-void st_s24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
+static void st_s24_read_buf(st_sample_t * buf1, char const * buf2, st_size_t len, char const swap, st_size_t * clippedCount UNUSED)
{
while (len--)
{
@@ -293,7 +293,7 @@
-void st_udw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_udw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -309,7 +309,7 @@
}
}
-void st_dw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_dw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -325,7 +325,7 @@
}
}
-void st_f32_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_f32_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
{
while (len)
{
@@ -341,7 +341,7 @@
}
}
-void st_f64_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_f64_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
{
while (len)
{
@@ -366,18 +366,12 @@
* functions will cause a loss of data! Need to have sox implement
* a consistent buffering protocol.
*/
-st_ssize_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+st_size_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
{
st_size_t len, done = 0;
void (*read_buf)(st_sample_t *, char const *, st_size_t, char, st_size_t *) = 0;
size_t i;
- if (nsamp < 0)
- {
- st_fail_errno(ft,ST_EINVAL,"st_rawread requires positive sizes");
- return ST_EOF;
- }
-
switch(ft->info.size) {
case ST_SIZE_BYTE:
switch(ft->info.encoding)
@@ -527,7 +521,7 @@
return ST_SUCCESS;
}
-void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -536,7 +530,7 @@
}
}
-void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -545,8 +539,8 @@
}
}
-void st_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
- char swap, st_size_t * clippedCount)
+static void st_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
+ char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -555,8 +549,8 @@
}
}
-void st_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
- char swap, st_size_t * clippedCount)
+static void st_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
+ char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -565,8 +559,8 @@
}
}
-void st_inv_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
- char swap, st_size_t * clippedCount)
+static void st_inv_ulaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
+ char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -575,8 +569,8 @@
}
}
-void st_inv_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
- char swap, st_size_t * clippedCount)
+static void st_inv_alaw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len,
+ char swap UNUSED, st_size_t * clippedCount)
{
while (len)
{
@@ -639,7 +633,7 @@
-void st_u24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
+static void st_u24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
{
while (len--)
{
@@ -650,7 +644,7 @@
-void st_s24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
+static void st_s24_write_buf(char * buf1, st_sample_t const * buf2, st_size_t len, char const swap, st_size_t * clippedCount)
{
while (len--)
{
@@ -661,7 +655,7 @@
-void st_udw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_udw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -677,7 +671,7 @@
}
}
-void st_dw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_dw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clippedCount UNUSED)
{
while (len)
{
@@ -693,7 +687,7 @@
}
}
-void st_f32_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_f32_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
{
while (len)
{
@@ -709,7 +703,7 @@
}
}
-void st_f64_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
+static void st_f64_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clippedCount)
{
while (len)
{
@@ -744,7 +738,7 @@
* functions will cause a loss of data! Need to have sox implement
* a consistent buffering protocol.
*/
-st_ssize_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+st_size_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
{
st_size_t len, done = 0;
void (*write_buf)(char *, st_sample_t const *, st_size_t, char, st_size_t *) = 0;
@@ -873,7 +867,7 @@
*/
#define STARTREAD(NAME,SIZE,STYLE) \
-int NAME(ft_t ft) \
+static int NAME(ft_t ft) \
{ \
ft->info.size = SIZE; \
ft->info.encoding = STYLE; \
@@ -882,7 +876,7 @@
}
#define STARTWRITE(NAME,SIZE,STYLE)\
-int NAME(ft_t ft) \
+static int NAME(ft_t ft) \
{ \
ft->info.size = SIZE; \
ft->info.encoding = STYLE; \
@@ -930,7 +924,7 @@
{
if (ft->info.rate == 0)
ft->info.rate = 8000;
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
}
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -33,7 +33,7 @@
int repeats;
} *repeat_t;
-int st_repeat_getopts(eff_t effp, int n, char **argv)
+static int st_repeat_getopts(eff_t effp, int n, char **argv)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -55,7 +55,7 @@
return (ST_SUCCESS);
}
-int st_repeat_start(eff_t effp)
+static int st_repeat_start(eff_t effp)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -69,7 +69,7 @@
return (ST_SUCCESS);
}
-int st_repeat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_repeat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf UNUSED,
st_size_t *isamp, st_size_t *osamp)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -85,7 +85,7 @@
return (ST_SUCCESS);
}
-int st_repeat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_repeat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
size_t read = 0;
st_sample_t *buf;
@@ -187,7 +187,7 @@
return ST_SUCCESS;
}
-int st_repeat_stop(eff_t effp)
+static int st_repeat_stop(eff_t effp)
{
repeat_t repeat = (repeat_t)effp->priv;
--- a/src/resample.c
+++ b/src/resample.c
@@ -158,7 +158,7 @@
/*
* Process options
*/
-int st_resample_getopts(eff_t effp, int n, char **argv)
+int st_resample_getopts(eff_t effp, int n, char **argv)
{
resample_t r = (resample_t) effp->priv;
@@ -392,7 +392,6 @@
r->Xp = r->Xoff;
for(i=0; i < Nout; i++) {
- // orig: *obuf++ = r->Y[i] * ISCALE;
double ftemp = r->Y[i] * ISCALE;
ST_SAMPLE_CLIP_COUNT(ftemp, effp->clippedCount);
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -104,11 +104,11 @@
/* Private data for SKEL file */
typedef struct reverbstuff {
int counter;
- int numdelays;
+ size_t numdelays;
float *reverbbuf;
float in_gain, out_gain, time;
float delay[MAXREVERBS], decay[MAXREVERBS];
- long samples[MAXREVERBS], maxsamples;
+ size_t samples[MAXREVERBS], maxsamples;
st_sample_t pl, ppl, pppl;
} *reverb_t;
@@ -115,7 +115,7 @@
/*
* Process options
*/
-int st_reverb_getopts(eff_t effp, int n, char **argv)
+static int st_reverb_getopts(eff_t effp, int n, char **argv)
{
reverb_t reverb = (reverb_t) effp->priv;
int i;
@@ -150,10 +150,10 @@
/*
* Prepare for processing.
*/
-int st_reverb_start(eff_t effp)
+static int st_reverb_start(eff_t effp)
{
reverb_t reverb = (reverb_t) effp->priv;
- int i;
+ size_t i;
reverb->in_gain = 1.0;
@@ -208,12 +208,12 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_reverb_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_reverb_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
- int len, done;
- int i, j;
+ size_t len, done;
+ size_t i, j;
float d_in, d_out;
st_sample_t out;
@@ -243,12 +243,12 @@
/*
* Drain out reverb lines.
*/
-int st_reverb_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_reverb_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
float d_in, d_out;
st_sample_t out, l;
- int i, j;
+ size_t i, j;
st_size_t done;
i = reverb->counter;
@@ -280,7 +280,7 @@
/*
* Clean up reverb effect.
*/
-int st_reverb_stop(eff_t effp)
+static int st_reverb_stop(eff_t effp)
{
reverb_t reverb = (reverb_t) effp->priv;
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -33,24 +33,10 @@
#define READING 1
/*
- * Process options: none in our case.
- */
-
-int st_reverse_getopts(eff_t effp, int n, char **argv)
-{
- if (n)
- {
- st_fail(st_reverse_effect.usage);
- return (ST_EOF);
- }
- return(ST_SUCCESS);
-}
-
-/*
* Prepare processing: open temporary file.
*/
-int st_reverse_start(eff_t effp)
+static int st_reverse_start(eff_t effp)
{
reverse_t reverse = (reverse_t) effp->priv;
reverse->fp = tmpfile();
@@ -67,7 +53,7 @@
* Effect flow: a degenerate case: write input samples on temporary file,
* don't generate any output samples.
*/
-int st_reverse_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_reverse_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf UNUSED,
st_size_t *isamp, st_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
@@ -91,7 +77,7 @@
* Effect drain: generate the actual samples in reverse order.
*/
-int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
st_size_t len, nbytes;
@@ -137,7 +123,7 @@
/*
* Close and unlink the temporary file.
*/
-int st_reverse_stop(eff_t effp)
+static int st_reverse_stop(eff_t effp)
{
reverse_t reverse = (reverse_t) effp->priv;
@@ -149,7 +135,7 @@
"reverse",
"Usage: Reverse effect takes no options",
0,
- st_reverse_getopts,
+ st_effect_nothing_getopts,
st_reverse_start,
st_reverse_flow,
st_reverse_drain,
--- a/src/sf.c
+++ b/src/sf.c
@@ -64,7 +64,7 @@
ft->comment = commentbuf;
}
-int st_sfseek(ft_t ft, st_size_t offset)
+static int st_sfseek(ft_t ft, st_size_t offset)
{
st_size_t new_offset, channel_block, alignment;
@@ -91,7 +91,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_sfstartread(ft_t ft)
+static int st_sfstartread(ft_t ft)
{
sf_t sf = (sf_t) ft->priv;
SFHEADER sfhead;
@@ -139,7 +139,7 @@
}
ft->info.channels = (int) sf->info.sf_chans;
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
/* Read codes and print as comments. */
@@ -159,7 +159,7 @@
return(rc);
}
-int st_sfstartwrite(ft_t ft)
+static int st_sfstartwrite(ft_t ft)
{
sf_t sf = (sf_t) ft->priv;
SFHEADER sfhead;
--- a/src/silence.c
+++ b/src/silence.c
@@ -78,7 +78,7 @@
silence->rms_sum = 0;
}
-int st_silence_getopts(eff_t effp, int n, char **argv)
+static int st_silence_getopts(eff_t effp, int n, char **argv)
{
silence_t silence = (silence_t) effp->priv;
int parse_count;
@@ -250,7 +250,7 @@
return(ST_SUCCESS);
}
-int st_silence_start(eff_t effp)
+static int st_silence_start(eff_t effp)
{
silence_t silence = (silence_t) effp->priv;
@@ -321,7 +321,7 @@
return(ST_SUCCESS);
}
-int aboveThreshold(eff_t effp, st_sample_t value, double threshold, char unit)
+static int aboveThreshold(eff_t effp, st_sample_t value, double threshold, char unit)
{
double ratio;
int rc;
@@ -390,12 +390,12 @@
/* Process signed long samples from ibuf to obuf. */
/* Return number of samples processed in isamp and osamp. */
-int st_silence_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_silence_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
- int threshold, j;
- st_size_t i;
+ int threshold;
+ st_size_t i, j;
st_size_t nrOfTicks, nrOfInSamplesRead, nrOfOutSamplesWritten;
nrOfInSamplesRead = 0;
@@ -640,7 +640,7 @@
return (ST_SUCCESS);
}
-int st_silence_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_silence_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
st_size_t i;
@@ -676,7 +676,7 @@
return ST_SUCCESS;
}
-int st_silence_stop(eff_t effp)
+static int st_silence_stop(eff_t effp)
{
silence_t silence = (silence_t) effp->priv;
--- a/src/smp.c
+++ b/src/smp.c
@@ -169,7 +169,7 @@
return(ST_SUCCESS);
}
-int st_smpseek(ft_t ft, st_size_t offset)
+static int st_smpseek(ft_t ft, st_size_t offset)
{
int new_offset, channel_block, alignment;
smp_t smp = (smp_t) ft->priv;
@@ -200,7 +200,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_smpstartread(ft_t ft)
+static int st_smpstartread(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
int i;
@@ -326,11 +326,11 @@
* Place in buf[].
* Return number of samples read.
*/
-st_ssize_t st_smpread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_smpread(ft_t ft, st_sample_t *buf, st_size_t len)
{
smp_t smp = (smp_t) ft->priv;
unsigned short datum;
- int done = 0;
+ st_size_t done = 0;
for(; done < len && smp->NoOfSamps; done++, smp->NoOfSamps--) {
st_readw(ft, &datum);
@@ -340,17 +340,8 @@
return done;
}
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_smpstopread(ft_t ft)
+static int st_smpstartwrite(ft_t ft)
{
- return(ST_SUCCESS);
-}
-
-int st_smpstartwrite(ft_t ft)
-{
smp_t smp = (smp_t) ft->priv;
struct smpheader header;
@@ -390,11 +381,11 @@
return(ST_SUCCESS);
}
-st_ssize_t st_smpwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_smpwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
smp_t smp = (smp_t) ft->priv;
- register int datum;
- st_ssize_t done = 0;
+ int datum;
+ st_size_t done = 0;
while(done < len) {
datum = (int) ST_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clippedCount);
@@ -406,7 +397,7 @@
return(done);
}
-int st_smpstopwrite(ft_t ft)
+static int st_smpstopwrite(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
struct smptrailer trailer;
@@ -436,7 +427,7 @@
ST_FILE_STEREO | ST_FILE_LOOPS | ST_FILE_SEEK,
st_smpstartread,
st_smpread,
- st_smpstopread,
+ st_format_nothing,
st_smpstartwrite,
st_smpwrite,
st_smpstopwrite,
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -20,9 +20,27 @@
st_size_t dataStart;
} *snd_t;
-static void sndtwriteheader(ft_t ft, st_size_t nsamples);
+static void sndtwriteheader(ft_t ft, st_size_t nsamples)
+{
+ char name_buf[97];
-int st_sndseek(ft_t ft, st_size_t offset)
+ /* sndtool header */
+ st_writes(ft, "SOUND"); /* magic */
+ st_writeb(ft, 0x1a);
+ st_writew (ft,0); /* hGSound */
+ st_writedw (ft,nsamples);
+ st_writedw (ft,0);
+ st_writedw (ft,nsamples);
+ st_writew (ft,(int) ft->info.rate);
+ st_writew (ft,0);
+ st_writew (ft,10);
+ st_writew (ft,4);
+ memset (name_buf, 0, 96);
+ sprintf (name_buf,"%.62s - File created by SoX",ft->filename);
+ st_writebuf(ft, name_buf, 1, 96);
+}
+
+static int st_sndseek(ft_t ft, st_size_t offset)
{
st_size_t new_offset, channel_block, alignment;
snd_t snd = (snd_t ) ft->priv;
@@ -41,11 +59,8 @@
return st_seeki(ft, new_offset, SEEK_SET);
}
-/*======================================================================*/
-/* SNDSTARTREAD */
-/*======================================================================*/
-int st_sndtstartread(ft_t ft)
+static int st_sndtstartread(ft_t ft)
{
snd_t snd = (snd_t ) ft->priv;
@@ -122,10 +137,7 @@
return (ST_SUCCESS);
}
-/*======================================================================*/
-/* SNDTSTARTWRITE */
-/*======================================================================*/
-int st_sndtstartwrite(ft_t ft)
+static int st_sndtstartwrite(ft_t ft)
{
snd_t p = (snd_t ) ft->priv;
int rc;
@@ -143,66 +155,24 @@
ft->swap = ft->swap ? 0 : 1;
}
-/* write header */
-ft->info.channels = 1;
-ft->info.encoding = ST_ENCODING_UNSIGNED;
-ft->info.size = ST_SIZE_BYTE;
-p->nsamples = 0;
-sndtwriteheader(ft, 0);
+ /* write header */
+ ft->info.channels = 1;
+ ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->info.size = ST_SIZE_BYTE;
+ p->nsamples = 0;
+ sndtwriteheader(ft, 0);
-return(ST_SUCCESS);
+ return(ST_SUCCESS);
}
-/*======================================================================*/
-/* SNDRSTARTWRITE */
-/*======================================================================*/
-int st_sndrstartwrite(ft_t ft)
+static st_size_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
- int rc;
-
- /* Needed for rawread() */
- rc = st_rawstartread(ft);
- if (rc)
- return rc;
-
- /* sndr is in little endian format so
- * swap bytes on big endian machines
- */
- if (ST_IS_BIGENDIAN)
- {
- ft->swap = ft->swap ? 0 : 1;
- }
-
-/* write header */
-ft->info.channels = 1;
-ft->info.encoding = ST_ENCODING_UNSIGNED;
-ft->info.size = ST_SIZE_BYTE;
-
-/* sounder header */
-st_writew (ft,0); /* sample size code */
-st_writew (ft,(int) ft->info.rate); /* sample rate */
-st_writew (ft,10); /* volume */
-st_writew (ft,4); /* shift */
-
-return(ST_SUCCESS);
-}
-
-/*======================================================================*/
-/* SNDTWRITE */
-/*======================================================================*/
-
-st_ssize_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
-{
snd_t p = (snd_t ) ft->priv;
p->nsamples += len;
return st_rawwrite(ft, buf, len);
}
-/*======================================================================*/
-/* SNDTSTOPWRITE */
-/*======================================================================*/
-
-int st_sndtstopwrite(ft_t ft)
+static int st_sndtstopwrite(ft_t ft)
{
snd_t p = (snd_t ) ft->priv;
int rc;
@@ -222,29 +192,6 @@
return(ST_SUCCESS);
-}
-
-/*======================================================================*/
-/* SNDTWRITEHEADER */
-/*======================================================================*/
-static void sndtwriteheader(ft_t ft, st_size_t nsamples)
-{
- char name_buf[97];
-
- /* sndtool header */
- st_writes(ft, "SOUND"); /* magic */
- st_writeb(ft, 0x1a);
- st_writew (ft,0); /* hGSound */
- st_writedw (ft,nsamples);
- st_writedw (ft,0);
- st_writedw (ft,nsamples);
- st_writew (ft,(int) ft->info.rate);
- st_writew (ft,0);
- st_writew (ft,10);
- st_writew (ft,4);
- memset (name_buf, 0, 96);
- sprintf (name_buf,"%.62s - File created by Sound Exchange",ft->filename);
- st_writebuf(ft, name_buf, 1, 96);
}
/* Sndtool Sound File */
--- a/src/sox.c
+++ b/src/sox.c
@@ -128,8 +128,8 @@
/* Array's tracking input and output files */
static file_options_t *file_opts[MAX_FILES];
static ft_t file_desc[MAX_FILES];
-static int file_count = 0;
-static int input_count = 0;
+static size_t file_count = 0;
+static size_t input_count = 0;
/* We parse effects into a temporary effects table and then place into
* the real effects table. This makes it easier to reorder some effects
@@ -179,7 +179,7 @@
int main(int argc, char **argv)
{
file_options_t *fo;
- int i;
+ size_t i;
myname = argv[0];
@@ -202,8 +202,8 @@
fo = (file_options_t *)calloc(sizeof(file_options_t), 1);
fo->info.size = -1;
- fo->info.encoding = -1;
- fo->info.channels = -1;
+ fo->info.encoding = ST_ENCODING_UNKNOWN;
+ fo->info.channels = 0;
fo->info.compression = HUGE_VAL;
fo->volume = 1.0;
file_opts[file_count++] = fo;
@@ -551,7 +551,7 @@
return ST_SUCCESS;
}
-void optimize_trim(void)
+static void optimize_trim(void)
{
/* Speed hack. If the "trim" effect is the first effect then
* peak inside its "effect descriptor" and see what the
@@ -585,9 +585,9 @@
*/
static void process(void) {
- int e, f, flowstatus = ST_SUCCESS;
- int current_input;
- st_size_t s;
+ int e, flowstatus = ST_SUCCESS;
+ size_t current_input;
+ st_size_t s, f;
st_ssize_t ilen[MAX_INPUT_FILES];
st_sample_t *ibuf[MAX_INPUT_FILES];
@@ -626,9 +626,9 @@
options->info.rate = file_desc[0]->info.rate;
if (options->info.size == -1)
options->info.size = file_desc[0]->info.size;
- if (options->info.encoding == -1)
+ if (options->info.encoding == ST_ENCODING_UNKNOWN)
options->info.encoding = file_desc[0]->info.encoding;
- if (options->info.channels == -1)
+ if (options->info.channels == 0)
options->info.channels = file_desc[0]->info.channels;
if (options->comment != NULL)
@@ -1263,7 +1263,7 @@
static int flow_effect_out(void)
{
int e, havedata, flowstatus = 0;
- int len, total;
+ size_t len, total;
do {
/* run entire chain BACKWARDS: pull, don't push.*/
@@ -1330,9 +1330,9 @@
len = st_write(file_desc[file_count-1],
&efftab[neffects-1].obuf[total],
- (st_ssize_t)efftab[neffects-1].olen-total);
+ efftab[neffects-1].olen-total);
- if (len < 0 || file_desc[file_count-1]->file.eof)
+ if (len != efftab[neffects-1].olen-total || file_desc[file_count-1]->file.eof)
{
st_warn("Error writing: %s",
file_desc[file_count-1]->st_errstr);
@@ -1877,7 +1877,7 @@
void cleanup(void)
{
- int i;
+ size_t i;
struct stat st;
char *fn;
--- a/src/speed.c
+++ b/src/speed.c
@@ -76,7 +76,7 @@
}
/* get options. */
-int st_speed_getopts(eff_t effp, int n, char **argv)
+static int st_speed_getopts(eff_t effp, int n, char **argv)
{
speed_t speed = (speed_t) effp->priv;
int cent = 0;
@@ -106,7 +106,7 @@
}
/* start processing. */
-int st_speed_start(eff_t effp)
+static int st_speed_start(eff_t effp)
{
speed_t speed = (speed_t) effp->priv;
@@ -192,7 +192,7 @@
/* handle a flow.
*/
-int st_speed_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_speed_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
speed_t speed;
@@ -237,7 +237,7 @@
/* end of stuff.
*/
-int st_speed_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_speed_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
speed_t speed = (speed_t) effp->priv;
st_size_t i, oindex;
@@ -274,7 +274,7 @@
/* stop processing. report overflows.
*/
-int st_speed_stop(eff_t effp)
+static int st_speed_stop(eff_t effp)
{
speed_t speed = (speed_t) effp->priv;
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -1,8 +1,6 @@
/*
* NIST Sphere file format handler.
- */
-
-/*
+ *
* August 7, 2000
*
* Copyright (C) 2000 Chris Bagwell (cbagwell@sprynet.com)
@@ -28,7 +26,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_spherestartread(ft_t ft)
+static int st_spherestartread(ft_t ft)
{
sphere_t sphere = (sphere_t) ft->priv;
int rc;
@@ -85,7 +83,7 @@
ft->info.size = i;
}
if (strncmp(buf, "channel_count", 13) == 0 &&
- ft->info.channels == -1)
+ ft->info.channels == 0)
{
sscanf(buf, "%63s %15s %d", fldname, fldtype, &i);
ft->info.channels = i;
@@ -96,7 +94,7 @@
/* Only bother looking for ulaw flag. All others
* should be caught below by default PCM check
*/
- if (ft->info.encoding == -1 &&
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN &&
strncmp(fldsval,"ulaw",4) == 0)
{
ft->info.encoding = ST_ENCODING_ULAW;
@@ -146,7 +144,7 @@
* This means encoding is signed if size = word or
* unsigned if size = byte.
*/
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
{
if (ft->info.size == 1)
ft->info.encoding = ST_ENCODING_UNSIGNED;
@@ -190,7 +188,7 @@
* Return number of samples read.
*/
-st_ssize_t st_sphereread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_sphereread(ft_t ft, st_sample_t *buf, st_size_t len)
{
sphere_t sphere = (sphere_t) ft->priv;
@@ -204,7 +202,7 @@
return st_rawread(ft, buf, len);
}
-int st_spherestartwrite(ft_t ft)
+static int st_spherestartwrite(ft_t ft)
{
int rc;
int x;
@@ -243,7 +241,7 @@
}
-st_ssize_t st_spherewrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_spherewrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
sphere_t sphere = (sphere_t) ft->priv;
@@ -251,7 +249,7 @@
return st_rawwrite(ft, buf, len);
}
-int st_spherestopwrite(ft_t ft)
+static int st_spherestopwrite(ft_t ft)
{
int rc;
char buf[128];
--- a/src/st.h
+++ b/src/st.h
@@ -19,6 +19,9 @@
# define __attribute__(x) /*NOTHING*/
#endif
+/* Avoid warnings about unused parameters. */
+#define UNUSED __attribute__ ((unused))
+
/* C language enhancements: */
/* Boolean type, compatible with C++ */
@@ -85,8 +88,8 @@
*/
/* Temporary variables to prevent multiple evaluation of macro arguments: */
-static st_sample_t st_macro_temp_sample __attribute__((unused));
-static double st_macro_temp_double __attribute__((unused));
+static st_sample_t st_macro_temp_sample UNUSED;
+static double st_macro_temp_double UNUSED;
#define ST_SAMPLE_NEG ST_INT_MIN(32)
#define ST_SAMPLE_TO_UNSIGNED(bits,d,clips) \
@@ -199,7 +202,7 @@
st_rate_t rate; /* sampling rate */
signed char size; /* word length of data */
st_encoding_t encoding; /* format of sample numbers */
- signed char channels; /* number of sound channels */
+ unsigned channels; /* number of sound channels */
char swap; /* do byte- or word-swap */
double compression; /* compression factor (where applicable) */
} st_signalinfo_t;
@@ -263,13 +266,13 @@
typedef struct st_format {
const char * const *names;
- char *usage;
+ const char *usage;
unsigned int flags;
int (*startread)(ft_t ft);
- st_ssize_t (*read)(ft_t ft, st_sample_t *buf, st_size_t len);
+ st_size_t (*read)(ft_t ft, st_sample_t *buf, st_size_t len);
int (*stopread)(ft_t ft);
int (*startwrite)(ft_t ft);
- st_ssize_t (*write)(ft_t ft, const st_sample_t *buf, st_size_t len);
+ st_size_t (*write)(ft_t ft, const st_sample_t *buf, st_size_t len);
int (*stopwrite)(ft_t ft);
int (*seek)(ft_t ft, st_size_t offset);
} st_format_t;
@@ -344,7 +347,7 @@
char *usage;
unsigned int flags;
- int (*getopts)(eff_t effp, int argc, char **argv);
+ int (*getopts)(eff_t effp, int argc, char *argv[]);
int (*start)(eff_t effp);
int (*flow)(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp);
@@ -363,7 +366,7 @@
st_size_t odone, olen; /* consumed, total length */
st_size_t clippedCount; /* increment if clipping occurs */
/* The following is a portable trick to align this variable on
- * an 8-byte bounder. Once this is done, the buffer alloced
+ * an 8-byte boundary. Once this is done, the buffer alloced
* after it should be align on an 8-byte boundery as well.
* This lets you cast any structure over the private area
* without concerns of alignment.
@@ -380,8 +383,8 @@
const char *filetype, const char *comment,
const st_instrinfo_t *instr,
const st_loopinfo_t *loops);
-extern st_ssize_t st_read(ft_t ft, st_sample_t *buf, st_size_t len);
-extern st_ssize_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len);
+extern st_size_t st_read(ft_t ft, st_sample_t *buf, st_size_t len);
+extern st_size_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len);
extern int st_close(ft_t ft);
#define ST_SEEK_SET 0
--- a/src/st_i.h
+++ b/src/st_i.h
@@ -21,17 +21,8 @@
#endif
/* various gcc optimizations and portablity defines */
-#ifdef __GNUC__
#define NORET __attribute__((noreturn))
-#else
-#define NORET
-#endif
-
-#ifdef USE_REGPARM
#define REGPARM(n) __attribute__((regparm(n)))
-#else
-#define REGPARM(n)
-#endif
/* declared in misc.c */
typedef struct {char const *text; int value;} enum_item;
@@ -45,14 +36,14 @@
void st_generate_wave_table(
st_wave_t wave_type,
st_data_t data_type,
- void * table,
+ void *table,
uint32_t table_size,
double min,
double max,
double phase);
-st_sample_t st_gcd(st_sample_t a, st_sample_t b) REGPARM(2);
-st_sample_t st_lcm(st_sample_t a, st_sample_t b) REGPARM(2);
+REGPARM(2) st_sample_t st_gcd(st_sample_t a, st_sample_t b);
+REGPARM(2) st_sample_t st_lcm(st_sample_t a, st_sample_t b);
#ifndef HAVE_STRCASECMP
int strcasecmp(const char *s1, const char *s2);
@@ -69,8 +60,8 @@
* possible byte swapping.
*/
/* declared in misc.c */
-st_ssize_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len);
-st_ssize_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len);
+size_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len);
+size_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len);
int st_reads(ft_t ft, char *c, st_size_t len);
int st_writes(ft_t ft, char *c);
int st_readb(ft_t ft, uint8_t *ub);
@@ -232,10 +223,10 @@
/* Raw I/O
*/
int st_rawstartread(ft_t ft);
-st_ssize_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp);
+st_size_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp);
int st_rawstopread(ft_t ft);
int st_rawstartwrite(ft_t ft);
-st_ssize_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp);
+st_size_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp);
int st_rawstopwrite(ft_t ft);
int st_rawseek(ft_t ft, st_size_t offset);
@@ -243,11 +234,12 @@
* a file handler or effect doesn't need to do anything special
*/
int st_format_nothing(ft_t ft);
-st_ssize_t st_format_nothing_read_io(ft_t ft, st_sample_t *buf, st_size_t len);
-st_ssize_t st_format_nothing_write_io(ft_t ft, const st_sample_t *buf, st_size_t len);
+st_size_t st_format_nothing_read_io(ft_t ft, st_sample_t *buf, st_size_t len);
+st_size_t st_format_nothing_write_io(ft_t ft, const st_sample_t *buf, st_size_t len);
int st_format_nothing_seek(ft_t ft, st_size_t offset);
int st_effect_nothing(eff_t effp);
int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
+int st_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED);
/*=============================================================================
* Effects
@@ -307,9 +299,15 @@
extern const st_effect_t *st_vibro_effect_fn(void);
extern const st_effect_t *st_vol_effect_fn(void);
-/* Needed in sox.c
- */
+/* Needed in sox.c */
st_size_t st_trim_get_start(eff_t effp);
void st_trim_clear_start(eff_t effp);
+
+/* Needed in rate.c */
+int st_resample_start(eff_t effp);
+int st_resample_getopts(eff_t effp, int n, char **argv);
+int st_resample_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, st_size_t *isamp, st_size_t *osamp);
+int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
+int st_resample_stop(eff_t effp);
#endif
--- a/src/stat.c
+++ b/src/stat.c
@@ -45,7 +45,7 @@
/*
* Process options
*/
-int st_stat_getopts(eff_t effp, int n, char **argv)
+static int st_stat_getopts(eff_t effp, int n, char **argv)
{
stat_t stat = (stat_t) effp->priv;
@@ -96,7 +96,7 @@
/*
* Prepare processing.
*/
-int st_stat_start(eff_t effp)
+static int st_stat_start(eff_t effp)
{
stat_t stat = (stat_t) effp->priv;
int i;
@@ -152,7 +152,7 @@
* Return number of samples processed.
*/
-int st_stat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_stat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
@@ -231,7 +231,7 @@
/*
* Process tail of input samples.
*/
-int st_stat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_stat_drain(eff_t effp, st_sample_t *obuf UNUSED, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
@@ -256,7 +256,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_stat_stop(eff_t effp)
+static int st_stat_stop(eff_t effp)
{
stat_t stat = (stat_t) effp->priv;
double amp, scale, rms = 0, freq;
--- a/src/stconfig.h.in
+++ b/src/stconfig.h.in
@@ -111,19 +111,19 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* The size of a `char', as computed by sizeof. */
+/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR
-/* The size of a `int', as computed by sizeof. */
+/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
-/* The size of a `long', as computed by sizeof. */
+/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
-/* The size of a `short', as computed by sizeof. */
+/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
-/* The size of a `void*', as computed by sizeof. */
+/* The size of `void*', as computed by sizeof. */
#undef SIZEOF_VOIDP
/* Define to 1 if you have the ANSI C header files. */
--- a/src/stio.c
+++ b/src/stio.c
@@ -54,7 +54,7 @@
return ST_EOF;
}
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
{
st_fail_errno(ft,ST_EFMT,"data encoding was not specified");
return ST_EOF;
@@ -105,8 +105,8 @@
}
ft->info.size = -1;
- ft->info.encoding = -1;
- ft->info.channels = -1;
+ ft->info.encoding = ST_ENCODING_UNKNOWN;
+ ft->info.channels = 0;
if (info)
ft->info = *info;
/* FIXME: Remove ft->swap from code */
@@ -145,7 +145,7 @@
* This is because libst usually doesn't set this for mono file
* formats (for historical reasons).
*/
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
if (st_checkformat(ft) )
@@ -229,8 +229,8 @@
}
ft->info.size = -1;
- ft->info.encoding = -1;
- ft->info.channels = -1;
+ ft->info.encoding = ST_ENCODING_UNKNOWN;
+ ft->info.channels = 0;
if (info)
ft->info = *info;
ft->mode = 'w';
@@ -314,12 +314,12 @@
return st_open_write_instr(path, info, filetype, comment, NULL, NULL);
}
-st_ssize_t st_read(ft_t ft, st_sample_t *buf, st_size_t len)
+st_size_t st_read(ft_t ft, st_sample_t *buf, st_size_t len)
{
return (*ft->h->read)(ft, buf, len);
}
-st_ssize_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len)
+st_size_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len)
{
return (*ft->h->write)(ft, buf, len);
}
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -55,36 +55,24 @@
*/
stretch_status_t state; /* automaton status */
- int size; /* buffer size */
- int index; /* next available element */
+ st_size_t size; /* buffer size */
+ st_size_t index; /* next available element */
st_sample_t *ibuf; /* input buffer */
int ishift; /* input shift */
- int oindex; /* next evailable element */
+ st_size_t oindex; /* next evailable element */
double * obuf; /* output buffer */
- int oshift; /* output shift */
+ st_size_t oshift; /* output shift */
- int fsize; /* fading size */
+ st_size_t fsize; /* fading size */
double * fbuf; /* fading, 1.0 -> 0.0 */
} * stretch_t;
/*
-static void debug(stretch_t s, char * where)
-{
- st_debug(
- "%s: (f=%.2f w=%.2f r=%.2f f=%.2f)"
- " st=%d s=%d ii=%d is=%d oi=%d os=%d fs=%d\n",
- where, s->factor, s->window, s->shift, s->fading,
- s->state, s->size, s->index, s->ishift,
- s->oindex, s->oshift, s->fsize);
-}
-*/
-
-/*
* Process options
*/
-int st_stretch_getopts(eff_t effp, int n, char **argv)
+static int st_stretch_getopts(eff_t effp, int n, char **argv)
{
char usage[1024];
stretch_t stretch = (stretch_t) effp->priv;
@@ -170,10 +158,10 @@
/*
* Start processing
*/
-int st_stretch_start(eff_t effp)
+static int st_stretch_start(eff_t effp)
{
stretch_t stretch = (stretch_t) effp->priv;
- register int i;
+ st_size_t i;
/* not necessary. taken care by effect processing? */
if (effp->outinfo.channels != effp->ininfo.channels)
@@ -199,7 +187,7 @@
sizeof(st_sample_t));
/* the shift ratio deal with the longest of ishift/oshift
- hence ishift<=size and oshift<=size. should be asserted.
+ hence ishift<=size and oshift<=size. FIXME: should be asserted.
*/
if (stretch->factor < 1.0)
{
@@ -246,7 +234,11 @@
} else if (stretch->fsize==1)
stretch->fbuf[0] = 1.0;
- /* debug(stretch, "start"); */
+ st_debug("start: (f=%.2f w=%.2f r=%.2f f=%.2f)"
+ " st=%d s=%d ii=%d is=%d oi=%d os=%d fs=%d\n",
+ stretch->factor, stretch->window, stretch->shift, stretch->fading,
+ stretch->state, stretch->size, stretch->index, stretch->ishift,
+ stretch->oindex, stretch->oshift, stretch->fsize);
return ST_SUCCESS;
}
@@ -276,12 +268,12 @@
/*
* Processes flow.
*/
-int st_stretch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_stretch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
st_size_t iindex, oindex;
- int i;
+ st_size_t i;
iindex = 0;
oindex = 0;
@@ -353,10 +345,10 @@
* Drain buffer at the end
* maybe not correct ? end might be artificially faded?
*/
-int st_stretch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_stretch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
- register int i;
+ st_size_t i;
st_size_t oindex;
oindex = 0;
@@ -393,7 +385,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_stretch_stop(eff_t effp)
+static int st_stretch_stop(eff_t effp)
{
stretch_t stretch = (stretch_t) effp->priv;
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -63,7 +63,7 @@
if (ft->info.rate == 0.0) ft->info.rate = 8000;
if (ft->info.size == -1) ft->info.size = ST_SIZE_BYTE;
- if (ft->info.encoding == -1) ft->info.encoding = ST_ENCODING_ULAW;
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN) ft->info.encoding = ST_ENCODING_ULAW;
#ifdef __SVR4
/* Read in old values, change to what we need and then send back */
@@ -78,7 +78,7 @@
}
#endif
- // If simple hardware detected in force data to ulaw.
+ /* If simple hardware detected in force data to ulaw. */
if (simple_hw)
{
if (ft->info.size == ST_SIZE_BYTE)
@@ -125,7 +125,7 @@
return(ST_EOF);
}
- if (ft->info.channels == -1) ft->info.channels = 1;
+ if (ft->info.channels == 0) ft->info.channels = 1;
else if (ft->info.channels > 1) {
st_report("Warning: some Sun audio devices can not play stereo");
st_report("at all or sometimes only with signed words. If the");
@@ -233,7 +233,7 @@
if (ft->info.rate == 0.0) ft->info.rate = 8000;
if (ft->info.size == -1) ft->info.size = ST_SIZE_BYTE;
- if (ft->info.encoding == -1) ft->info.encoding = ST_ENCODING_ULAW;
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN) ft->info.encoding = ST_ENCODING_ULAW;
if (ft->info.size == ST_SIZE_BYTE) {
samplesize = 8;
@@ -266,7 +266,7 @@
samplesize = 16;
}
- if (ft->info.channels == -1) ft->info.channels = 1;
+ if (ft->info.channels == 0) ft->info.channels = 1;
else if (ft->info.channels > 1) ft->info.channels = 2;
/* Read in old values, change to what we need and then send back */
--- a/src/swap.c
+++ b/src/swap.c
@@ -26,7 +26,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_swap_getopts(eff_t effp, int n, char **argv)
+static int st_swap_getopts(eff_t effp, int n, char **argv)
{
swap_t swap = (swap_t) effp->priv;
@@ -62,7 +62,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_swap_start(eff_t effp)
+static int st_swap_start(eff_t effp)
{
swap_t swap = (swap_t) effp->priv;
@@ -128,7 +128,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_swap_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_swap_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
swap_t swap = (swap_t) effp->priv;
@@ -178,26 +178,6 @@
return (ST_SUCCESS);
}
-/*
- * Drain out remaining samples if the effect generates any.
- */
-
-int st_swap_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
-{
- *osamp = 0;
- return ST_EOF;
-}
-
-/*
- * Do anything required when you stop reading samples.
- * (free allocated memory, etc.)
- */
-int st_swap_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
-}
-
static st_effect_t st_swap_effect = {
"swap",
"Usage: swap [1 2 | 1 2 3 4]",
@@ -205,8 +185,8 @@
st_swap_getopts,
st_swap_start,
st_swap_flow,
- st_swap_drain,
- st_swap_stop
+ st_effect_nothing_drain,
+ st_effect_nothing
};
const st_effect_t *st_swap_effect_fn(void)
--- a/src/synth.c
+++ b/src/synth.c
@@ -49,7 +49,7 @@
ENUM_ITEM(SYNTH_,PINKNOISE )
ENUM_ITEM(SYNTH_,BROWNNOISE)
ENUM_ITEM(SYNTH_,EXP )
- {0}};
+ {0, 0}};
enum_item const combine_type[] = {
ENUM_ITEM(SYNTH_,CREATE)
@@ -56,7 +56,7 @@
ENUM_ITEM(SYNTH_,MIX )
ENUM_ITEM(SYNTH_,AMOD )
ENUM_ITEM(SYNTH_,FMOD )
- {0}};
+ {0, 0}};
/* do not ask me for the colored noise, i copied the
* algorithm somewhere...
@@ -97,7 +97,7 @@
} PinkNoise;
/* Setup PinkNoise structure for N rows of generators. */
-void InitializePinkNoise( PinkNoise *pink, int numRows )
+static void InitializePinkNoise( PinkNoise *pink, int numRows )
{
int i;
long pmax;
@@ -112,7 +112,7 @@
}
/* Generate Pink noise values between -1.0 and +1.0 */
-float GeneratePinkNoise( PinkNoise *pink )
+static float GeneratePinkNoise( PinkNoise *pink )
{
long newRandom;
long sum;
@@ -238,7 +238,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_synth_getopts(eff_t effp, int n, char **argv)
+static int st_synth_getopts(eff_t effp, int n, char **argv)
{
int argn;
char *hlp;
@@ -372,7 +372,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_synth_start(eff_t effp)
+static int st_synth_start(eff_t effp)
{
int i;
int c;
@@ -664,7 +664,7 @@
/*
* Processed signed long samples from ibuf to obuf.
*/
-int st_synth_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_synth_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
synth_t synth = (synth_t) effp->priv;
@@ -701,26 +701,6 @@
return result;
}
-/*
- * Drain out remaining samples if the effect generates any.
- */
-
-int st_synth_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
-{
- *osamp = 0;
- return ST_EOF;
-}
-
-/*
- * Do anything required when you stop reading samples.
- * (free allocated memory, etc.)
- */
-int st_synth_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
-}
-
static st_effect_t st_synth_effect = {
"synth",
"Usage: synth [len] {[type] [combine] [freq[-freq2]] [off] [ph] [p1] [p2] [p3]}\n"
@@ -741,8 +721,8 @@
st_synth_getopts,
st_synth_start,
st_synth_flow,
- st_synth_drain,
- st_synth_stop
+ st_effect_nothing_drain,
+ st_effect_nothing
};
const st_effect_t *st_synth_effect_fn(void)
--- a/src/trim.c
+++ b/src/trim.c
@@ -37,7 +37,7 @@
/*
* Process options
*/
-int st_trim_getopts(eff_t effp, int n, char **argv)
+static int st_trim_getopts(eff_t effp, int n, char **argv)
{
trim_t trim = (trim_t) effp->priv;
@@ -88,7 +88,7 @@
/*
* Start processing
*/
-int st_trim_start(eff_t effp)
+static int st_trim_start(eff_t effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -128,7 +128,7 @@
* Place in buf[].
* Return number of samples read.
*/
-int st_trim_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_trim_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
int finished = 0;
@@ -195,7 +195,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_trim_stop(eff_t effp)
+static int st_trim_stop(eff_t effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -227,7 +227,7 @@
st_trim_start,
st_trim_flow,
st_effect_nothing_drain,
- st_effect_nothing
+ st_trim_stop
};
const st_effect_t *st_trim_effect_fn(void)
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -74,7 +74,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_txwstartread(ft_t ft)
+static int st_txwstartread(ft_t ft)
{
int c;
char filetype[7];
@@ -186,10 +186,10 @@
* Return number of samples read.
*/
-st_ssize_t st_txwread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_txwread(ft_t ft, st_sample_t *buf, st_size_t len)
{
txw_t sk = (txw_t) ft->priv;
- int done = 0;
+ st_size_t done = 0;
unsigned char uc1,uc2,uc3;
unsigned short s1,s2;
@@ -236,17 +236,8 @@
return done;
}
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_txwstopread(ft_t ft)
+static int st_txwstartwrite(ft_t ft)
{
- return(ST_SUCCESS);
-}
-
-int st_txwstartwrite(ft_t ft)
-{
struct WaveHeader_ WH;
st_debug("tx16w selected output");
@@ -276,9 +267,9 @@
return(ST_SUCCESS);
}
-st_ssize_t st_txwwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_txwwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
- int i;
+ st_size_t i;
unsigned int w1,w2;
tx16w_len += len;
@@ -299,7 +290,7 @@
return(len);
}
-int st_txwstopwrite(ft_t ft)
+static int st_txwstopwrite(ft_t ft)
{
struct WaveHeader_ WH;
int AttackLength, LoopLength, i;
@@ -388,7 +379,7 @@
0,
st_txwstartread,
st_txwread,
- st_txwstopread,
+ st_format_nothing,
st_txwstartwrite,
st_txwwrite,
st_txwstopwrite,
--- a/src/util.c
+++ b/src/util.c
@@ -16,9 +16,9 @@
*/
#include "st_i.h"
+#include <stddef.h>
#include <string.h>
#include <ctype.h>
-
#include <stdarg.h>
struct st_output_message_s
@@ -49,8 +49,8 @@
}
dot_pos = strrchr(drivername, '.');
- if (dot_pos != NULL && dot_pos - drivername <= sizeof(buffer) - 1) {
- strncpy(buffer, drivername, dot_pos - drivername);
+ if (dot_pos != NULL && dot_pos - drivername <= (ptrdiff_t)(sizeof(buffer) - 1)) {
+ strncpy(buffer, drivername, (size_t)(dot_pos - drivername));
buffer[dot_pos - drivername] = '\0';
drivername = buffer;
}
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -43,7 +43,7 @@
/*
* Process options
*/
-int st_vibro_getopts(eff_t effp, int n, char **argv)
+static int st_vibro_getopts(eff_t effp, int n, char **argv)
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -66,7 +66,7 @@
/*
* Prepare processing.
*/
-int st_vibro_start(eff_t effp)
+static int st_vibro_start(eff_t effp)
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -89,7 +89,7 @@
* Return number of samples processed.
*/
-int st_vibro_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_vibro_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -112,16 +112,6 @@
/* processed all samples */
*isamp = *osamp = len;
return (ST_SUCCESS);
-}
-
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-int st_vibro_stop(eff_t effp)
-{
- /* nothing to do */
- return (ST_SUCCESS);
}
static st_effect_t st_vibro_effect = {
--- a/src/voc.c
+++ b/src/voc.c
@@ -200,7 +200,6 @@
/* Prototypes for internal functions */
static int getblock(ft_t);
static void blockstart(ft_t);
-static void blockstop(ft_t);
/* Conversion macros (from raw.c) */
#define ST_ALAW_BYTE_TO_SAMPLE(d) ((st_sample_t)(st_alaw2linear16(d)) << 16)
@@ -210,7 +209,7 @@
/*-----------------------------------------------------------------
* st_vocstartread() -- start reading a VOC file
*-----------------------------------------------------------------*/
-int st_vocstartread(ft_t ft)
+static int st_vocstartread(ft_t ft)
{
int rtn = ST_SUCCESS;
char header[20];
@@ -306,7 +305,7 @@
}
/* setup number of channels */
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = v->channels;
return(ST_SUCCESS);
@@ -317,10 +316,10 @@
* ANN: Major changes here to support multi-part files and files
* that do not have audio in block 9's.
*-----------------------------------------------------------------*/
-st_ssize_t st_vocread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_vocread(ft_t ft, st_sample_t *buf, st_size_t len)
{
vs_t v = (vs_t) ft->priv;
- int done = 0;
+ st_size_t done = 0;
int rc = 0;
int16_t sw;
unsigned char uc;
@@ -405,15 +404,6 @@
return done;
}
-/*-----------------------------------------------------------------
- * st_vocstartread() -- start reading a VOC file
- * nothing to do
- *-----------------------------------------------------------------*/
-int st_vocstopread(ft_t ft)
-{
- return(ST_SUCCESS);
-}
-
/* When saving samples in VOC format the following outline is followed:
* If an 8-bit mono sample then use a VOC_DATA header.
* If an 8-bit stereo sample then use a VOC_EXTENDED header followed
@@ -427,7 +417,7 @@
* which will work with the oldest software (eg. an 8-bit mono sample
* will be able to be played with a really old SB VOC player.)
*/
-int st_vocstartwrite(ft_t ft)
+static int st_vocstartwrite(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -457,7 +447,7 @@
ft->info.encoding = ST_ENCODING_UNSIGNED;
else
ft->info.encoding = ST_ENCODING_SIGN2;
- if (ft->info.channels == -1)
+ if (ft->info.channels == 0)
ft->info.channels = 1;
return(ST_SUCCESS);
@@ -464,14 +454,14 @@
}
/*-----------------------------------------------------------------
- * st_vocstartread() -- start reading a VOC file
+ * st_vocwrite() -- write a VOC file
*-----------------------------------------------------------------*/
-st_ssize_t st_vocwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_vocwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
vs_t v = (vs_t) ft->priv;
unsigned char uc;
int16_t sw;
- st_ssize_t done = 0;
+ st_size_t done = 0;
if (v->samples == 0) {
/* No silence packing yet. */
@@ -493,9 +483,39 @@
}
/*-----------------------------------------------------------------
+ * blockstop() -- stop an output block
+ * End the current data or silence block.
+ *-----------------------------------------------------------------*/
+static void blockstop(ft_t ft)
+{
+ vs_t v = (vs_t) ft->priv;
+ st_sample_t datum;
+
+ st_writeb(ft, 0); /* End of file block code */
+ st_seeki(ft, v->blockseek, 0); /* seek back to block length */
+ st_seeki(ft, 1, 1); /* seek forward one */
+ if (v->silent) {
+ st_writew(ft, v->samples);
+ } else {
+ if (ft->info.size == ST_SIZE_BYTE) {
+ if (ft->info.channels > 1) {
+ st_seeki(ft, 8, 1); /* forward 7 + 1 for new block header */
+ }
+ }
+ v->samples += 2; /* adjustment: SBDK pp. 3-5 */
+ datum = (v->samples * ft->info.size) & 0xff;
+ st_writeb(ft, (int)datum); /* low byte of length */
+ datum = ((v->samples * ft->info.size) >> 8) & 0xff;
+ st_writeb(ft, (int)datum); /* middle byte of length */
+ datum = ((v->samples * ft->info.size)>> 16) & 0xff;
+ st_writeb(ft, (int)datum); /* high byte of length */
+ }
+}
+
+/*-----------------------------------------------------------------
* st_vocstopwrite() -- stop writing a VOC file
*-----------------------------------------------------------------*/
-int st_vocstopwrite(ft_t ft)
+static int st_vocstopwrite(ft_t ft)
{
blockstop(ft);
return(ST_SUCCESS);
@@ -795,36 +815,6 @@
}
}
-/*-----------------------------------------------------------------
- * blockstop() -- stop an output block
- * End the current data or silence block.
- *-----------------------------------------------------------------*/
-static void blockstop(ft_t ft)
-{
- vs_t v = (vs_t) ft->priv;
- st_sample_t datum;
-
- st_writeb(ft, 0); /* End of file block code */
- st_seeki(ft, v->blockseek, 0); /* seek back to block length */
- st_seeki(ft, 1, 1); /* seek forward one */
- if (v->silent) {
- st_writew(ft, v->samples);
- } else {
- if (ft->info.size == ST_SIZE_BYTE) {
- if (ft->info.channels > 1) {
- st_seeki(ft, 8, 1); /* forward 7 + 1 for new block header */
- }
- }
- v->samples += 2; /* adjustment: SBDK pp. 3-5 */
- datum = (v->samples * ft->info.size) & 0xff;
- st_writeb(ft, (int)datum); /* low byte of length */
- datum = ((v->samples * ft->info.size) >> 8) & 0xff;
- st_writeb(ft, (int)datum); /* middle byte of length */
- datum = ((v->samples * ft->info.size)>> 16) & 0xff;
- st_writeb(ft, (int)datum); /* high byte of length */
- }
-}
-
/* Sound Blaster .VOC */
static const char *vocnames[] = {
"voc",
@@ -837,7 +827,7 @@
ST_FILE_STEREO,
st_vocstartread,
st_vocread,
- st_vocstopread,
+ st_format_nothing,
st_vocstartwrite,
st_vocwrite,
st_vocstopwrite,
--- a/src/vol.c
+++ b/src/vol.c
@@ -29,7 +29,7 @@
/*
* Process options: gain (float) type (amplitude, power, dB)
*/
-int st_vol_getopts(eff_t effp, int n, char **argv)
+static int st_vol_getopts(eff_t effp, int n, char **argv)
{
vol_t vol = (vol_t) effp->priv;
vol->gain = 1.0; /* default is no change */
@@ -90,7 +90,7 @@
/*
* Start processing
*/
-int st_vol_start(eff_t effp)
+static int st_vol_start(eff_t effp)
{
vol_t vol = (vol_t) effp->priv;
@@ -116,7 +116,7 @@
/*
* Process data.
*/
-int st_vol_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_vol_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
vol_t vol = (vol_t) effp->priv;
@@ -180,7 +180,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_vol_stop(eff_t effp)
+static int st_vol_stop(eff_t effp)
{
vol_t vol = (vol_t) effp->priv;
if (vol->limited)
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -66,7 +66,7 @@
} *vorbis_t;
/******** Callback functions used in ov_open_callbacks ************/
-int myclose (void *datasource)
+static int myclose (void *datasource UNUSED)
{
/* Do nothing so sox can close the file for us */
return 0;
@@ -89,7 +89,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_vorbisstartread(ft_t ft)
+static int st_vorbisstartread(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_info *vi;
@@ -195,7 +195,7 @@
/* Refill the buffer with samples. Returns BUF_EOF if the end of the
vorbis data was reached while the buffer was being filled,
BUF_ERROR is something bad happens, and BUF_DATA otherwise */
-int refill_buffer (vorbis_t vb)
+static int refill_buffer (vorbis_t vb)
{
int num_read;
@@ -230,10 +230,10 @@
* Return number of samples read.
*/
-st_ssize_t st_vorbisread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_vorbisread(ft_t ft, st_sample_t *buf, st_size_t len)
{
vorbis_t vb = (vorbis_t) ft->priv;
- int i;
+ st_size_t i;
int ret;
st_sample_t l;
@@ -265,7 +265,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_vorbisstopread(ft_t ft)
+static int st_vorbisstopread(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
@@ -277,7 +277,7 @@
/* Write a page of ogg data to a file. Taken directly from encode.c in
oggenc. Returns the number of bytes written. */
-int oe_write_page(ogg_page *page, ft_t ft)
+static int oe_write_page(ogg_page *page, ft_t ft)
{
int written;
written = st_writebuf(ft, page->header,1,page->header_len);
@@ -289,7 +289,7 @@
/* Write out the header packets. Derived mostly from encode.c in
oggenc. Returns HEADER_ERROR if the header cannot be written and
HEADER_OK otherwise. */
-int write_vorbis_header(ft_t ft, vorbis_enc_t *ve)
+static int write_vorbis_header(ft_t ft, vorbis_enc_t *ve)
{
ogg_packet header_main;
ogg_packet header_comments;
@@ -345,7 +345,7 @@
return HEADER_OK;
}
-int st_vorbisstartwrite(ft_t ft)
+static int st_vorbisstartwrite(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve;
@@ -399,13 +399,13 @@
return(ST_SUCCESS);
}
-st_ssize_t st_vorbiswrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_vorbiswrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve = vb->vorbis_enc_data;
- st_ssize_t samples = len / ft->info.channels;
+ st_size_t samples = len / ft->info.channels;
float **buffer = vorbis_analysis_buffer(&ve->vd, samples);
- st_ssize_t i, j;
+ st_size_t i, j;
int ret;
int eos = 0;
@@ -450,7 +450,7 @@
return (len);
}
-int st_vorbisstopwrite(ft_t ft)
+static int st_vorbisstopwrite(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve = vb->vorbis_enc_data;
--- a/src/vox.c
+++ b/src/vox.c
@@ -26,10 +26,6 @@
* *
************************************************************************/
- ///////////////////////////////////////////
- // ORIGINAL SOX COPYRIGHT AND DISCLAIMER //
-///////////////////////////////////////////
-
/************************************************************************
* July 5, 1991 *
* *
@@ -43,30 +39,19 @@
* *
************************************************************************/
- ///////////////////
- // INCLUDE FILES //
-///////////////////
-
#include "st_i.h"
- //////////////
- // TYPEDEFS //
-//////////////
-typedef struct voxstuff { struct { short last; // ADPCM codec state
+typedef struct voxstuff { struct { short last; /* ADPCM codec state */
short index;
} state;
- struct { uint8_t byte; // write store
+ struct { uint8_t byte; /* write store */
uint8_t flag;
} store;
} *vox_t;
- ///////////////
- // CONSTANTS //
-///////////////
-
static short STEPSIZE[49] = { 16, 17, 19, 21, 23, 25, 28,
31, 34, 37, 41, 45, 50, 55,
60, 66, 73, 80, 88, 97, 107,
@@ -79,18 +64,10 @@
static short STEPADJUST[8] = { -1,-1,-1,-1,2,4,6,8 };
- /////////////////////////
- // FUNCTION PROTOTYPES //
-/////////////////////////
-
static uint8_t envox (short, vox_t);
static short devox (uint8_t,vox_t);
- ////////////////////
- // IMPLEMENTATION //
-////////////////////
-
/******************************************************************************
* Function : st_voxstartread
* Description: Initialises the file parameters and ADPCM codec state.
@@ -104,11 +81,11 @@
* rates but the codecs allows any user specified rate.
******************************************************************************/
-int st_voxstartread (ft_t ft)
+static int st_voxstartread (ft_t ft)
{ vox_t state = (vox_t) ft->priv;
- // ... setup file info
+ /* ... setup file info */
ft->file.buf = (char *)malloc(ST_BUFSIZ);
@@ -123,11 +100,11 @@
ft->file.pos = 0;
ft->file.eof = 0;
- ft->info.size = ST_SIZE_WORD;
+ ft->info.size = ST_SIZE_WORD;
ft->info.encoding = ST_ENCODING_OKI_ADPCM;
ft->info.channels = 1;
- // ... initialise CODEC state
+ /* ... initialise CODEC state */
state->state.last = 0;
state->state.index = 0;
@@ -151,22 +128,22 @@
* Notes :
******************************************************************************/
-st_ssize_t st_voxread (ft_t ft,st_sample_t *buffer,st_size_t length)
+static st_size_t st_voxread (ft_t ft,st_sample_t *buffer,st_size_t length)
{ vox_t state = (vox_t) ft->priv;
- int count = 0;
+ int count = 0;
int N;
uint8_t byte;
short word;
- // ... round length down to nearest even number
+ /* ... round length down to nearest even number */
N = length/2;
N *=2;
- // ... loop until buffer full or EOF
+ /* ... loop until buffer full or EOF */
while (count < N)
- { // ... refill buffer
+ { /* ... refill buffer */
if (ft->file.pos >= ft->file.count)
{ ft->file.count = st_readbuf (ft,ft->file.buf,1,ft->file.size);
@@ -176,7 +153,7 @@
break;
}
- // ... decode two nibbles stored as a byte
+ /* ... decode two nybbles stored as a byte */
byte = ft->file.buf[ft->file.pos++];
@@ -201,7 +178,7 @@
* Notes :
******************************************************************************/
-int st_voxstopread (ft_t ft)
+static int st_voxstopread (ft_t ft)
{ free (ft->file.buf);
return (ST_SUCCESS);
@@ -221,11 +198,11 @@
* rates but the codecs allows any user specified rate.
******************************************************************************/
-int st_voxstartwrite (ft_t ft)
+static int st_voxstartwrite (ft_t ft)
{ vox_t state = (vox_t) ft->priv;
- // ... setup file info
+ /* ... setup file info */
ft->file.buf = (char *)malloc(ST_BUFSIZ);
@@ -244,7 +221,7 @@
ft->info.encoding = ST_ENCODING_OKI_ADPCM;
ft->info.channels = 1;
- // ... initialise CODEC state
+ /* ... initialise CODEC state */
state->state.last = 0;
state->state.index = 0;
@@ -267,9 +244,9 @@
* Notes :
******************************************************************************/
-st_ssize_t st_voxwrite (ft_t ft,const st_sample_t *buffer,st_size_t length)
+static st_size_t st_voxwrite (ft_t ft,const st_sample_t *buffer,st_size_t length)
{ vox_t state = (vox_t) ft->priv;
- int count = 0;
+ st_size_t count = 0;
uint8_t byte = state->store.byte;
uint8_t flag = state->store.flag;
short word;
@@ -297,7 +274,7 @@
count++;
}
- // ... keep last byte across calls
+ /* ... keep last byte across calls */
state->store.byte = byte;
state->store.flag = flag;
@@ -315,12 +292,12 @@
* Notes :
******************************************************************************/
-int st_voxstopwrite (ft_t ft)
+static int st_voxstopwrite (ft_t ft)
{ vox_t state = (vox_t) ft->priv;
uint8_t byte = state->store.byte;
uint8_t flag = state->store.flag;
- // ... flush remaining samples
+ /* ... flush remaining samples */
if (flag != 0)
{ byte <<= 4;
@@ -332,8 +309,6 @@
if (ft->file.count > 0)
st_writebuf (ft,ft->file.buf,1,ft->file.count);
- // ... free buffer
-
free (ft->file.buf);
return (ST_SUCCESS);
@@ -377,7 +352,8 @@
{ code = code | 0x01;
}
- // ... use decoder to set the estimate of last sample and adjust the step index
+ /* ... use decoder to set the estimate of last sample and
+ adjust the step index */
state->state.last = devox (code,state);
@@ -418,7 +394,7 @@
sample = state->state.last + dn;
- // ... clip to 12 bits
+ /* ... clip to 12 bits */
if (sample > 2047)
sample = 2047;
@@ -426,7 +402,7 @@
if (sample < -2048)
sample = -2048;
- // ... adjust step size
+ /* ... adjust step size */
state->state.last = sample;
state->state.index += STEPADJUST[code & 0x07];
@@ -437,7 +413,7 @@
if (state->state.index > 48)
state->state.index = 48;
- // ... done
+ /* ... done */
return (sample);
}
--- a/src/wav.c
+++ b/src/wav.c
@@ -1,59 +1,11 @@
/*
* Microsoft's WAVE sound format driver
*
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Lance Norskog And Sundry Contributors are not responsible for
- * the consequences of using this software.
- *
- * Change History:
- *
- * November 23, 1999 - Stan Brooks (stabro@megsinet.com)
- * Merged in gsm support patches from Stuart Daines...
- * Since we had simultaneously made similar changes in
- * wavwritehdr() and wavstartread(), this was some
- * work. Hopefully the result is cleaner than either
- * version, and nothing broke.
- *
- * November 20, 1999 - Stan Brooks (stabro@megsinet.com)
- * Mods for faster adpcm decoding and addition of IMA_ADPCM
- * and ADPCM writing... low-level codex functions moved to
- * external modules ima_rw.c and adpcm.c. Some general cleanup,
- * consistent with writing adpcm and other output formats.
- * Headers written for adpcm include the 'fact' subchunk.
- *
- * September 11, 1998 - Chris Bagwell (cbagwell@sprynet.com)
- * Fixed length bug for IMA and MS ADPCM files.
- *
- * June 1, 1998 - Chris Bagwell (cbagwell@sprynet.com)
- * Fixed some compiler warnings as reported by Kjetil Torgrim Homme
- * <kjetilho@ifi.uio.no>.
- * Fixed bug that caused crashes when reading mono MS ADPCM files. Patch
- * was sent from Michael Brown (mjb@pootle.demon.co.uk).
- *
- * March 15, 1998 - Chris Bagwell (cbagwell@sprynet.com)
- * Added support for Microsoft's ADPCM and IMA (or better known as
- * DVI) ADPCM format for wav files. Thanks goes to Mark Podlipec's
- * XAnim code. It gave some real life understanding of how the ADPCM
- * format is processed. Actual code was implemented based off of
- * various sources from the net.
- *
- * NOTE: Previous maintainers weren't very good at providing contact
- * information.
- *
- * Copyright 1992 Rick Richardson
+ * Copyright 1998-2006 Chris Bagwell and SoX Contributors
* Copyright 1991 Lance Norskog And Sundry Contributors
+ * Copyright 1992 Rick Richardson
+ * Copyright 1997 Graeme W. Gill, 93/5/17
*
- * Fixed by various contributors previous to 1998:
- * 1) Little-endian handling
- * 2) Skip other kinds of file data
- * 3) Handle 16-bit formats correctly
- * 4) Not go into infinite loop
- *
- * User options should override file header - we assumed user knows what
- * they are doing if they specify options.
- * Enhancements and clean up by Graeme W. Gill, 93/5/17
- *
* Info for format tags can be found at:
* http://www.microsoft.com/asf/resources/draft-ietf-fleischman-codec-subtree-01.txt
*
@@ -122,7 +74,7 @@
* ImaAdpcmReadBlock - Grab and decode complete block of samples
*
*/
-unsigned short ImaAdpcmReadBlock(ft_t ft)
+static unsigned short ImaAdpcmReadBlock(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int bytesRead;
@@ -162,7 +114,7 @@
* AdpcmReadBlock - Grab and decode complete block of samples
*
*/
-unsigned short AdpcmReadBlock(ft_t ft)
+static unsigned short AdpcmReadBlock(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int bytesRead;
@@ -211,7 +163,7 @@
for (p = wav->samplePtr; p < wav->sampleTop; p++) *p=0;
/* compress the samples to wav->packet */
if (wav->formatTag == WAVE_FORMAT_ADPCM) {
- AdpcmBlockMashI(chans, wav->samples, wav->samplesPerBlock, wav->state, wav->packet, wav->blockAlign,9);
+ AdpcmBlockMashI(chans, wav->samples, wav->samplesPerBlock, wav->state, wav->packet, wav->blockAlign);
}else{ /* WAVE_FORMAT_IMA_ADPCM */
ImaBlockMashI(chans, wav->samples, wav->samplesPerBlock, wav->state, wav->packet, 9);
}
@@ -236,7 +188,7 @@
/* WAV GSM6.10 support functions */
/****************************************************************************/
/* create the gsm object, malloc buffer for 160*2 samples */
-int wavgsminit(ft_t ft)
+static int wavgsminit(ft_t ft)
{
int valueP=1;
wav_t wav = (wav_t) ft->priv;
@@ -263,7 +215,7 @@
}
/*destroy the gsm object and free the buffer */
-void wavgsmdestroy(ft_t ft)
+static void wavgsmdestroy(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
gsm_destroy(wav->gsmhandle);
@@ -270,14 +222,14 @@
free(wav->gsmsample);
}
-st_ssize_t wavgsmread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t wavgsmread(ft_t ft, st_sample_t *buf, st_size_t len)
{
wav_t wav = (wav_t) ft->priv;
- int done=0;
+ size_t done=0;
int bytes;
gsm_byte frame[65];
- ft->st_errno = ST_SUCCESS;
+ ft->st_errno = ST_SUCCESS;
/* copy out any samples left from the last call */
while(wav->gsmindex && (wav->gsmindex<160*2) && (done < len))
@@ -338,13 +290,13 @@
return (ST_SUCCESS);
}
-st_ssize_t wavgsmwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t wavgsmwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
- wav_t wav = (wav_t) ft->priv;
- int done = 0;
+ wav_t wav = (wav_t) ft->priv;
+ size_t done = 0;
int rc;
- ft->st_errno = ST_SUCCESS;
+ ft->st_errno = ST_SUCCESS;
while (done < len) {
while ((wav->gsmindex < 160*2) && (done < len))
@@ -362,7 +314,7 @@
}
-void wavgsmstopwrite(ft_t ft)
+static void wavgsmstopwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
@@ -425,7 +377,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_wavstartread(ft_t ft)
+static int st_wavstartread(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
char magic[5];
@@ -537,7 +489,7 @@
case WAVE_FORMAT_PCM:
/* Default (-1) depends on sample size. Set that later on. */
- if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_UNSIGNED &&
+ if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_UNSIGNED &&
ft->info.encoding != ST_ENCODING_SIGN2)
st_report("User options overriding encoding read in .wav header");
@@ -549,7 +501,7 @@
break;
case WAVE_FORMAT_IMA_ADPCM:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_IMA_ADPCM)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_IMA_ADPCM)
ft->info.encoding = ST_ENCODING_IMA_ADPCM;
else
st_report("User options overriding encoding read in .wav header");
@@ -556,7 +508,7 @@
break;
case WAVE_FORMAT_ADPCM:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ADPCM)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ADPCM)
ft->info.encoding = ST_ENCODING_ADPCM;
else
st_report("User options overriding encoding read in .wav header");
@@ -563,7 +515,7 @@
break;
case WAVE_FORMAT_IEEE_FLOAT:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_FLOAT)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_FLOAT)
ft->info.encoding = ST_ENCODING_FLOAT;
else
st_report("User options overriding encoding read in .wav header");
@@ -576,7 +528,7 @@
break;
case WAVE_FORMAT_ALAW:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ALAW)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ALAW)
ft->info.encoding = ST_ENCODING_ALAW;
else
st_report("User options overriding encoding read in .wav header");
@@ -589,7 +541,7 @@
break;
case WAVE_FORMAT_MULAW:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ULAW)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ULAW)
ft->info.encoding = ST_ENCODING_ULAW;
else
st_report("User options overriding encoding read in .wav header");
@@ -614,7 +566,7 @@
st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in Dolby AC2 format.");
return ST_EOF;
case WAVE_FORMAT_GSM610:
- if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_GSM )
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_GSM )
ft->info.encoding = ST_ENCODING_GSM;
else
st_report("User options overriding encoding read in .wav header");
@@ -648,7 +600,7 @@
}
/* User options take precedence */
- if (ft->info.channels == -1 || ft->info.channels == wChannels)
+ if (ft->info.channels == 0 || ft->info.channels == wChannels)
ft->info.channels = wChannels;
else
st_report("User options overriding channels read in .wav header");
@@ -839,7 +791,7 @@
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_UNSIGNED;
break;
@@ -850,7 +802,7 @@
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_SIGN2;
break;
@@ -861,7 +813,7 @@
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_SIGN2;
break;
@@ -872,7 +824,7 @@
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == -1)
+ if (ft->info.encoding == ST_ENCODING_UNKNOWN)
ft->info.encoding = ST_ENCODING_SIGN2;
break;
@@ -1078,10 +1030,10 @@
* Return number of samples read.
*/
-st_ssize_t st_wavread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_wavread(ft_t ft, st_sample_t *buf, st_size_t len)
{
wav_t wav = (wav_t) ft->priv;
- st_ssize_t done;
+ st_size_t done;
ft->st_errno = ST_SUCCESS;
@@ -1116,7 +1068,7 @@
/* Copy interleaved data into buf, converting to st_sample_t */
{
short *p, *top;
- int ct;
+ size_t ct;
ct = len-done;
if (ct > (wav->blockSamplesRemaining*ft->info.channels))
ct = (wav->blockSamplesRemaining*ft->info.channels);
@@ -1186,7 +1138,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_wavstopread(ft_t ft)
+static int st_wavstopread(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int rc = ST_SUCCESS;
@@ -1218,7 +1170,7 @@
return rc;
}
-int st_wavstartwrite(ft_t ft)
+static int st_wavstartwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int rc;
@@ -1252,7 +1204,7 @@
wav->iCoefs = NULL;
switch (wav->formatTag)
{
- int ch, sbsize;
+ size_t ch, sbsize;
case WAVE_FORMAT_IMA_ADPCM:
initImaTable();
@@ -1572,7 +1524,7 @@
if (isExtensible)
{
- int i;
+ size_t i;
static const char guid[14] = "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71";
st_writew(ft, 22);
st_writew(ft, wBitsPerSample); /* No padding in container */
@@ -1640,7 +1592,7 @@
return ST_SUCCESS;
}
-st_ssize_t st_wavwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_wavwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
{
wav_t wav = (wav_t) ft->priv;
st_ssize_t total_len = len;
@@ -1681,7 +1633,7 @@
}
}
-int st_wavstopwrite(ft_t ft)
+static int st_wavstopwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
@@ -1778,7 +1730,7 @@
}
}
-int st_wavseek(ft_t ft, st_size_t offset)
+static int st_wavseek(ft_t ft, st_size_t offset)
{
wav_t wav = (wav_t) ft->priv;
int new_offset, channel_block, alignment;
--- a/src/wve.c
+++ b/src/wve.c
@@ -25,7 +25,7 @@
static void wvewriteheader(ft_t ft);
-int st_wveseek(ft_t ft, st_size_t offset)
+static int st_wveseek(ft_t ft, st_size_t offset)
{
int new_offset, channel_block, alignment;
wve_t wve = (wve_t ) ft->priv;
@@ -45,7 +45,7 @@
return st_seeki(ft, offset, SEEK_SET);
}
-int st_wvestartread(ft_t ft)
+static int st_wvestartread(ft_t ft)
{
wve_t p = (wve_t ) ft->priv;
char magic[16];
@@ -117,7 +117,7 @@
st_report("WVE must use 8000 sample rate. Overriding");
ft->info.rate = 8000;
- if (ft->info.channels != -1 && ft->info.channels != 1)
+ if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 1)
st_report("WVE must only supports 1 channel. Overriding");
ft->info.channels = 1;
@@ -136,7 +136,7 @@
if it is not, the unspecified size remains in the header
(this is illegal). */
-int st_wvestartwrite(ft_t ft)
+static int st_wvestartwrite(ft_t ft)
{
wve_t p = (wve_t ) ft->priv;
int rc;
@@ -161,7 +161,7 @@
if (ft->info.rate != 0)
st_report("WVE must use 8000 sample rate. Overriding");
- if (ft->info.channels != -1 && ft->info.channels != 1)
+ if (ft->info.channels != 0 && ft->info.channels != 1)
st_report("WVE must only supports 1 channel. Overriding");
ft->info.encoding = ST_ENCODING_ALAW;
@@ -172,7 +172,7 @@
return ST_SUCCESS;
}
-st_ssize_t st_wvewrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static st_size_t st_wvewrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
wve_t p = (wve_t ) ft->priv;
p->length += samp * ft->info.size;
@@ -179,7 +179,7 @@
return st_rawwrite(ft, buf, samp);
}
-int st_wvestopwrite(ft_t ft)
+static int st_wvestopwrite(ft_t ft)
{
/* Call before seeking to flush buffer */
--- a/src/xa.c
+++ b/src/xa.c
@@ -141,7 +141,7 @@
st_report("User options overriding size read in .xa header");
}
- if (ft->info.channels == -1 || ft->info.channels == xa->header.channels) {
+ if (ft->info.channels == 0 || ft->info.channels == xa->header.channels) {
ft->info.channels = xa->header.channels;
} else {
st_report("User options overriding channels read in .xa header");
@@ -210,14 +210,12 @@
* Read up to len samples from a file, converted to signed longs.
* Return the number of samples read.
*/
-static st_ssize_t st_xaread(ft_t ft, st_sample_t *buf, st_size_t len)
+static st_size_t st_xaread(ft_t ft, st_sample_t *buf, st_size_t len)
{
xa_t xa = (xa_t) ft->priv;
- st_ssize_t done;
- st_ssize_t bytes;
int32_t sample;
unsigned char inByte;
- unsigned int i;
+ size_t i, done, bytes;
ft->st_errno = ST_SUCCESS;
done = 0;
@@ -312,7 +310,7 @@
return ST_EOF;
}
-static st_ssize_t st_xawrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static st_size_t st_xawrite(ft_t ft, const st_sample_t *buf UNUSED, st_size_t len UNUSED)
{
st_fail_errno(ft, ST_ENOTSUP, ".XA writing not supported");
return ST_EOF;