shithub: sox

Download patch

ref: 73dae59cf6d3f0c39a581a314baaab9523e3a959
parent: ab6d7c8cfcd68ecd20c8399bf3c606828fe15511
author: robs <robs>
date: Thu Dec 7 02:29:46 EST 2006

Fixed an alsa crash due to dodgy externs.

--- a/src/alsa.c
+++ b/src/alsa.c
@@ -29,15 +29,6 @@
 
 static int get_format(ft_t ft, snd_pcm_format_mask_t *fmask, int *fmt);
 
-extern void st_ub_write_buf(char* buf1, const st_sample_t *buf2, st_size_t len, char swap);
-extern void st_sb_write_buf(char *buf1, const st_sample_t *buf2, st_size_t len, char swap);
-extern void st_uw_write_buf(char *buf1, const st_sample_t *buf2, st_size_t len, char swap);
-extern void st_sw_write_buf(char *buf1, const st_sample_t *buf2, st_size_t len, char swap);
-extern void st_ub_read_buf(st_sample_t *buf1, char *buf2, st_size_t len, char swap);
-extern void st_sb_read_buf(st_sample_t *buf1, char *buf2, st_size_t len, char swap);
-extern void st_uw_read_buf(st_sample_t *buf1, char *buf2, st_size_t len, char swap);
-extern void st_sw_read_buf(st_sample_t *buf1, char *buf2, st_size_t len, char swap);
-
 int st_alsasetup(ft_t ft, snd_pcm_stream_t mode)
 {
     int fmt = SND_PCM_FORMAT_S16;
@@ -307,7 +298,7 @@
     st_size_t len;
     int err;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*read_buf)(st_sample_t *, char *, st_size_t, char) = 0;
+    void (*read_buf)(st_sample_t *, char const *, st_size_t, char, st_size_t *) = 0;
 
     switch(ft->info.size) {
         case ST_SIZE_BYTE:
@@ -365,7 +356,7 @@
         }
         else
         {
-            read_buf(buf+(len*sizeof(st_sample_t)), alsa->buf, err, ft->swap);
+            read_buf(buf+(len*sizeof(st_sample_t)), alsa->buf, err, ft->swap, &ft->clippedCount);
             len += err * ft->info.channels;
         }
     }
@@ -395,7 +386,7 @@
     st_size_t len;
     int err;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*write_buf)(char *, const st_sample_t *, st_size_t, char) = 0;
+    void (*write_buf)(char *, const st_sample_t *, st_size_t, char, st_size_t *) = 0;
 
     switch(ft->info.size) {
         case ST_SIZE_BYTE:
@@ -436,7 +427,7 @@
         nsamp = (alsa->buf_size/ft->info.size);
     len = 0;
 
-    write_buf(alsa->buf, buf, nsamp, ft->swap);
+    write_buf(alsa->buf, buf, nsamp, ft->swap, &ft->clippedCount);
 
     while (len < nsamp)
     {
--- a/src/mask.c
+++ b/src/mask.c
@@ -86,7 +86,7 @@
                                 *obuf++ = l;
                         }
                         break;
-                        default:
+                        default: /* Mask (dither) not needed at >= 24 bits */
                         for(done = 0; done < len; done++) {
                                 *obuf++ = *ibuf++;
                         }
--- a/src/st.h
+++ b/src/st.h
@@ -113,7 +113,9 @@
 #define ST_SAMPLE_TO_UNSIGNED_BYTE(d,clips) ST_SAMPLE_TO_UNSIGNED(8,d,clips)
 #define ST_SAMPLE_TO_SIGNED_BYTE(d,clips) ST_SAMPLE_TO_SIGNED(8,d,clips)
 #define ST_SAMPLE_TO_UNSIGNED_WORD(d,clips) ST_SAMPLE_TO_UNSIGNED(16,d,clips)
+
 #define ST_SAMPLE_TO_SIGNED_WORD(d,clips) ST_SAMPLE_TO_SIGNED(16,d,clips)
+
 #define ST_SAMPLE_TO_UNSIGNED_24BIT(d,clips) ST_SAMPLE_TO_UNSIGNED(24,d,clips)
 #define ST_SAMPLE_TO_SIGNED_24BIT(d,clips) ST_SAMPLE_TO_SIGNED(24,d,clips)
 #define ST_SAMPLE_TO_UNSIGNED_DWORD(d) (uint32_t)((d)^ST_SAMPLE_NEG)
--- a/src/st_i.h
+++ b/src/st_i.h
@@ -78,6 +78,16 @@
 void st_rewind(ft_t ft);
 void st_clearerr(ft_t ft);
 
+/* defined in raw.c */
+void st_ub_write_buf(char* buf1, const st_sample_t *buf2, st_size_t len, char swap, st_size_t * clippedCount);
+void st_sb_write_buf(char *buf1, const st_sample_t *buf2, st_size_t len, char swap, st_size_t * clippedCount);
+void st_uw_write_buf(char *buf1, const st_sample_t *buf2, st_size_t len, char swap, st_size_t * clippedCount);
+void st_sw_write_buf(char *buf1, const st_sample_t *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, st_size_t * clippedCount);
+void st_sb_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);
+void st_sw_read_buf(st_sample_t *buf1, char const *buf2, st_size_t len, char swap, st_size_t * clippedCount);
+
 /* Utilities to byte-swap values, use libc optimized macros if possible  */
 #ifdef HAVE_BYTESWAP_H
 #define st_swapw(x) bswap_16(x)