Could MP3 support be made optional?
Posted: Sun Feb 20, 2011 12:06 pm
Something like this:
It would help package it in distributions that can't package MP3 support because of patents.
Code: Select all
Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -36,7 +35,7 @@ AC_SEARCH_LIBS([TIFFOpen], [tiff], [], A
AC_SEARCH_LIBS([FT_Load_Glyph], [freetype], [], AC_MSG_ERROR([Can't LÖVE without FreeType]))
AC_SEARCH_LIBS([PHYSFS_init], [physfs], [], AC_MSG_ERROR([Can't LÖVE without PhysicsFS]))
AC_SEARCH_LIBS([ModPlug_Load], [modplug], [], AC_MSG_ERROR([Can't LÖVE without ModPlug]))
-AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [], AC_MSG_ERROR([Can't LÖVE without Mpg123]))
+AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [AC_DEFINE([WITH_MPG123], [], [Description for mpg123])], AC_MSG_WARN([Mpg123 is not available]))
AC_SEARCH_LIBS([mpg123_seek_64], [mpg123], AC_SUBST([FILE_OFFSET],[-D_FILE_OFFSET_BITS=64]), AC_SUBST([FILE_OFFSET],[]))
AC_SEARCH_LIBS([ov_open], [vorbisfile], [], AC_MSG_ERROR([Can't LÖVE without VorbisFile]))
AC_CONFIG_FILES([
Index: src/modules/sound/lullaby/Mpg123Decoder.cpp
===================================================================
--- src/modules/sound/lullaby/Mpg123Decoder.cpp.orig
+++ src/modules/sound/lullaby/Mpg123Decoder.cpp
@@ -18,6 +18,10 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
+#include "../config.h"
+
+#ifdef WITH_MPG123
+
#include "Mpg123Decoder.h"
#include <common/Exception.h>
@@ -227,3 +231,4 @@ namespace lullaby
} // lullaby
} // sound
} // love
+#endif
Index: src/modules/sound/lullaby/Mpg123Decoder.h
===================================================================
--- src/modules/sound/lullaby/Mpg123Decoder.h.orig
+++ src/modules/sound/lullaby/Mpg123Decoder.h
@@ -17,7 +17,9 @@
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
+#include "../config.h"
+#ifdef WITH_MPG123
#ifndef LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
#define LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
@@ -77,3 +79,4 @@ namespace lullaby
} // love
#endif // LOVE_SOUND_LULLABY_LIBMPG123_DECODER_H
+#endif
Index: src/modules/sound/lullaby/Sound.cpp
===================================================================
--- src/modules/sound/lullaby/Sound.cpp.orig
+++ src/modules/sound/lullaby/Sound.cpp
@@ -18,10 +18,14 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
+#include "../config.h"
+
#include "Sound.h"
#include "ModPlugDecoder.h"
+#ifdef WITH_MPG123
#include "Mpg123Decoder.h"
+#endif
#include "VorbisDecoder.h"
//#include "FLACDecoder.h"
@@ -37,7 +41,9 @@ namespace lullaby
Sound::~Sound()
{
+ #ifdef WITH_MPG123
Mpg123Decoder::quit();
+ #endif
}
const char * Sound::getName() const
@@ -55,8 +61,10 @@ namespace lullaby
// Find a suitable decoder here, and return it.
if(ModPlugDecoder::accepts(ext))
decoder = new ModPlugDecoder(data, ext, bufferSize);
+ #ifdef WITH_MPG123
else if(Mpg123Decoder::accepts(ext))
decoder = new Mpg123Decoder(data, ext, bufferSize);
+ #endif
else if(VorbisDecoder::accepts(ext))
decoder = new VorbisDecoder(data, ext, bufferSize);
/*else if (FLACDecoder::accepts(ext))