[xiph-commits] r3330 - libfishsound/branches/1.0-stable-flac/src/libfishsound

conrad at svn.annodex.net conrad at svn.annodex.net
Thu Jan 10 00:36:27 PST 2008


Author: conrad
Date: 2008-01-10 00:36:27 -0800 (Thu, 10 Jan 2008)
New Revision: 3330

Modified:
   libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c
Log:
wibble: clean up debug statements


Modified: libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c
===================================================================
--- libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c	2008-01-10 08:19:48 UTC (rev 3329)
+++ libfishsound/branches/1.0-stable-flac/src/libfishsound/flac.c	2008-01-10 08:36:27 UTC (rev 3330)
@@ -76,16 +76,16 @@
   FishSound* fsound = (FishSound*)client_data;
   FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data;
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_read_callback\n");
+  printf("fs_flac_read_callback: IN\n");
 #endif
   if (fi->bufferlength > *bytes) {
 #ifdef DEBUG
-    fprintf(stderr, "too much data\n");
+    printf("fs_flac_read_callback: too much data\n");
 #endif
     return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
   } else if (fi->bufferlength < 1) {
 #ifdef DEBUG
-    fprintf(stderr, "no data, %ld\n",fi->bufferlength);
+    printf("fs_flac_read_callback: no data, %ld\n",fi->bufferlength);
 #endif
     return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
   }
@@ -105,7 +105,7 @@
   FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data;
   int i, j, offset;
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_write_callback\n");
+  printf("fs_flac_write_callback: IN\n");
 #endif
   fsound->frameno += frame->header.blocksize*frame->header.channels;
   if (fsound->callback.decoded_float) {
@@ -146,7 +146,7 @@
   FishSound* fsound = (FishSound*)client_data;
   /*  FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; */
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_meta_callback\n");
+  printf("fs_flac_meta_callback: IN\n");
 #endif
   switch (metadata->type) {
   case FLAC__METADATA_TYPE_STREAMINFO:
@@ -155,7 +155,7 @@
     break;
   default:
 #ifdef DEBUG
-    fprintf(stderr, "not yet implemented type\n");
+    printf("fs_flac_meta_callback: not yet implemented type\n");
 #endif
     break;
   }
@@ -167,9 +167,9 @@
                        void *client_data)
 {
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_error_callback\n");
+  printf("fs_flac_error_callback: IN\n");
 #endif
-  fprintf(stderr, "ERROR: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
+  fprintf(stderr, "FLAC ERROR: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
 }
 #endif
 
@@ -183,8 +183,8 @@
   FishSound* fsound = (FishSound*)client_data;
   FishSoundFlacInfo *fi = fsound->codec_data;
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_enc_write_callback\n");
-  printf("bytes: %d, samples: %d\n", bytes, samples);
+  printf("fs_flac_enc_write_callback: IN\n");
+  printf("fs_flac_enc_write_callback: bytes: %d, samples: %d\n", bytes, samples);
 #endif
   if (fsound->callback.encoded) {
     FishSoundEncoded encoded = (FishSoundEncoded) fsound->callback.encoded;
@@ -195,8 +195,8 @@
          * as described in http://flac.sourceforge.net/ogg_mapping.html.
          */
 #ifdef DEBUG
-        printf("fs_flac_enc_write_callback: generating FLAC header packet: %x\n",
-               buffer[0]);
+        printf("fs_flac_enc_write_callback: generating FLAC header packet: "
+               "%c%c%c%c\n", buffer[0], buffer[1], buffer[2], buffer[3]);
 #endif
 	fi->buffer = (unsigned char*)malloc(sizeof(unsigned char)*(bytes+9));
 	fi->buffer[0] = 0x7f;
@@ -231,6 +231,7 @@
 	       fsound->user_data);
     }
   }
+
   return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
 }
 
@@ -242,11 +243,14 @@
   /* FishSound* fsound = (FishSound*)client_data; */
   /* FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; */
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_meta_callback\n");
+  printf("fs_flac_meta_callback: IN\n");
 #endif
   switch (metadata->type) {
   case FLAC__METADATA_TYPE_STREAMINFO:
-    printf("channels %d\n", metadata->data.stream_info.channels);
+#ifdef DEBUG
+    printf("fs_flac_meta_callback: channels %d\n",
+           metadata->data.stream_info.channels);
+#endif
     /*
     fsound->info.channels = metadata->data.stream_info.channels;
     fsound->info.samplerate = metadata->data.stream_info.sample_rate;
@@ -254,7 +258,7 @@
     break;
   default:
 #ifdef DEBUG
-    fprintf(stderr, "not yet implemented type\n");
+    printf("fs_flac_enc_meta_callback: metadata type not yet implemented\n");
 #endif
     break;
   }
@@ -268,7 +272,7 @@
   if (buf[0] != 0x7f) return FISH_SOUND_UNKNOWN;
   if (!strncmp ((char *)buf+1, "FLAC", 4)) {
 #ifdef DEBUG
-    fprintf(stderr, "flac found\n");
+    printf("fish_sound_flac_identify: flac found\n");
 #endif
     /* if only a short buffer was passed, do a weak identify */
     if (bytes == 8) return FISH_SOUND_FLAC;
@@ -278,6 +282,7 @@
       return FISH_SOUND_FLAC;
     }
   }
+
   return FISH_SOUND_UNKNOWN;
 }
 
@@ -311,7 +316,7 @@
   FishSoundFlacInfo *fi = fsound->codec_data;
   int i, *p = (int *)pcm;
 #ifdef DEBUG
-  printf("frames: %ld\n", frames);
+  printf("fs_flac_encode_i_ilv: frames: %ld\n", frames);
 #endif
   if (fi->packetno == 0)
     fs_flac_enc_headers (fsound);
@@ -330,7 +335,7 @@
   int i;
   long length = frames * fsound->info.channels;
 #ifdef DEBUG
-  fprintf(stderr, "fs_flac_encode_f_ilv\n");
+  printf("fs_flac_encode_f_ilv: IN\n");
 #endif
   fi->pcm = realloc(fi->pcm, sizeof(FLAC__int32)*fsound->info.channels*frames);
   buffer = (FLAC__int32*) fi->pcm;
@@ -341,13 +346,14 @@
     fs_flac_enc_headers (fsound);
   FLAC__stream_encoder_process_interleaved(fi->fse, buffer, frames);
   fi->packetno++;
+
   return frames;
 }
 #endif
 
 #if FS_DECODE
 static void*
-process_header(FishSound * fsound, unsigned char *buf, long bytes)
+fs_flac_decode_header (FishSound * fsound, unsigned char *buf, long bytes)
 {
   FishSoundFlacInfo *fi = fsound->codec_data;
   if (buf[0] != 0x7f) return NULL;
@@ -355,20 +361,24 @@
   fi->version.major = buf[5];
   fi->version.minor = buf[6];
 #ifdef DEBUG
-  printf("Flac Ogg Mapping Version: %d.%d\n",
+  printf("fs_flac_decode_header : Flac Ogg Mapping Version: %d.%d\n",
          fi->version.major, fi->version.minor);
 #endif
   fi->header_packets = buf[7] << 8 | buf[8];
 #ifdef DEBUG
-  printf("Number of Header packets: %d\n", fi->header_packets);
+  printf("fs_flac_decode_header: Number of Header packets: %d\n",
+         fi->header_packets);
 #endif
 
-  if ((fi->fsd = FLAC__stream_decoder_new()) == NULL) return NULL;
+  if ((fi->fsd = FLAC__stream_decoder_new()) == NULL)
+    return NULL;
+
   FLAC__stream_decoder_set_read_callback(fi->fsd, fs_flac_read_callback);
   FLAC__stream_decoder_set_write_callback(fi->fsd, fs_flac_write_callback);
   FLAC__stream_decoder_set_metadata_callback(fi->fsd, fs_flac_meta_callback);
   FLAC__stream_decoder_set_error_callback(fi->fsd, fs_flac_error_callback);
   FLAC__stream_decoder_set_client_data(fi->fsd, fsound);
+
   if (FLAC__stream_decoder_init(fi->fsd) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
     return NULL;
 
@@ -383,7 +393,7 @@
   printf("fs_flac_decode: IN\n");
 #endif
   if (fi->packetno == 0) {
-    if (process_header(fsound, buf, bytes) == NULL) {
+    if (fs_flac_decode_header (fsound, buf, bytes) == NULL) {
 #ifdef DEBUG
       printf("fs_flac_decode: Error reading header\n");
 #endif
@@ -430,6 +440,7 @@
     FLAC__stream_decoder_process_single(fi->fsd);
   }
   fi->packetno++;
+
   return 0;
 }
 #else /* !FS_DECODE */



More information about the commits mailing list