changeset 348:edda24bb85fc

* Skip ID3 block when reading MP3 files (so long as ID3 support is included) * Show progress when retrieving audio file from playlist * Avoid -- but do not actually fix -- segmentation fault on exit. I am totally stumped at the moment about why both the PA and JACK audio targets should crash when properly shut down. For the moment, we just don't shut them down... * Fix incorrect behaviour (introduced on Friday as part of a different fix) when replacing main model in situation where no current main model exists
author Chris Cannam
date Fri, 30 Nov 2007 17:31:09 +0000
parents a9ccd644f3bf
children d7c41483af8f
files data/fileio/MP3FileReader.cpp
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp	Thu Nov 29 17:10:53 2007 +0000
+++ b/data/fileio/MP3FileReader.cpp	Fri Nov 30 17:31:09 2007 +0000
@@ -206,7 +206,7 @@
     unsigned int nstrings = id3_field_getnstrings(&frame->fields[1]);
     if (nstrings == 0) {
 #ifdef DEBUG_ID3TAG
-        std::cerr << "MP3FileReader::loadTags: No data for \"" << name << "\" in ID3 tag" << std::endl;
+        std::cerr << "MP3FileReader::loadTags: No strings for \"" << name << "\" in ID3 tag" << std::endl;
 #endif
         return "";
     }
@@ -291,7 +291,22 @@
     DecoderData *data = (DecoderData *)dp;
 
     if (!data->length) return MAD_FLOW_STOP;
-    mad_stream_buffer(stream, data->start, data->length);
+
+    unsigned char const *start = data->start;
+    unsigned long length = data->length;
+
+#ifdef HAVE_ID3TAG
+    if (length > ID3_TAG_QUERYSIZE) {
+        int taglen = id3_tag_query(start, ID3_TAG_QUERYSIZE);
+        if (taglen > 0) {
+//            std::cerr << "ID3 tag length to skip: " << taglen << std::endl;
+            start += taglen;
+            length -= taglen;
+        }
+    }
+#endif
+
+    mad_stream_buffer(stream, start, length);
     data->length = 0;
 
     return MAD_FLOW_CONTINUE;