Update of /cvsroot/audacity/audacity-src/src/import
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv10710

Modified Files:
        ImportMP3.cpp 
Log Message:
Fix importing MP3 files with ID3v2 tags.

Index: ImportMP3.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/import/ImportMP3.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- ImportMP3.cpp       23 Sep 2006 02:26:55 -0000      1.30
+++ ImportMP3.cpp       28 Apr 2007 08:51:20 -0000      1.31
@@ -66,6 +66,10 @@
 
 extern "C" {
 #include "mad.h"
+
+#ifdef USE_LIBID3TAG 
+#include <id3tag.h>
+#endif
 }
 
 #include "../WaveTrack.h"
@@ -85,6 +89,7 @@
    progress_callback_t progressCallback;
    void *userData;
    bool cancelled;
+   bool id3checked;
 };
 
 class MP3ImportPlugin : public ImportPlugin
@@ -197,8 +202,9 @@
 
    mPrivateData.file        = mFile;
    mPrivateData.inputBuffer = new unsigned char [INPUT_BUFFER_SIZE];
-   mPrivateData.channels   = NULL;
+   mPrivateData.channels    = NULL;
    mPrivateData.cancelled   = false;
+   mPrivateData.id3checked  = false;
    mPrivateData.numChannels = 0;
    mPrivateData.trackFactory= trackFactory;
 
@@ -277,6 +283,21 @@
       return MAD_FLOW_STOP;
    }
 
+#ifdef USE_LIBID3TAG 
+   if (!data->id3checked) {
+      off_t read = data->file->Read(data->inputBuffer, ID3_TAG_QUERYSIZE);
+      int len = id3_tag_query(data->inputBuffer, ID3_TAG_QUERYSIZE);
+      if (len > 0) {
+         data->file->Seek(len, wxFromCurrent);
+      }
+      else {
+         data->file->Seek(0);
+      }
+      
+      data->id3checked = true;
+   }
+#endif
+
    /* "Each time you refill your buffer, you need to preserve the data in
     *  your existing buffer from stream.next_frame to the end.
     *


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to