Blob Blame History Raw
diff -rupN qtractor-0.5.5.old/configure.ac qtractor-0.5.5/configure.ac
--- qtractor-0.5.5.old/configure.ac	2012-06-15 06:12:54.000000000 -0400
+++ qtractor-0.5.5/configure.ac	2012-06-24 04:26:35.076671263 -0400
@@ -550,12 +566,14 @@ if test "x$ac_libmad" = "xyes"; then
    AC_CHECK_LIB(mad, main, [ac_libmad="yes"], [ac_libmad="no"])
    if test "x$ac_libmad" = "xyes"; then
       AC_DEFINE(CONFIG_LIBMAD, 1, [Define if libmad is available.])
-      ac_libs="$ac_libs -lmad"
+      ac_have_libmad=1
    else
       AC_MSG_WARN([*** mad library not found.])
       AC_MSG_WARN([*** MPEG Layer III audio file support will be disabled.])
+      ac_have_libmad=0
    fi
 fi
+AC_SUBST(ac_have_libmad)
 
 # Check for optional libsamplerate library.
 if test "x$ac_libsamplerate" = "xyes"; then
@@ -776,6 +776,9 @@ else
    AC_MSG_WARN([*** JACK metadata support will be disabled.])
 fi
 
+# To dlopen plugins
+ac_libs="$ac_libs -ldl"
+
 # Some recent distros (eg. fedora, debian) require this.
 ac_libs="$ac_libs -lX11"
 
@@ -1155,6 +1176,7 @@ echo "  Gradient eye-candy . . . . . . .
 echo "  Debugger stack-trace (gdb) . . . . . . . . . . . .: $ac_stacktrace"
 echo
 echo "  Install prefix . . . . . . . . . . . . . . . . . .: $ac_prefix"
+echo "  Install libdir . . . . . . . . . . . . . . . . . .: $ac_libdir"
 echo
 echo "Now type 'make', followed by 'make install' as root."
 echo
diff -rupN qtractor-0.5.5.old/Makefile.in qtractor-0.5.5/Makefile.in
--- qtractor-0.5.5.old/Makefile.in	2012-05-25 12:55:11.000000000 -0400
+++ qtractor-0.5.5/Makefile.in	2012-06-24 04:39:18.798372418 -0400
@@ -2,10 +2,16 @@ prefix  = @ac_prefix@
 qmake   = @ac_qmake@
 lupdate = @ac_lupdate@
 lrelease = @ac_lrelease@
+have_libmad = @ac_have_libmad@
 
 name    = qtractor
 
 target  = src/$(name)
+ifeq ($(have_libmad), 1)
+	mad_target = lib$(name)_mad.so
+	mad_install_target = install_mad
+	mad_clean_target = clean_mad
+endif
 
 headers = \
 	src/config.h \
@@ -17,7 +23,6 @@ headers = \
 	src/qtractorAudioEngine.h \
 	src/qtractorAudioFile.h \
 	src/qtractorAudioListView.h \
-	src/qtractorAudioMadFile.h \
 	src/qtractorAudioMeter.h \
 	src/qtractorAudioMonitor.h \
 	src/qtractorAudioPeak.h \
@@ -128,6 +133,12 @@ headers = \
 	src/qtractorTimeScaleForm.h \
 	src/qtractorTrackForm.h
 
+mad_headers = \
+	src/config.h \
+	src/qtractorAudioMadFile.h \
+	src/qtractorAudioFile.h
+
+
 sources = \
 	src/qtractor.cpp \
 	src/qtractorAudioBuffer.cpp \
@@ -136,7 +147,6 @@ sources = \
 	src/qtractorAudioEngine.cpp \
 	src/qtractorAudioFile.cpp \
 	src/qtractorAudioListView.cpp \
-	src/qtractorAudioMadFile.cpp \
 	src/qtractorAudioMeter.cpp \
 	src/qtractorAudioMonitor.cpp \
 	src/qtractorAudioPeak.cpp \
@@ -239,6 +249,9 @@ sources = \
 	src/qtractorTimeScaleForm.cpp \
 	src/qtractorTrackForm.cpp
 
+mad_sources = \
+	src/qtractorAudioMadFile.cpp \
+
 forms = \
 	src/qtractorBusForm.ui \
 	src/qtractorClipForm.ui \
diff -rupN qtractor-0.5.5.old/qtractor_mad.pro qtractor-0.5.5/qtractor_mad.pro
--- qtractor-0.5.5.old/qtractor_mad.pro	1969-12-31 19:00:00.000000000 -0500
+++ qtractor-0.5.5/qtractor_mad.pro	2012-06-24 04:27:11.320512459 -0400
@@ -0,0 +1,9 @@
+# qtractor_mad.pro
+#
+QMAKEVERSION = $$[QMAKE_VERSION]
+ISQT4 = $$find(QMAKEVERSION, ^[2-9])
+isEmpty( ISQT4 ) {
+	error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
+}
+
+include(src/mad.pri)
diff -rupN qtractor-0.5.5.old/src/config.h.in qtractor-0.5.5/src/config.h.in
--- qtractor-0.5.5.old/src/config.h.in	2012-06-15 06:13:53.000000000 -0400
+++ qtractor-0.5.5/src/config.h.in	2012-06-24 04:04:30.131475190 -0400
@@ -84,6 +87,9 @@
 /* Define if NSM support is available. */
 #undef CONFIG_NSM
 
+/* Default plugin installation dir. */
+#undef CONFIG_PLUGINDIR
+
 /* Default installation prefix. */
 #undef CONFIG_PREFIX
 
diff -rupN qtractor-0.5.5.old/src/mad.pri qtractor-0.5.5/src/mad.pri
--- qtractor-0.5.5.old/src/mad.pri	1969-12-31 19:00:00.000000000 -0500
+++ qtractor-0.5.5/src/mad.pri	2012-06-24 04:26:06.994794380 -0400
@@ -0,0 +1,38 @@
+# qtractor.pro
+#
+TARGET = qtractor_mad
+
+TEMPLATE = lib
+CONFIG += plugin
+QT -= gui
+DEPENDPATH += .
+INCLUDEPATH += .
+
+include(src/src.pri)
+
+#DEFINES += DEBUG
+
+HEADERS += src/config.h \
+	src/qtractorAudioFile.h \
+	src/qtractorAudioMadFile.h
+
+SOURCES += \
+	src/qtractorAudioMadFile.cpp
+
+unix {
+	# Additional link flags
+	LIBS = -lmad
+
+	# variables
+	OBJECTS_DIR = .obj
+
+	isEmpty(LIBDIR) {
+		LIBDIR = $$PREFIX/lib
+	}
+
+	# make install
+	INSTALLS += target
+
+	target.path = $$LIBDIR/qtractor
+
+}
diff -rupN qtractor-0.5.5.old/src/qtractorAudioFile.cpp qtractor-0.5.5/src/qtractorAudioFile.cpp
--- qtractor-0.5.5.old/src/qtractorAudioFile.cpp	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioFile.cpp	2012-06-24 04:09:36.980160092 -0400
@@ -29,7 +29,7 @@
 #include <QRegExp>
 
 #include <stdlib.h>
-
+#include <dlfcn.h>
 
 //----------------------------------------------------------------------
 // class qtractorAudioFileFactory -- Audio file factory (singleton).
@@ -131,7 +131,8 @@ qtractorAudioFileFactory::qtractorAudioF
 	m_pDefaultFormat = pFormat;
 #endif
 
-#ifdef CONFIG_LIBMAD
+if (madPluginExists())
+{
 	// Add for libmad (mp3 read-only)...
 	pFormat = new FileFormat;
 	pFormat->type = MadFile;
@@ -142,7 +143,7 @@ qtractorAudioFileFactory::qtractorAudioF
 	m_types[pFormat->ext] = pFormat;
 	m_filters.append(
 		sFilterMask.arg(pFormat->name).arg(sExtMask.arg(pFormat->ext)));
-#endif
+ }
 
 	// Finally, simply build the all (most commonly) supported files entry.
 	QRegExp rx("^(aif(|f)|fla(|c)|mp3|ogg|w(av|64))", Qt::CaseInsensitive);
@@ -198,13 +199,12 @@ qtractorAudioFile *qtractorAudioFileFact
 	case VorbisFile:
 		return new qtractorAudioVorbisFile(iChannels, iSampleRate, iBufferSize);
 	case MadFile:
-		return new qtractorAudioMadFile(iBufferSize);
+		return getQtractorAudioMadFile(iBufferSize);
 	default:
 		return NULL;
 	}
 }
 
-
 const qtractorAudioFileFactory::FileFormats& qtractorAudioFileFactory::formats (void)
 {
 	return getInstance().m_formats;
@@ -322,5 +322,44 @@ int qtractorAudioFileFactory::format (
 	return 0;
 }
 
+bool madPluginExists()
+{
+	void* madplugin = madPluginLibrary();
+	if (!madplugin) return false;
+	dlclose(madplugin);
+	return true;
+}
+
+void* madPluginLibrary()
+{
+	// load the mad plugin library
+	void* madplugin = dlopen(CONFIG_PLUGINDIR "/libqtractor_mad.so", RTLD_LAZY);
+	if (!madplugin) {
+#ifdef CONFIG_DEBUG
+		qDebug("Cannot load library: %s", dlerror());
+#endif
+		return NULL;
+	}
+	return madplugin;
+}
+
+qtractorAudioFile* getQtractorAudioMadFile(unsigned int iBufferSize) 
+{
+	void* madplugin = madPluginLibrary();
+	// reset errors
+	dlerror();
+	// load the symbols
+	create_t* create_qtractorAudioMadFile = (create_t*) dlsym(madplugin, "createQtractorAudioMadFile");
+	const char* dlsym_error = dlerror();
+	if (dlsym_error) {
+#ifdef CONFIG_DEBUG
+		qDebug("Cannot load symbol create_qtractorAudioMadFile: %s", dlsym_error)
+#endif
+		return NULL;
+	}
+	// create an instance of the class
+	return create_qtractorAudioMadFile(iBufferSize);
+}
+
 
 // end of qtractorAudioFile.cpp
diff -rupN qtractor-0.5.5.old/src/qtractorAudioFile.h qtractor-0.5.5/src/qtractorAudioFile.h
--- qtractor-0.5.5.old/src/qtractorAudioFile.h	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioFile.h	2012-06-24 04:04:30.133475181 -0400
@@ -59,7 +59,6 @@ public:
 	virtual unsigned int sampleRate() const = 0;
 };
 
-
 //----------------------------------------------------------------------
 // class qtractorAudioFileFactory -- Audio file factory (singleton).
 //
@@ -150,6 +149,19 @@ private:
 	int m_iDefaultQuality;
 };
 
+// Dlopen the plugin library to get an qtractorAudioFile instance
+qtractorAudioFile* getQtractorAudioMadFile(unsigned int iBufferSize);
+// the type of the create factory
+typedef qtractorAudioFile* create_t(unsigned int iBufferSize);
+// Note that we will also need a destroy factory in case we overload "delete".
+// If this is the case the dlopened library should handle its own destruction.
+// Since we don't overload delete, we skip this factory for now.
+
+// Check whether we can dlopen the mad plugin library
+bool madPluginExists();
+// Give us the mad plugin library object
+void* madPluginLibrary();
+
 
 #endif  // __qtractorAudioFile_h
 
diff -rupN qtractor-0.5.5.old/src/qtractorAudioMadFile.cpp qtractor-0.5.5/src/qtractorAudioMadFile.cpp
--- qtractor-0.5.5.old/src/qtractorAudioMadFile.cpp	2011-05-14 18:03:38.000000000 -0400
+++ qtractor-0.5.5/src/qtractorAudioMadFile.cpp	2012-06-24 04:04:30.134475176 -0400
@@ -24,6 +24,11 @@
 
 #include <sys/stat.h>
 
+// factory loader function
+extern "C" qtractorAudioFile* createQtractorAudioMadFile( unsigned int iBufferSize ) {
+  return new qtractorAudioMadFile(iBufferSize);
+}
+
 
 //----------------------------------------------------------------------
 // class qtractorAudioMadFile -- Buffered audio file implementation.
diff -rupN qtractor-0.5.5.old/src/qtractorMainForm.cpp qtractor-0.5.5/src/qtractorMainForm.cpp
--- qtractor-0.5.5.old/src/qtractorMainForm.cpp	2012-06-11 13:26:14.000000000 -0400
+++ qtractor-0.5.5/src/qtractorMainForm.cpp	2012-06-24 04:04:30.141475146 -0400
@@ -39,6 +39,7 @@
 #include "qtractorAudioPeak.h"
 #include "qtractorAudioBuffer.h"
 #include "qtractorAudioEngine.h"
+#include "qtractorAudioFile.h"
 #include "qtractorMidiEngine.h"
 
 #include "qtractorSessionDocument.h"
@@ -4801,9 +4802,9 @@ void qtractorMainForm::helpAbout (void)
 
 	list << tr("Ogg Vorbis (libvorbis) file support disabled.");
 #endif
-#ifndef CONFIG_LIBMAD
+if (!madPluginExists()) {
 	list << tr("MPEG-1 Audio Layer 3 (libmad) file support disabled.");
-#endif
+}
 #ifndef CONFIG_LIBSAMPLERATE
 	list << tr("Sample-rate conversion (libsamplerate) disabled.");
 #endif
diff -Nurp qtractor-0.6.6/configure.ac qtractor-0.6.6.mod/configure.ac
--- qtractor-0.6.6/configure.ac	2015-04-29 07:17:24.800743638 +0200
+++ qtractor-0.6.6.mod/configure.ac	2015-04-29 07:19:34.351744874 +0200
@@ -22,6 +22,22 @@ eval ac_libdir=$libdir
 AC_SUBST(ac_libdir)
 AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["$ac_libdir"], [Default library path.])
 
+# Set default installation libdir and plugindir.
+if test "x$exec_prefix" = "xNONE"; then
+    exec_prefix="${ac_prefix}"
+fi
+
+ac_libdir=$libdir
+if test "x$ac_libdir" = "xNONE"; then
+    ac_libdir=$ac_default_libdir
+fi
+# We want to make sure that this expands out. Otherwise we have bash variables
+# such as ${exec_prefix} inside config.h:
+eval ac_libdir="\"$ac_libdir\""
+AC_SUBST(ac_libdir)
+AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["$ac_libdir"], [Default installation libdir.])
+AC_DEFINE_UNQUOTED(CONFIG_PLUGINDIR, ["$ac_libdir/qtractor"], [Default plugin installation dir.])
+
 # Enable debugging argument option.
 AC_ARG_ENABLE(debug,
   AC_HELP_STRING([--enable-debug], [enable debugging (default=no)]),
diff -Nurp qtractor-0.6.6/src/src.pro qtractor-0.6.6.mod/src/src.pro
--- qtractor-0.6.6/src/src.pro	2015-03-29 16:54:06.966664956 +0200
+++ qtractor-0.6.6.mod/src/src.pro	2015-04-29 07:21:36.791746043 +0200
@@ -18,7 +18,6 @@ HEADERS += config.h \
 	qtractorAudioEngine.h \
 	qtractorAudioFile.h \
 	qtractorAudioListView.h \
-	qtractorAudioMadFile.h \
 	qtractorAudioMeter.h \
 	qtractorAudioMonitor.h \
 	qtractorAudioPeak.h \
@@ -143,7 +142,6 @@ SOURCES += \
 	qtractorAudioEngine.cpp \
 	qtractorAudioFile.cpp \
 	qtractorAudioListView.cpp \
-	qtractorAudioMadFile.cpp \
 	qtractorAudioMeter.cpp \
 	qtractorAudioMonitor.cpp \
 	qtractorAudioPeak.cpp \