[xiph-commits] r17743 - trunk/squishyball

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Dec 8 19:38:37 PST 2010


Author: xiphmont
Date: 2010-12-08 19:38:36 -0800 (Wed, 08 Dec 2010)
New Revision: 17743

Modified:
   trunk/squishyball/configure.ac
   trunk/squishyball/loader.c
Log:
Fix a bug in the flac load/decode


Modified: trunk/squishyball/configure.ac
===================================================================
--- trunk/squishyball/configure.ac	2010-12-08 23:22:00 UTC (rev 17742)
+++ trunk/squishyball/configure.ac	2010-12-09 03:38:36 UTC (rev 17743)
@@ -4,7 +4,7 @@
 cflags_save="$CFLAGS"
 AC_PREREQ(2.57)
 AC_INIT(main.c)
-AM_INIT_AUTOMAKE(squishyball, 20101206, [vorbis-dev at xiph.org])
+AM_INIT_AUTOMAKE(squishyball, 20101208, [vorbis-dev at xiph.org])
 AC_CONFIG_FILES([Makefile])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
 

Modified: trunk/squishyball/loader.c
===================================================================
--- trunk/squishyball/loader.c	2010-12-08 23:22:00 UTC (rev 17742)
+++ trunk/squishyball/loader.c	2010-12-09 03:38:36 UTC (rev 17743)
@@ -700,7 +700,7 @@
   int i, j;
 
   if(pcm->data == NULL){
-    /* lasy initialization */
+    /* lazy initialization */
     pcm->ch = channels;
     pcm->bits = (bits_per_sample+7)/8*8;
     pcm->size *= pcm->bits/8*channels;
@@ -782,12 +782,22 @@
 }
 
 static pcm_t *flac_load_i(char *path, FILE *in, int oggp){
-  pcm_t *pcm = calloc(1,sizeof(pcm_t));
-  flac_callback_arg *flac = calloc(1,sizeof(flac_callback_arg));
-  FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
+  pcm_t *pcm;
+  flac_callback_arg *flac;
+  FLAC__StreamDecoder *decoder;
   FLAC__bool ret;
+
+  if(fseek(in,0,SEEK_SET)==-1){
+    fprintf(stderr,"%s: Failed to seek\n",path);
+    goto err;
+  }
+
+  pcm = calloc(1,sizeof(pcm_t));
+  flac = calloc(1,sizeof(flac_callback_arg));
+  decoder = FLAC__stream_decoder_new();
   FLAC__stream_decoder_set_md5_checking(decoder, true);
   FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO);
+
   pcm->name=strdup(trim_path(path));
   flac->in=in;
   flac->pcm=pcm;
@@ -856,6 +866,8 @@
   if(sb_verbose)
     fprintf(stderr,"\r%s: loaded.                 \n",path);
   return pcm;
+ err:
+  return NULL;
 }
 
 static pcm_t *flac_load(char *path, FILE *in){



More information about the commits mailing list