ref: f596a1a4a7abe3f5d2ca338cdc53e81f369092c3
parent: 9279a48c30d0b7dc00018525ad1a58bd95b34b0a
author: Ulrich Klauer <[email protected]>
date: Sun Jan 1 18:58:27 EST 2012
Count samples with 64 bits in more places Change a number of places where size_t or off_t were still used to count samples in order to now use (sox_)uint64_t. Also use PRIu64 where such numbers are output. Some function prototypes and data structures from sox.h are also affected. This breaks ABI compatibility; the library version number has been incremented for 14.4.0 already in commit e9a66b7c, so no change necessary here.
--- a/src/bend.c
+++ b/src/bend.c
@@ -43,7 +43,7 @@
char *str; /* Command-line argument to parse for this bend */
size_t start; /* Start bending when in_pos equals this */
double cents;
- size_t duration; /* Number of samples to bend */
+ uint64_t duration; /* Number of samples to bend */
} *bends;
unsigned frame_rate;
@@ -69,7 +69,8 @@
static int parse(sox_effect_t * effp, char **argv, sox_rate_t rate)
{
priv_t *p = (priv_t *) effp->priv;
- size_t i, time = 0, delay;
+ size_t i;
+ uint64_t time = 0, delay;
char const *next;
for (i = 0; i < p->nbends; ++i) {
--- a/src/crop.c
+++ b/src/crop.c
@@ -32,7 +32,7 @@
{
priv_t * p = (priv_t *)effp->priv;
char const * s, * q;
- size_t samples;
+ uint64_t samples;
int i;
for (i = p->argc - 1; i == 0 || i == 1; --i) {
@@ -105,7 +105,7 @@
sox_sample_t * obuf, size_t * isamp, size_t * osamp)
{
priv_t * p = (priv_t *)effp->priv;
- size_t skipped;
+ uint64_t skipped;
p->pos[0].at -= skipped = min(p->pos[0].at, *isamp);
*osamp = !p->pos[0].at * min(p->pos[1].at, min(*isamp - skipped, *osamp));
--- a/src/delay.c
+++ b/src/delay.c
@@ -21,7 +21,8 @@
typedef struct {
size_t argc;
char * * argv, * max_arg;
- size_t delay, pre_pad, pad, buffer_size, buffer_index;
+ uint64_t delay, pre_pad, pad;
+ size_t buffer_size, buffer_index;
sox_sample_t * buffer;
sox_bool drain_started;
} priv_t;
@@ -40,7 +41,7 @@
static int create(sox_effect_t * effp, int argc, char * * argv)
{
priv_t * p = (priv_t *)effp->priv;
- size_t delay, max_samples = 0;
+ uint64_t delay, max_samples = 0;
unsigned i;
--argc, ++argv;
@@ -70,7 +71,7 @@
static int start(sox_effect_t * effp)
{
priv_t * p = (priv_t *)effp->priv;
- size_t max_delay;
+ uint64_t max_delay;
if (!p->max_arg)
return SOX_EFF_NULL;
@@ -82,7 +83,7 @@
lsx_parsesamples(effp->in_signal.rate, p->argv[effp->flow], &p->buffer_size, 't');
lsx_parsesamples(effp->in_signal.rate, p->max_arg, &max_delay, 't');
if (effp->flow == 0)
- lsx_debug("extending audio by %" PRIuPTR " samples", max_delay);
+ lsx_debug("extending audio by %" PRIu64 " samples", max_delay);
p->buffer_index = p->delay = p->pre_pad = 0;
p->pad = max_delay - p->buffer_size;
p->buffer = lsx_malloc(p->buffer_size * sizeof(*p->buffer));
--- a/src/effects.c
+++ b/src/effects.c
@@ -397,10 +397,10 @@
return flow_status;
}
-size_t sox_effects_clips(sox_effects_chain_t * chain)
+uint64_t sox_effects_clips(sox_effects_chain_t * chain)
{
unsigned i, f;
- size_t clips = 0;
+ uint64_t clips = 0;
for (i = 1; i < chain->length - 1; ++i)
for (f = 0; f < chain->effects[i][0].flows; ++f)
clips += chain->effects[i][f].clips;
@@ -407,10 +407,10 @@
return clips;
}
-size_t sox_stop_effect(sox_effect_t *effp)
+uint64_t sox_stop_effect(sox_effect_t *effp)
{
unsigned f;
- size_t clips = 0;
+ uint64_t clips = 0;
for (f = 0; f < effp->flows; ++f) {
effp[f].handler.stop(&effp[f]);
@@ -451,12 +451,12 @@
*/
void sox_delete_effect(sox_effect_t *effp)
{
- size_t clips;
+ uint64_t clips;
unsigned f;
if ((clips = sox_stop_effect(effp)) != 0)
- lsx_warn("%s clipped %lu samples; decrease volume?",
- effp->handler.name, (unsigned long)clips);
+ lsx_warn("%s clipped %" PRIu64 " samples; decrease volume?",
+ effp->handler.name, clips);
effp->handler.kill(effp); /* N.B. only one kill; not one per flow */
for (f = 0; f < effp->flows; ++f)
free(effp[f].priv);
--- a/src/effects_i.c
+++ b/src/effects_i.c
@@ -145,7 +145,7 @@
* # of samples.
* Returns NULL on error, pointer to next char to parse otherwise.
*/
-char const * lsx_parsesamples(sox_rate_t rate, const char *str0, size_t *samples, int def)
+char const * lsx_parsesamples(sox_rate_t rate, const char *str0, uint64_t *samples, int def)
{
int i, found_samples = 0, found_time = 0;
char const * end;
@@ -214,7 +214,7 @@
int main(int argc, char * * argv)
{
char const * str, * next;
- size_t samples;
+ uint64_t samples;
TEST("0" , 0, 1)
TEST("1" , 10000, 1)
--- a/src/fade.c
+++ b/src/fade.c
@@ -47,7 +47,7 @@
priv_t * fade = (priv_t *) effp->priv;
char t_char[2];
int t_argno;
- size_t samples;
+ uint64_t samples;
const char *n;
--argc, ++argv;
@@ -118,7 +118,7 @@
{
priv_t * fade = (priv_t *) effp->priv;
sox_bool truncate = sox_false;
- size_t samples;
+ uint64_t samples;
/* converting time values to samples */
fade->in_start = 0;
@@ -179,7 +179,9 @@
fade->samplesdone = fade->in_start;
fade->endpadwarned = 0;
- lsx_debug("in_start = %lu in_stop = %lu out_start = %lu out_stop = %lu", (unsigned long)fade->in_start, (unsigned long)fade->in_stop, (unsigned long)fade->out_start, (unsigned long)fade->out_stop);
+ lsx_debug("in_start = %" PRIu64 " in_stop = %" PRIu64 " "
+ "out_start = %" PRIu64 " out_stop = %" PRIu64,
+ fade->in_start, fade->in_stop, fade->out_start, fade->out_stop);
if (fade->in_start == fade->in_stop && !truncate &&
fade->out_start == fade->out_stop)
@@ -285,7 +287,7 @@
if (fade->do_out && fade->samplesdone < fade->out_stop &&
!(fade->endpadwarned))
{ /* Warning about padding silence into end of sample */
- lsx_warn("Fade: warning: End time passed end-of-file. Padding with silence");
+ lsx_warn("End time past end of audio. Padding with silence");
fade->endpadwarned = 1;
} /* endif endpadwarned */
--- a/src/oss.c
+++ b/src/oss.c
@@ -204,7 +204,7 @@
file->size = 0;
ioctl (fileno(ft->fp), SNDCTL_DSP_GETBLKSIZE, &file->size);
if (file->size < 4 || file->size > 65536) {
- lsx_fail_errno(ft,SOX_EOF,"Invalid audio buffer size %lu", (unsigned long)file->size);
+ lsx_fail_errno(ft,SOX_EOF,"Invalid audio buffer size %" PRIuPTR, file->size);
return (SOX_EOF);
}
file->count = 0;
--- a/src/pad.c
+++ b/src/pad.c
@@ -21,13 +21,13 @@
unsigned npads; /* Number of pads requested */
struct {
char * str; /* Command-line argument to parse for this pad */
- size_t start; /* Start padding when in_pos equals this */
- size_t pad; /* Number of samples to pad */
+ uint64_t start; /* Start padding when in_pos equals this */
+ uint64_t pad; /* Number of samples to pad */
} * pads;
- size_t in_pos; /* Number of samples read from the input stream */
+ uint64_t in_pos; /* Number of samples read from the input stream */
unsigned pads_pos; /* Number of pads completed so far */
- size_t pad_pos; /* Number of samples through the current pad */
+ uint64_t pad_pos; /* Number of samples through the current pad */
} priv_t;
static int parse(sox_effect_t * effp, char * * argv, sox_rate_t rate)
@@ -42,7 +42,7 @@
next = lsx_parsesamples(rate, p->pads[i].str, &p->pads[i].pad, 't');
if (next == NULL) break;
if (*next == '\0')
- p->pads[i].start = i? SOX_SIZE_MAX : 0;
+ p->pads[i].start = i? UINT64_MAX : 0;
else {
if (*next != '@') break;
next = lsx_parsesamples(rate, next+1, &p->pads[i].start, 't');
@@ -118,7 +118,7 @@
priv_t * p = (priv_t *)effp->priv;
static size_t isamp = 0;
if (p->pads_pos != p->npads && p->in_pos != p->pads[p->pads_pos].start)
- p->in_pos = SOX_SIZE_MAX; /* Invoke the final pad (with no given start) */
+ p->in_pos = UINT64_MAX; /* Invoke the final pad (with no given start) */
return flow(effp, 0, obuf, &isamp, osamp);
}
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -20,7 +20,7 @@
typedef struct {
unsigned num_repeats, remaining_repeats;
- off_t num_samples, remaining_samples;
+ uint64_t num_samples, remaining_samples;
FILE * tmp_file;
} priv_t;
@@ -74,7 +74,7 @@
--p->remaining_repeats;
rewind(p->tmp_file);
}
- n = min(p->remaining_samples, (off_t)(*osamp - odone));
+ n = min(p->remaining_samples, *osamp - odone);
if ((fread(obuf + odone, sizeof(*obuf), n, p->tmp_file)) != n) {
lsx_fail("error reading temporary file: %s", strerror(errno));
return SOX_EOF;
--- a/src/sox.c
+++ b/src/sox.c
@@ -151,7 +151,7 @@
sox_bool no_glob;
sox_format_t * ft; /* libSoX file descriptor */
- size_t volume_clips;
+ uint64_t volume_clips;
rg_mode replay_gain_mode;
} file_t;
@@ -187,7 +187,7 @@
static sox_signalinfo_t combiner_signal, ofile_signal_options;
static sox_encodinginfo_t combiner_encoding, ofile_encoding_options;
-static size_t mixing_clips = 0;
+static uint64_t mixing_clips = 0;
static size_t current_input = 0;
static uint64_t input_wide_samples = 0;
static uint64_t read_wide_samples = 0;
@@ -381,9 +381,9 @@
uint64_t ws = ft->signal.length / ft->signal.channels;
char const * text, * text2 = NULL;
fprintf(output,
- "Duration : %s = %lu samples %c %g CDDA sectors\n",
+ "Duration : %s = %" PRIu64 " samples %c %g CDDA sectors\n",
str_time((double)ws / ft->signal.rate),
- (unsigned long)ws, "~="[ft->signal.rate == 44100],
+ ws, "~="[ft->signal.rate == 44100],
(double)ws / ft->signal.rate * 44100 / 588);
if (ft->mode == 'r' && (text = size_and_bitrate(ft, &text2))) {
fprintf(output, "File Size : %s\n", text);
@@ -489,7 +489,8 @@
static int combiner_start(sox_effect_t *effp)
{
input_combiner_t * z = (input_combiner_t *) effp->priv;
- size_t ws, i;
+ uint64_t ws;
+ size_t i;
if (is_serial(combine_method))
progress_to_next_input_file(files[current_input], effp);
@@ -1113,10 +1114,10 @@
return SOX_SUCCESS;
} /* advance_eff_chain */
-static size_t total_clips(void)
+static uint64_t total_clips(void)
{
unsigned i;
- size_t clips = 0;
+ uint64_t clips = 0;
for (i = 0; i < file_count; ++i)
clips += files[i]->ft->clips + files[i]->volume_clips;
return clips + mixing_clips + sox_effects_clips(effects_chain);
@@ -2615,7 +2616,7 @@
case Type: printf("%s\n", ft->filetype); break;
case Rate: printf("%g\n", ft->signal.rate); break;
case Channels: printf("%u\n", ft->signal.channels); break;
- case Samples: if (soxi_total ==-1) printf("%lu\n",(unsigned long)ws); break;
+ case Samples: if (soxi_total ==-1) printf("%" PRIu64 "\n", ws); break;
case Duration: if (soxi_total ==-1) printf("%s\n", str_time(secs)); break;
case Duration_secs: if (soxi_total ==-1) printf("%f\n", secs); break;
case Bits: printf("%u\n", ft->encoding.bits_per_sample); break;
@@ -2952,19 +2953,19 @@
for (i = 0; i < file_count; ++i)
if (files[i]->ft->clips != 0)
- lsx_warn(i < input_count?"`%s' input clipped %lu samples" :
- "`%s' output clipped %lu samples; decrease volume?",
+ lsx_warn(i < input_count?"`%s' input clipped %" PRIu64 " samples" :
+ "`%s' output clipped %" PRIu64 " samples; decrease volume?",
(files[i]->ft->handler.flags & SOX_FILE_DEVICE)?
files[i]->ft->handler.names[0] : files[i]->ft->filename,
- (unsigned long)files[i]->ft->clips);
+ files[i]->ft->clips);
if (mixing_clips > 0)
- lsx_warn("mix-combining clipped %lu samples; decrease volume?", (unsigned long)mixing_clips);
+ lsx_warn("mix-combining clipped %" PRIu64 " samples; decrease volume?", mixing_clips);
for (i = 0; i < file_count; i++)
if (files[i]->volume_clips > 0)
- lsx_warn("`%s' balancing clipped %lu samples; decrease volume?",
- files[i]->filename, (unsigned long)files[i]->volume_clips);
+ lsx_warn("`%s' balancing clipped %" PRIu64 " samples; decrease volume?",
+ files[i]->filename, files[i]->volume_clips);
if (show_progress) {
if (user_abort)
--- a/src/sox.h
+++ b/src/sox.h
@@ -1515,7 +1515,7 @@
*/
struct sox_format_t {
char * filename; /**< File name */
-
+
/**
Signal specifications for reader (decoder) or writer (encoder):
sample rate, number of channels, precision, length, headroom multiplier.
@@ -1543,7 +1543,7 @@
sox_bool seekable; /**< Can seek on this file */
char mode; /**< Read or write mode ('r' or 'w') */
sox_uint64_t olength; /**< Samples * chans written to file */
- size_t clips; /**< Incremented if clipping occurs */
+ sox_uint64_t clips; /**< Incremented if clipping occurs */
int sox_errno; /**< Failure error code */
char sox_errstr[256]; /**< Failure error text */
void * fp; /**< File stream pointer */
@@ -1606,7 +1606,7 @@
size_t obeg; /**< output buffer consumed */
size_t oend; /**< output buffer total length */
size_t imin; /**< minimum input buffer size */
- size_t clips; /**< increment if clipping occurs */
+ sox_uint64_t clips; /**< increment if clipping occurs */
size_t flows; /**< 1 if MCHAN, number of chans otherwise */
size_t flow; /**< flow number */
void * priv; /**< Effect's private data area */
@@ -2129,7 +2129,7 @@
Gets the number of clips that occurred while running an effects chain.
@returns the number of clips that occurred while running an effects chain.
*/
-size_t
+sox_uint64_t
LSX_API
sox_effects_clips(
LSX_PARAM_IN sox_effects_chain_t * chain /**< Effects chain from which to read clip information. */
@@ -2140,7 +2140,7 @@
Shuts down an effect (calls stop on each of its flows).
@returns the number of clips from all flows.
*/
-size_t
+sox_uint64_t
LSX_API
sox_stop_effect(
LSX_PARAM_INOUT_COUNT(effp->flows) sox_effect_t * effp /**< Effect to stop. */
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -73,7 +73,7 @@
double min, /* Minimum value on the y-axis. (e.g. -1) */
double max, /* Maximum value on the y-axis. (e.g. +1) */
double phase); /* Phase at 1st point; 0..2pi. (e.g. pi/2 for cosine) */
-char const * lsx_parsesamples(sox_rate_t rate, const char *str, size_t *samples, int def);
+char const * lsx_parsesamples(sox_rate_t rate, const char *str, uint64_t *samples, int def);
int lsx_parse_note(char const * text, char * * end_ptr);
double lsx_parse_frequency_k(char const * text, char * * end_ptr, int key);
#define lsx_parse_frequency(a, b) lsx_parse_frequency_k(a, b, INT_MAX)
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -56,7 +56,7 @@
/* Per-channel work area */
int WORK; /* Start of work area is marked by this dummy variable. */
- size_t skip;
+ uint64_t skip;
int dft_size, step_size, block_steps, block_num, rows, cols, read;
int x_size, end, end_min, last_end;
sox_bool truncated;
@@ -92,7 +92,7 @@
static int getopts(sox_effect_t * effp, int argc, char **argv)
{
priv_t * p = (priv_t *)effp->priv;
- size_t duration;
+ uint64_t duration;
char const * next;
int c;
lsx_getopt_t optstate;
--- a/src/splice.c
+++ b/src/splice.c
@@ -50,12 +50,12 @@
unsigned nsplices; /* Number of splices requested */
struct {
char * str; /* Command-line argument to parse for this splice */
- size_t overlap; /* Number of samples to overlap */
- size_t search; /* Number of samples to search */
- size_t start; /* Start splicing when in_pos equals this */
+ uint64_t overlap; /* Number of samples to overlap */
+ uint64_t search; /* Number of samples to search */
+ uint64_t start; /* Start splicing when in_pos equals this */
} * splices;
- size_t in_pos; /* Number of samples read from the input stream */
+ uint64_t in_pos; /* Number of samples read from the input stream */
unsigned splices_pos; /* Number of splices completed so far */
size_t buffer_pos; /* Number of samples through the current splice */
size_t max_buffer_size;
@@ -64,7 +64,7 @@
} priv_t;
static void splice(sox_effect_t * effp, const sox_sample_t * in1, const
- sox_sample_t * in2, sox_sample_t * output, size_t overlap, size_t channels)
+ sox_sample_t * in2, sox_sample_t * output, uint64_t overlap, size_t channels)
{
priv_t * p = (priv_t *)effp->priv;
size_t i, j, k = 0;
@@ -104,10 +104,10 @@
}
}
-static size_t do_splice(sox_effect_t * effp,
- sox_sample_t * f, size_t overlap, size_t search, size_t channels)
+static uint64_t do_splice(sox_effect_t * effp,
+ sox_sample_t * f, uint64_t overlap, uint64_t search, size_t channels)
{
- size_t offset = search? best_overlap_position(
+ uint64_t offset = search? best_overlap_position(
f, f + overlap * channels, overlap, search, channels) : 0;
splice(effp, f, f + (overlap + offset) * channels,
f + (overlap + offset) * channels, overlap, channels);
--- a/src/stat.c
+++ b/src/stat.c
@@ -25,7 +25,7 @@
double dsum1, dsum2; /* deltas */
double scale; /* scale-factor */
double last; /* previous sample */
- size_t read; /* samples processed */
+ uint64_t read; /* samples processed */
int volume;
int srms;
int fft;
@@ -265,7 +265,7 @@
if (stat->volume == 2)
fprintf(stderr, "\n\n");
/* print out the info */
- fprintf(stderr, "Samples read: %12lu\n", (unsigned long)stat->read);
+ fprintf(stderr, "Samples read: %12" PRIu64 "\n", stat->read);
fprintf(stderr, "Length (seconds): %12.6f\n", (double)stat->read/effp->in_signal.rate/effp->in_signal.channels);
if (stat->srms)
fprintf(stderr, "Scaled by rms: %12.6f\n", rms);
--- a/src/synth.c
+++ b/src/synth.c
@@ -186,8 +186,8 @@
char * length_str;
channel_t * getopts_channels;
size_t getopts_nchannels;
- size_t samples_done;
- size_t samples_to_do;
+ uint64_t samples_done;
+ uint64_t samples_to_do;
channel_t * channels;
size_t number_of_channels;
sox_bool no_headroom;
@@ -514,11 +514,11 @@
(log(chan->freq2) - log(chan->freq)) / p->samples_to_do : 1;
break;
}
- lsx_debug("type=%s, combine=%s, samples_to_do=%lu, f1=%g, f2=%g, "
+ lsx_debug("type=%s, combine=%s, samples_to_do=%" PRIu64 ", f1=%g, f2=%g, "
"offset=%g, phase=%g, p1=%g, p2=%g, p3=%g mult=%g",
lsx_find_enum_value(chan->type, synth_type)->text,
lsx_find_enum_value(chan->combine, combine_type)->text,
- (unsigned long)p->samples_to_do, chan->freq, chan->freq2,
+ p->samples_to_do, chan->freq, chan->freq2,
chan->offset, chan->phase, chan->p1, chan->p2, chan->p3, chan->mult);
}
p->gain = 1;
--- a/src/trim.c
+++ b/src/trim.c
@@ -31,7 +31,7 @@
{
char *end;
priv_t * trim = (priv_t *) effp->priv;
- size_t samples;
+ uint64_t samples;
const char *n;
--argc, ++argv;
@@ -72,7 +72,7 @@
static int sox_trim_start(sox_effect_t * effp)
{
priv_t * trim = (priv_t *) effp->priv;
- size_t samples;
+ uint64_t samples;
if (lsx_parsesamples(effp->in_signal.rate, trim->start_str,
&samples, 't') == NULL)
@@ -98,7 +98,7 @@
trim->length = 0;
/* with trim->end_str == NULL, this means indefinite length */
- lsx_debug("start at %lus, length %lu", (unsigned long)trim->start, (unsigned long)trim->length);
+ lsx_debug("start at %" PRIu64 ", length %" PRIu64, trim->start, trim->length);
/* Account for # of channels */
trim->start *= effp->in_signal.channels;