ref: 44a99eb48b0e0b45b5808d841e17028e91793910
parent: 82a7fd4ef9e66dffe17bc376db6ade45ed478a5e
author: robs <robs>
date: Mon Jan 29 15:34:40 EST 2007
sequence fixes; cosmetics
--- a/src/sox.c
+++ b/src/sox.c
@@ -95,7 +95,7 @@
static st_bool doopts(file_t, int, char **);
static void usage(char const *) NORET;
static void usage_effect(char *) NORET;
-static void process(void);
+static int process(void);
static void update_status(void);
static void report_file_info(file_t f);
static void parse_effects(int argc, char **argv);
@@ -106,6 +106,7 @@
static int drain_effect_out(void);
static int drain_effect(int);
static void stop_effects(void);
+static void delete_effects(void);
#define MAX_INPUT_FILES 32
#define MAX_FILES MAX_INPUT_FILES + 2 /* 1 output file plus record input */
@@ -421,16 +422,25 @@
if (ofile->desc)
st_close(ofile->desc);
free(ofile->desc);
- process();
- } while (!user_abort && current_input < input_count);
+ } while (process() != ST_EOF && !user_abort && current_input < input_count);
else process();
+ delete_effects();
+
+ for (i = 0; i < file_count; ++i)
+ if (files[i]->desc->clips != 0)
+ st_warn(i < input_count?"%s: input clipped %u samples" :
+ "%s: output clipped %u samples; decrease volume?",
+ (files[i]->desc->h->flags & ST_FILE_DEVICE)?
+ files[i]->desc->h->names[0] : files[i]->desc->filename,
+ files[i]->desc->clips);
+
if (mixing_clips > 0)
- st_warn("-m clipped %u samples; decrease volume?", mixing_clips);
+ st_warn("mix-combining clipped %u samples; decrease volume?", mixing_clips);
for (i = 0; i < file_count; i++)
if (files[i]->volume_clips > 0)
- st_warn("%s: -v clipped %u samples; decrease volume?", files[i]->filename,
+ st_warn("%s: balancing clipped %u samples; decrease volume?", files[i]->filename,
files[i]->volume_clips);
if (show_progress) {
@@ -832,10 +842,10 @@
}
/*
- * Process input file -> effect table -> output file one buffer at a time
+ * Process: Input(s) -> Balancing -> Combiner -> Effects -> Output
*/
-static void process(void) {
+static int process(void) {
int e, flowstatus = 0;
st_size_t ws, s, i;
st_size_t ilen[MAX_INPUT_FILES];
@@ -1053,17 +1063,7 @@
/* N.B. more data may be written during stop_effects */
stop_effects();
-
- for (i = 0; i < input_count; i++)
- if (files[i]->desc->clips != 0)
- st_warn("%s: input clipped %u samples", files[i]->desc->filename,
- files[i]->desc->clips);
-
- if (files[i]->desc->clips != 0)
- st_warn("%s: output clipped %u samples; decrease volume?",
- (files[i]->desc->h->flags & ST_FILE_DEVICE)?
- files[i]->desc->h->names[0] : files[i]->desc->filename,
- files[i]->desc->clips);
+ return flowstatus;
}
static void parse_effects(int argc, char **argv)
@@ -1563,8 +1563,6 @@
st_size_t clips;
int (*stop)(eff_t effp) =
efftab[e].h->stop? efftab[e].h->stop : st_effect_nothing;
- int (*delete)(eff_t effp) =
- efftab[e].h->delete? efftab[e].h->delete : st_effect_nothing;
stop(&efftab[e]);
clips = efftab[e].clips;
@@ -1575,6 +1573,16 @@
}
if (clips != 0)
st_warn("'%s' clipped %u samples; decrease volume?",efftab[e].name,clips);
+ }
+}
+
+static void delete_effects(void)
+{
+ int e;
+
+ for (e = 1; e < neffects; e++) {
+ int (*delete)(eff_t effp) =
+ efftab[e].h->delete? efftab[e].h->delete : st_effect_nothing;
/* No left & right delete as there is no left & right getopts */
delete(&efftab[e]);
--- a/src/trim.c
+++ b/src/trim.c
@@ -179,11 +179,7 @@
return (ST_SUCCESS);
}
-/*
- * Do anything required when you stop reading samples.
- * Don't close input file!
- */
-static int st_trim_stop(eff_t effp)
+static int delete(eff_t effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -201,8 +197,8 @@
st_trim_start,
st_trim_flow,
st_effect_nothing_drain,
- st_trim_stop,
- st_effect_nothing
+ st_effect_nothing,
+ delete
};
const st_effect_t *st_trim_effect_fn(void)
--
⑨