Hey all,

Here are two patches for current trunk (1.8).  The first adds mmap
support for linux when loading mp3s.  This change alone eliminates all
of the xruns and stuttering I was getting when loading new tracks.  This
is a huge improvement for me in very few lines of code.

Secondly, I go back and forth between 1.7 and 1.8 a lot, so 1.8's legacy
libraryimporter is a pain in the ass because it's always moving my old
1.7 database aside (and it doesn't overwrite old copies of
mixxxtrack.xml, so it causes data loss!).  This patch has the importer
check for a stub file and does the upgrade if the file isn't there.

owen
=== modified file 'mixxx/src/library/legacylibraryimporter.cpp'
--- mixxx/src/library/legacylibraryimporter.cpp	2010-01-11 05:30:11 +0000
+++ mixxx/src/library/legacylibraryimporter.cpp	2010-02-13 14:32:47 +0000
@@ -152,9 +152,16 @@
             }
         }
 
-        //now change the file to mixxxtrack.bak so that its not readded next time program loads
-        file.copy(QDir::homePath().append("/").append(SETTINGS_PATH).append("mixxxtrack.bak"));
-        file.remove();
+        QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED");
+        //now create stub so that the library is not readded next time program loads
+        QFile upgradefile(upgrade_filename);
+        if (!upgradefile.open(QIODevice::WriteOnly | QIODevice::Text))
+            qDebug() << "Couldn't open" << upgrade_filename << "for writing";
+        else
+        {
+            file.write("",0);
+            file.close();
+        }
     } else {
         qDebug() << errorMsg << " line: " << errorLine << " column: " << errorColumn;
     }

=== modified file 'mixxx/src/library/libraryscanner.cpp'
--- mixxx/src/library/libraryscanner.cpp	2010-01-11 05:30:11 +0000
+++ mixxx/src/library/libraryscanner.cpp	2010-02-13 14:24:20 +0000
@@ -117,15 +117,24 @@
 
     QTime t2;
     t2.start();
+    
     //Try to upgrade the library from 1.7 (XML) to 1.8+ (DB) if needed
-    LegacyLibraryImporter libImport(m_trackDao, m_playlistDao);
-    connect(&libImport, SIGNAL(progress(QString)),
-            m_pProgress, SLOT(slotUpdate(QString)),
-            Qt::BlockingQueuedConnection);
-    m_database.transaction();
-    libImport.import();
-    m_database.commit();
-    qDebug("Legacy importer took %d ms", t2.elapsed());
+    QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED");
+    QFile upgradefile(upgrade_filename);
+    if (!upgradefile.open(QIODevice::ReadOnly | QIODevice::Text))
+    {
+	    LegacyLibraryImporter libImport(m_trackDao, m_playlistDao);
+	    connect(&libImport, SIGNAL(progress(QString)),
+	            m_pProgress, SLOT(slotUpdate(QString)),
+	            Qt::BlockingQueuedConnection);
+	    m_database.transaction();
+	    libImport.import();
+	    m_database.commit();
+	    qDebug("Legacy importer took %d ms", t2.elapsed());
+	    
+	}
+	else
+		upgradefile.close();
 
     // Time the library scanner.
     QTime t;

=== modified file 'mixxx/src/soundsourcemp3.cpp'
--- mixxx/src/soundsourcemp3.cpp	2010-01-20 22:15:37 +0000
+++ mixxx/src/soundsourcemp3.cpp	2010-02-13 14:01:06 +0000
@@ -18,6 +18,10 @@
 #include "soundsourcemp3.h"
 #include <QtDebug>
 
+#ifdef __LINUX__
+#include <sys/mman.h>
+#include <unistd.h>
+#endif
 
 SoundSourceMp3::SoundSourceMp3(QString qFilename) : SoundSource(qFilename)
 {
@@ -28,6 +32,16 @@
 
     // Read the whole file into inputbuf:
     inputbuf_len = file.size();
+    
+#ifdef __LINUX__
+	qDebug() << "Linux: mmapping file";
+    int handle = file.handle();
+    
+    //because we are doing shared memory, location of inputbuf may change
+    
+    inputbuf = (char*)mmap(0, inputbuf_len, PROT_READ, MAP_SHARED, handle, 0);
+    //inputbuf = (char*)file.map(0, inputbuf_len);
+#else    
     inputbuf = new char[inputbuf_len];
     unsigned int tmp = file.read(inputbuf, inputbuf_len);
     if (tmp != inputbuf_len) {
@@ -39,6 +53,7 @@
         //          << inputbuf_len
         //          << "bytes";
     }
+#endif
 
     // Transfer it to the mad stream-buffer:
     mad_stream_init(&Stream);
@@ -135,7 +150,9 @@
     mad_stream_finish(&Stream);
     mad_frame_finish(Frame);
     mad_synth_finish(&Synth);
+#ifndef __LINUX__    
     delete [] inputbuf;
+#endif
 
     m_qSeekList.clear();
 }

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to