shithub: sox

Download patch

ref: 5ed26883a877848cd755ec32dd9e6e3317b0a017
parent: 9dd22e5ec99577e56bf5225a121e3d78e72ef790
author: cbagwell <cbagwell>
date: Thu Oct 28 20:34:12 EDT 2004

Better default values durig recording.

--- a/src/alsa.c
+++ b/src/alsa.c
@@ -593,6 +593,9 @@
 
 static int get_format(ft_t ft, int formats, int *fmt)
 {
+    if (ft->info.size == -1)
+        ft->info.size = ST_SIZE_WORD;
+
     /* Some hardware only wants to work with 8-bit or 16-bit data */
     if (ft->info.size == ST_SIZE_BYTE)
     {
@@ -614,12 +617,12 @@
     {
         if ((formats & SND_PCM_FMT_U16) || (formats & SND_PCM_FMT_S16))
         {
-            st_report("Unsupport/unspecified size for ALSA driver.  Changing to 16-bits.");
+            st_report("ALSA driver doesn't supported %s samples.  Changing to words.", st_sizes_str[(unsigned char)ft->info.size]);
             ft->info.size = ST_SIZE_WORD;
         }
         else
         {
-            st_report("Unsupported/un specified size for ALSA driver.  Changing to 8-bits.");
+            st_report("ALSA driver doesn't supported %s samples.  Changing to bytes.", st_sizes_str[(unsigned char)ft->info.size]);
             ft->info.size = ST_SIZE_BYTE;
         }
 
@@ -626,6 +629,8 @@
     }
 
     if (ft->info.size == ST_SIZE_BYTE) {
+        if (ft->info.encoding == -1)
+            ft->info.encoding = ST_ENCODING_UNSIGNED;
         switch (ft->info.encoding)
         {
             case ST_ENCODING_SIGN2:
@@ -675,6 +680,8 @@
         }
     }
     else if (ft->info.size == ST_SIZE_WORD) {
+        if (ft->info.encoding == -1)
+            ft->info.encoding = ST_ENCODING_SIGN2;
         switch (ft->info.encoding)
         {
             case ST_ENCODING_SIGN2:
@@ -714,7 +721,7 @@
         }
     }
     else {
-        st_fail_errno(ft,ST_EFMT,EMSGFMT,st_encodings_str[(unsigned char)ft->info.encoding],st_sizes_str[(unsigned char)ft->info.size]);
+        st_fail_errno(ft,ST_EFMT,EMSGFMT,st_encodings_str[(unsigned char)ft->info.encoding], st_sizes_str[(unsigned char)ft->info.size]);
         return ST_EOF;
     }
     return 0;