ref: 7ef285353e8a75f0709962e31f00bfc2dc1e88e6
parent: 40fd453a7e61979c3bab7fe0455fb08417b69ffb
author: cbagwell <cbagwell>
date: Sun May 14 20:46:56 EDT 2006
Removed need for external cleanup() when using libst.
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,15 @@
This file contains a list of all changes starting after the release of
sox-11gamma.
+sox-12.18.2
+-----------
+ o Adding in debain's disk full fix (#313206).
+ o Finally got rid of reference to cleanup() function in
+ library. Applications are now required to detect
+ all failures from return codes and cleanup as they
+ want.
+
+
sox-12.18.1
------------
@@ -21,7 +30,8 @@
o Stop SoX from crashing on sphere files that contain large text
strings. (1430025) Ulf Hamhammar
o Fix some overflow crashes in aiff handler. (1430024) Ulf Hamhammar.
- o Under windows, set piped input/output to binary mode (1417794). Marty
+ o Under windows, set piped input/output to binary mode (1417794). Martin
+ Panter
o Fixed broken internal version of strdup(). (1417790) Marty
o Stop infinite loop when reading MP3's with a tag size of
exactly 8192 bytes. (1417511) Hans Fugal
--- a/src/sox.c
+++ b/src/sox.c
@@ -615,12 +615,14 @@
ilen = 0;
}
- /* FIXME: libst needs the feof() and ferror() concepts
- * to see if ST_EOF means a real failure. Until then we
- * must treat ST_EOF as just hiting the end of the file.
- */
if (ilen == ST_EOF)
+ {
efftab[0].olen = 0;
+ if (file_desc[current_input]->st_errno)
+ {
+ fprintf(stderr, file_desc[current_input]->st_errstr);
+ }
+ }
else
efftab[0].olen = ilen;
@@ -657,12 +659,14 @@
{
ilen[f] = st_read(file_desc[f], ibuf[f], (st_ssize_t)ST_BUFSIZ);
- /* FIXME: libst needs the feof() and ferror() concepts
- * to see if ST_EOF means a real failure. Until then we
- * must treat ST_EOF as just hiting the end of the buffer.
- */
if (ilen[f] == ST_EOF)
+ {
ilen[f] = 0;
+ if (file_desc[f]->st_errno)
+ {
+ fprintf(stderr, file_desc[f]->st_errstr);
+ }
+ }
/* Only count read samples for first file in mix */
if (f == 0)
@@ -742,7 +746,9 @@
} while (1);
/* This will drain the effects */
- drain_effect_out();
+ /* Don't write if output is indicating errors. */
+ if (writing && file_desc[file_count-1]->st_errno)
+ drain_effect_out();
#ifdef SOXMIX
/* Free input buffers now that they are not used */
@@ -831,6 +837,7 @@
int i;
int needchan = 0, needrate = 0, haschan = 0, hasrate = 0;
int effects_mask = 0;
+ int status;
if (writing)
{
@@ -880,10 +887,15 @@
st_geteffect(&efftab[neffects], "avg");
/* give default opts for added effects */
- /* FIXME: Should look at return code and abort on ST_EOF */
- (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
- (char **)0);
+ status = (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
+ (char **)0);
+ if (status == ST_EOF)
+ {
+ cleanup();
+ exit(2);
+ }
+
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
&file_desc[0]->info,
@@ -905,10 +917,15 @@
st_geteffect(&efftab[neffects], "resample");
/* set up & give default opts for added effects */
- /* FIXME: Should look at return code and abort on ST_EOF */
- (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
- (char **)0);
+ status = (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
+ (char **)0);
+ if (status == ST_EOF)
+ {
+ cleanup();
+ exit(2);
+ }
+
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
&file_desc[0]->info,
@@ -964,10 +981,15 @@
st_geteffect(&efftab[neffects], "resample");
/* set up & give default opts for added effects */
- /* FIXME: Should look at return code and abort on ST_EOF */
- (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
- (char **)0);
+ status = (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
+ (char **)0);
+ if (status == ST_EOF)
+ {
+ cleanup();
+ exit(2);
+ }
+
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
&file_desc[0]->info,
@@ -994,9 +1016,13 @@
st_geteffect(&efftab[neffects], "avg");
/* set up & give default opts for added effects */
- /* FIXME: Should look at return code and abort on ST_EOF */
- (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
- (char **)0);
+ status = (* efftab[neffects].h->getopts)(&efftab[neffects],(int)0,
+ (char **)0);
+ if (status == ST_EOF)
+ {
+ cleanup();
+ exit(2);
+ }
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
@@ -1104,10 +1130,6 @@
efftab[neffects-1].olen,
file_opts[file_count-1]->volume);
-
- /* FIXME: Should look at return code and abort
- * on ST_EOF
- */
total = 0;
do
{
@@ -1121,7 +1143,7 @@
&efftab[neffects-1].obuf[total],
(st_ssize_t)efftab[neffects-1].olen-total);
- if (len < 0)
+ if (len < 0 || file_desc[file_count-1]->file.eof)
{
st_warn("Error writing: %s",
file_desc[file_count-1]->st_errstr);
@@ -1230,7 +1252,7 @@
{
st_ssize_t i, done, idone, odone, idonel, odonel, idoner, odoner;
st_sample_t *ibuf, *obuf;
- int effstatus;
+ int effstatus, effstatusl, effstatusr;
/* Do not attempt to do any more effect processing during
* user aborts as we may be stuck in an infinit flow loop.
@@ -1274,8 +1296,9 @@
#endif
done = idone + odone;
- } else {
-
+ }
+ else
+ {
/* Put stereo data in two seperate buffers and run effect
* on each of them.
*/
@@ -1296,7 +1319,7 @@
fprintf(stderr, "pre %s odone1=%d, olen1=%d odone=%d olen=%d\n", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
#endif
- effstatus = (* efftab[e].h->flow)(&efftab[e],
+ effstatusl = (* efftab[e].h->flow)(&efftab[e],
ibufl, obufl, (st_size_t *)&idonel,
(st_size_t *)&odonel);
@@ -1303,8 +1326,7 @@
/* right */
idoner = idone/2; /* odd-length logic */
odoner = odone/2;
- /* FIXME: effstatus of previous operation is lost. */
- effstatus = (* efftabR[e].h->flow)(&efftabR[e],
+ effstatusr = (* efftabR[e].h->flow)(&efftabR[e],
ibufr, obufr, (st_size_t *)&idoner,
(st_size_t *)&odoner);
@@ -1325,8 +1347,12 @@
fprintf(stderr, "post %s odone1=%d, olen1=%d odone=%d olen=%d\n", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
#endif
-
done = idonel + idoner + odonel + odoner;
+
+ if (effstatusl)
+ effstatus = effstatusl;
+ else
+ effstatus = effstatusr;
}
if (effstatus == ST_EOF)
{
@@ -1579,7 +1605,6 @@
exit(1);
}
-/* called from util.c::st_fail() */
void cleanup(void)
{
int i;
--- a/src/st_i.h
+++ b/src/st_i.h
@@ -105,7 +105,7 @@
/* util.c */
void st_report(const char *, ...);
void st_warn(const char *, ...);
-void st_fail(const char *, ...) NORET;
+void st_fail(const char *, ...);
void st_fail_errno(ft_t, int, const char *, ...);
int st_is_bigendian(void);
--- a/src/stio.c
+++ b/src/stio.c
@@ -155,7 +155,7 @@
if (st_checkformat(ft) )
{
- st_fail("bad input format for file %s: %s", ft->filename,
+ st_warn("bad input format for file %s: %s", ft->filename,
ft->st_errstr);
goto input_error;
}
@@ -298,7 +298,7 @@
if (st_checkformat(ft) )
{
- st_fail("bad output format for file %s: %s", ft->filename,
+ st_warn("bad output format for file %s: %s", ft->filename,
ft->st_errstr);
goto output_error;
}
--- a/src/util.c
+++ b/src/util.c
@@ -60,10 +60,13 @@
fprintf(stderr, "\n");
}
+/* Warning: This function is depricated. st_fail_errno() is
+ * the preferred way so that applications can control printing
+ * to their choice; not just stderr.
+ */
void st_fail(const char *fmt, ...)
{
va_list args;
- extern void cleanup();
fprintf(stderr, "%s: ", myname);
@@ -71,8 +74,6 @@
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
- cleanup();
- exit(2);
}