ref: 19addbb93c1821b81c383ac0406f3274a7d57f78
parent: 0e12417f045bab8842fe2031548074bbb8b693e1
author: rrt <rrt>
date: Wed Dec 27 07:02:16 EST 2006
Inline reserve_effect_buf and release_effect_buf: there's little point having these functions; the places they came from are "narrative" code, and we might as well either have it like that (I don't have much against long functions when they're simply doing a long job with lots of little steps), or properly split up into lots of functions.
--- a/src/sox.c
+++ b/src/sox.c
@@ -97,12 +97,10 @@
static void parse_effects(int argc, char **argv);
static void check_effects(void);
static int start_effects(void);
-static void reserve_effect_buf(void);
static int flow_effect_out(void);
static int flow_effect(int);
static int drain_effect_out(void);
static int drain_effect(int);
-static void release_effect_buf(void);
static void stop_effects(void);
#define MAX_INPUT_FILES 32
@@ -685,7 +683,11 @@
flowstatus = start_effects();
/* Allocate output buffers for effects */
- reserve_effect_buf();
+ for (e = 0; e < neffects; e++) {
+ efftab[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
+ if (efftabR[e].name)
+ efftabR[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
+ }
if (combine_method != SOX_CONCAT) {
for (f = 0; f < input_count; f++) {
@@ -871,7 +873,10 @@
free(ibuf[f]);
/* Free output buffers now that they won't be used */
- release_effect_buf();
+ for (e = 0; e < neffects; e++) {
+ free(efftab[e].obuf);
+ free(efftabR[e].obuf);
+ }
/* N.B. more data may be written during stop_effects */
stop_effects();
@@ -1115,17 +1120,6 @@
return ret;
}
-static void reserve_effect_buf(void)
-{
- int e;
-
- for (e = 0; e < neffects; e++) {
- efftab[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
- if (efftabR[e].name)
- efftabR[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
- }
-}
-
static int flow_effect_out(void)
{
int e, havedata, flowstatus = 0;
@@ -1440,16 +1434,6 @@
efftab[e].odone = 0;
}
return rc;
-}
-
-static void release_effect_buf(void)
-{
- int e;
-
- for (e = 0; e < neffects; e++) {
- free(efftab[e].obuf);
- free(efftabR[e].obuf);
- }
}
static void stop_effects(void)