[xiph-cvs] cvs commit: speex/src speexdec.c

Jean-Marc Valin jm at xiph.org
Sat May 31 22:58:41 PDT 2003



jm          03/06/01 01:58:41

  Modified:    src      speexdec.c
  Log:
  fixed an soundcard endianness issue and a Win32 playback bug where the
  device wasn't closed properly, clipping the end of the file.

Revision  Changes    Path
1.77      +15 -5     speex/src/speexdec.c

Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- speexdec.c	30 May 2003 19:44:54 -0000	1.76
+++ speexdec.c	1 Jun 2003 05:58:41 -0000	1.77
@@ -136,7 +136,7 @@
          exit(1);         
       }
 
-      format=AFMT_S16_LE;
+      format=AFMT_S16_NE;
       if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)
       {
          perror("SNDCTL_DSP_SETFMT");
@@ -401,6 +401,7 @@
    int channels=-1;
    int rate=0;
    int extra_headers;
+   int wav_format=0;
 
    enh_enabled = 1;
 
@@ -492,6 +493,9 @@
       outFile=argv[optind+1];
    else
       outFile = "";
+   wav_format = strlen(outFile)>=4 && (
+                                       strcmp(outFile+strlen(outFile)-4,".wav")==0
+                                       || strcmp(inFile+strlen(inFile)-4,".WAV")==0);
    /*Open input file*/
    if (strcmp(inFile, "-")==0)
    {
@@ -611,8 +615,14 @@
                         output[i]=-32000.0;
                   }
                   /*Convert to short and save to output file*/
-                  for (i=0;i<frame_size*channels;i++)
-                     out[i]=(short)le_short((short)floor(.5+output[i]));
+		  if (strlen(outFile)!=0)
+                  {
+                     for (i=0;i<frame_size*channels;i++)
+                        out[i]=(short)le_short((short)floor(.5+output[i]));
+		  } else {
+                     for (i=0;i<frame_size*channels;i++)
+                        out[i]=(short)floor(.5+output[i]);
+		  }
 #if defined WIN32 || defined _WIN32
                   if (strlen(outFile)==0)
                       WIN_Play_Samples (out, sizeof(short) * frame_size*channels);
@@ -631,7 +641,7 @@
 
    }
 
-   if (strcmp(outFile+strlen(outFile)-4,".wav")==0 || strcmp(inFile+strlen(inFile)-4,".WAV")==0)
+   if (wav_format)
    {
       if (fseek(fout,4,SEEK_SET)==0)
       {
@@ -663,7 +673,7 @@
    ogg_sync_clear(&oy);
 
 #if defined WIN32 || defined _WIN32
-   if (fout && strlen(outFile)==0)
+   if (strlen(outFile)==0)
       WIN_Audio_close ();
 #endif
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list