1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-03 22:19:07 +02:00

Benjamin Drung's disable-dynamic-lame.patch for http://bugzilla.audacityteam.org/show_bug.cgi?id=233

This commit is contained in:
v.audacity 2012-06-25 01:41:57 +00:00
parent 4bb5f28b99
commit 87610cea39
7 changed files with 116 additions and 5 deletions

View File

@ -333,7 +333,7 @@ dnl can do without if they aren't available.
dnl------------------------------------------------------------- dnl-------------------------------------------------------------
dnl LIBRARIES="LIBVORBIS LIBMAD LIBSNDFILE LIBFLAC LIBID3TAG LIBSAMPLERATE LIBRESAMPLE LIBSBSMS LIBSOUNDTOUCH LIBNYQUIST LIBVAMP LIBEXPAT LIBTWOLAME FFMPEG LIBLRDF SLV2 REDLAND PORTSMF TAGLIB" dnl LIBRARIES="LIBVORBIS LIBMAD LIBSNDFILE LIBFLAC LIBID3TAG LIBSAMPLERATE LIBRESAMPLE LIBSBSMS LIBSOUNDTOUCH LIBNYQUIST LIBVAMP LIBEXPAT LIBTWOLAME FFMPEG LIBLRDF SLV2 REDLAND PORTSMF TAGLIB"
dnl disable plugin categorisation and LV2 libs for 1.3.7 release dnl disable plugin categorisation and LV2 libs for 1.3.7 release
LIBRARIES="LIBVORBIS LIBMAD LIBSNDFILE LIBFLAC LIBID3TAG LIBSAMPLERATE LIBRESAMPLE LIBSBSMS LIBSOUNDTOUCH LIBNYQUIST LIBVAMP LIBEXPAT LIBTWOLAME FFMPEG PORTSMF PORTAUDIO" LIBRARIES="LIBVORBIS LIBMAD LIBSNDFILE LIBFLAC LIBID3TAG LIBSAMPLERATE LIBRESAMPLE LIBSBSMS LIBSOUNDTOUCH LIBNYQUIST LIBVAMP LIBEXPAT LIBTWOLAME FFMPEG PORTSMF PORTAUDIO LAME"
AC_MSG_NOTICE([Determining what libraries are available in this tree and on the system]) AC_MSG_NOTICE([Determining what libraries are available in this tree and on the system])
@ -357,6 +357,7 @@ dnl AUDACITY_CHECKLIB_LIBLRDF
AUDACITY_CHECKLIB_PORTSMF AUDACITY_CHECKLIB_PORTSMF
dnl AUDACITY_CHECKLIB_TAGLIB dnl AUDACITY_CHECKLIB_TAGLIB
AUDACITY_CHECKLIB_PORTAUDIO AUDACITY_CHECKLIB_PORTAUDIO
AUDACITY_CHECKLIB_LAME
dnl Decide what libraries to build with, and whether to use system or local libraries dnl Decide what libraries to build with, and whether to use system or local libraries
dnl Set variables based on choices. dnl Set variables based on choices.

View File

@ -0,0 +1,41 @@
dnl Todo: Add Audacity / LAME license
dnl
dnl Please increment the serial number below whenever you alter this macro
dnl for the benefit of automatic macro update systems
# audacity_checklib_lame.m4 serial 1
dnl Check for a copy of lame, whoose headers we will use for the importer
AC_DEFUN([AUDACITY_CHECKLIB_LAME], [
AC_ARG_WITH(lame,
[AS_HELP_STRING([--with-lame],
[use lame for import and export support])],
LAME_ARGUMENT=$withval,
LAME_ARGUMENT="unspecified")
dnl See if LAME is installed in the system
AC_CHECK_LIB(mp3lame,
lame_set_VBR_q,
lib_found="yes",
lib_found="no")
AC_CHECK_HEADER(lame/lame.h,
header_found="yes",
header_found="no")
if test "x$lib_found" = "xyes" && test "x$header_found" = "xyes" ; then
LAME_SYSTEM_AVAILABLE="yes"
AC_MSG_NOTICE([LAME library is available as system library.])
if test "x$dynamic_loading" = "xno"; then
LAME_SYSTEM_LIBS="-lmp3lame"
LAME_SYSTEM_CPPSYMBOLS="DISABLE_DYNAMIC_LOADING_LAME"
fi
else
LAME_SYSTEM_AVAILABLE="no"
AC_MSG_NOTICE([LAME library is NOT available as system library.])
fi
dnl see if LAME is available in the source dir
LAME_LOCAL_AVAILABLE="yes"
])

View File

@ -84,6 +84,9 @@
*/ */
#undef USE_FFMPEG #undef USE_FFMPEG
/* Use system LAME library and disable dynamic loading of it. */
#undef DISABLE_DYNAMIC_LOADING_LAME
/* Define if LADSPA plug-ins are enabled */ /* Define if LADSPA plug-ins are enabled */
#undef USE_LADSPA #undef USE_LADSPA

View File

@ -90,7 +90,11 @@
#include "Export.h" #include "Export.h"
#if defined(DISABLE_DYNAMIC_LOADING_LAME)
#include <lame/lame.h>
#else
#include "lame.h" #include "lame.h"
#endif
#ifdef USE_LIBID3TAG #ifdef USE_LIBID3TAG
#include <id3tag.h> #include <id3tag.h>
@ -562,6 +566,8 @@ class FindDialog : public wxDialog
{ {
public: public:
#ifndef DISABLE_DYNAMIC_LOADING_LAME
FindDialog(wxWindow *parent, wxString path, wxString name, wxString type) FindDialog(wxWindow *parent, wxString path, wxString name, wxString type)
: wxDialog(parent, wxID_ANY, : wxDialog(parent, wxID_ANY,
/* i18n-hint: LAME is the name of an MP3 converter and should not be translated*/ /* i18n-hint: LAME is the name of an MP3 converter and should not be translated*/
@ -659,28 +665,36 @@ public:
return mLibPath.GetFullPath(); return mLibPath.GetFullPath();
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
private: private:
#ifndef DISABLE_DYNAMIC_LOADING_LAME
wxFileName mLibPath; wxFileName mLibPath;
wxString mPath; wxString mPath;
wxString mName; wxString mName;
wxString mType; wxString mType;
#endif // DISABLE_DYNAMIC_LOADING_LAME
wxTextCtrl *mPathText; wxTextCtrl *mPathText;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#ifndef DISABLE_DYNAMIC_LOADING_LAME
BEGIN_EVENT_TABLE(FindDialog, wxDialog) BEGIN_EVENT_TABLE(FindDialog, wxDialog)
EVT_BUTTON(ID_BROWSE, FindDialog::OnBrowse) EVT_BUTTON(ID_BROWSE, FindDialog::OnBrowse)
EVT_BUTTON(ID_DLOAD, FindDialog::OnDownload) EVT_BUTTON(ID_DLOAD, FindDialog::OnDownload)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif // DISABLE_DYNAMIC_LOADING_LAME
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// MP3Exporter // MP3Exporter
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#ifndef DISABLE_DYNAMIC_LOADING_LAME
typedef lame_global_flags *lame_init_t(void); typedef lame_global_flags *lame_init_t(void);
typedef int lame_init_params_t(lame_global_flags*); typedef int lame_init_params_t(lame_global_flags*);
typedef const char* get_lame_version_t(void); typedef const char* get_lame_version_t(void);
@ -724,6 +738,8 @@ typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int);
typedef size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char* buffer, size_t size); typedef size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char* buffer, size_t size);
typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *); typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *);
#endif // DISABLE_DYNAMIC_LOADING_LAME
#if defined(__WXMSW__) #if defined(__WXMSW__)
// An alternative solution to give Windows an additional chance of writing the tag before // An alternative solution to give Windows an additional chance of writing the tag before
// falling bato to lame_mp3_tag_fid(). The latter can have DLL sharing issues when mixing // falling bato to lame_mp3_tag_fid(). The latter can have DLL sharing issues when mixing
@ -776,9 +792,11 @@ public:
MP3Exporter(); MP3Exporter();
virtual ~MP3Exporter(); virtual ~MP3Exporter();
#ifndef DISABLE_DYNAMIC_LOADING_LAME
bool FindLibrary(wxWindow *parent); bool FindLibrary(wxWindow *parent);
bool LoadLibrary(wxWindow *parent, AskUser askuser); bool LoadLibrary(wxWindow *parent, AskUser askuser);
bool ValidLibraryLoaded(); bool ValidLibraryLoaded();
#endif // DISABLE_DYNAMIC_LOADING_LAME
/* These global settings keep state over the life of the object */ /* These global settings keep state over the life of the object */
void SetMode(int mode); void SetMode(int mode);
@ -820,9 +838,11 @@ public:
private: private:
#ifndef DISABLE_DYNAMIC_LOADING_LAME
wxString mLibPath; wxString mLibPath;
wxDynamicLibrary lame_lib; wxDynamicLibrary lame_lib;
bool mLibraryLoaded; bool mLibraryLoaded;
#endif // DISABLE_DYNAMIC_LOADING_LAME
#if defined(__WXMSW__) #if defined(__WXMSW__)
wxString mBladeVersion; wxString mBladeVersion;
@ -835,6 +855,7 @@ private:
int mRoutine; int mRoutine;
int mChannel; int mChannel;
#ifndef DISABLE_DYNAMIC_LOADING_LAME
/* function pointers to the symbols we get from the library */ /* function pointers to the symbols we get from the library */
lame_init_t* lame_init; lame_init_t* lame_init;
lame_init_params_t* lame_init_params; lame_init_params_t* lame_init_params;
@ -864,6 +885,7 @@ private:
beWriteInfoTag_t *beWriteInfoTag; beWriteInfoTag_t *beWriteInfoTag;
beVersion_t *beVersion; beVersion_t *beVersion;
#endif #endif
#endif // DISABLE_DYNAMIC_LOADING_LAME
lame_global_flags *mGF; lame_global_flags *mGF;
@ -880,13 +902,17 @@ private:
MP3Exporter::MP3Exporter() MP3Exporter::MP3Exporter()
{ {
#ifndef DISABLE_DYNAMIC_LOADING_LAME
mLibraryLoaded = false; mLibraryLoaded = false;
#endif // DISABLE_DYNAMIC_LOADING_LAME
mEncoding = false; mEncoding = false;
mGF = NULL; mGF = NULL;
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (gPrefs) { if (gPrefs) {
mLibPath = gPrefs->Read(wxT("/MP3/MP3LibPath"), wxT("")); mLibPath = gPrefs->Read(wxT("/MP3/MP3LibPath"), wxT(""));
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
mBitrate = 128; mBitrate = 128;
mQuality = QUALITY_2; mQuality = QUALITY_2;
@ -900,6 +926,8 @@ MP3Exporter::~MP3Exporter()
FreeLibrary(); FreeLibrary();
} }
#ifndef DISABLE_DYNAMIC_LOADING_LAME
bool MP3Exporter::FindLibrary(wxWindow *parent) bool MP3Exporter::FindLibrary(wxWindow *parent)
{ {
wxString path; wxString path;
@ -998,6 +1026,8 @@ bool MP3Exporter::ValidLibraryLoaded()
return mLibraryLoaded; return mLibraryLoaded;
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
void MP3Exporter::SetMode(int mode) void MP3Exporter::SetMode(int mode)
{ {
mMode = mode; mMode = mode;
@ -1023,6 +1053,7 @@ bool MP3Exporter::InitLibrary(wxString libpath)
{ {
wxLogMessage(wxT("Loading LAME from %s"), libpath.c_str()); wxLogMessage(wxT("Loading LAME from %s"), libpath.c_str());
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (!lame_lib.Load(libpath, wxDL_LAZY)) { if (!lame_lib.Load(libpath, wxDL_LAZY)) {
wxLogMessage(wxT("load failed")); wxLogMessage(wxT("load failed"));
return false; return false;
@ -1126,6 +1157,7 @@ bool MP3Exporter::InitLibrary(wxString libpath)
lame_lib.Unload(); lame_lib.Unload();
return false; return false;
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
mGF = lame_init(); mGF = lame_init();
if (mGF == NULL) { if (mGF == NULL) {
@ -1142,25 +1174,31 @@ void MP3Exporter::FreeLibrary()
mGF = NULL; mGF = NULL;
} }
#ifndef DISABLE_DYNAMIC_LOADING_LAME
lame_lib.Unload(); lame_lib.Unload();
#endif // DISABLE_DYNAMIC_LOADING_LAME
return; return;
} }
wxString MP3Exporter::GetLibraryVersion() wxString MP3Exporter::GetLibraryVersion()
{ {
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (!mLibraryLoaded) { if (!mLibraryLoaded) {
return wxT(""); return wxT("");
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
return wxString::Format(wxT("LAME %hs"), get_lame_version()); return wxString::Format(wxT("LAME %hs"), get_lame_version());
} }
int MP3Exporter::InitializeStream(int channels, int sampleRate) int MP3Exporter::InitializeStream(int channels, int sampleRate)
{ {
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (!mLibraryLoaded) { if (!mLibraryLoaded) {
return -1; return -1;
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
if (channels > 2) { if (channels > 2) {
return -1; return -1;
@ -1171,7 +1209,10 @@ int MP3Exporter::InitializeStream(int channels, int sampleRate)
lame_set_in_samplerate(mGF, sampleRate); lame_set_in_samplerate(mGF, sampleRate);
lame_set_out_samplerate(mGF, sampleRate); lame_set_out_samplerate(mGF, sampleRate);
lame_set_disable_reservoir(mGF, false); lame_set_disable_reservoir(mGF, false);
#ifndef DISABLE_DYNAMIC_LOADING_LAME
// TODO: Make this configurable (detect the existance of this function)
lame_set_padding_type(mGF, PAD_NO); lame_set_padding_type(mGF, PAD_NO);
#endif // DISABLE_DYNAMIC_LOADING_LAME
// Add the VbrTag for all types. For ABR/VBR, a Xing tag will be created. // Add the VbrTag for all types. For ABR/VBR, a Xing tag will be created.
// For CBR, it will be a Lame Info tag. // For CBR, it will be a Lame Info tag.
@ -1316,9 +1357,13 @@ int MP3Exporter::FinishStream(unsigned char outbuffer[])
int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize); int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
#if defined(DISABLE_DYNAMIC_LOADING_LAME)
mInfoTagLen = lame_get_lametag_frame(mGF, mInfoTagBuf, sizeof(mInfoTagBuf));
#else
if (lame_get_lametag_frame) { if (lame_get_lametag_frame) {
mInfoTagLen = lame_get_lametag_frame(mGF, mInfoTagBuf, sizeof(mInfoTagBuf)); mInfoTagLen = lame_get_lametag_frame(mGF, mInfoTagBuf, sizeof(mInfoTagBuf));
} }
#endif
return result; return result;
} }
@ -1571,10 +1616,20 @@ int ExportMP3::Export(AudacityProject *project,
int subformat) int subformat)
{ {
int rate = lrint(project->GetRate()); int rate = lrint(project->GetRate());
#ifndef DISABLE_DYNAMIC_LOADING_LAME
wxWindow *parent = project; wxWindow *parent = project;
#endif // DISABLE_DYNAMIC_LOADING_LAME
TrackList *tracks = project->GetTracks(); TrackList *tracks = project->GetTracks();
MP3Exporter exporter; MP3Exporter exporter;
#ifdef DISABLE_DYNAMIC_LOADING_LAME
if (!exporter.InitLibrary(wxT(""))) {
wxMessageBox(_("Could not initialize MP3 encoding library!"));
gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
return false;
}
#else
if (!exporter.LoadLibrary(parent, MP3Exporter::Maybe)) { if (!exporter.LoadLibrary(parent, MP3Exporter::Maybe)) {
wxMessageBox(_("Could not open MP3 encoding library!")); wxMessageBox(_("Could not open MP3 encoding library!"));
gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT(""))); gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
@ -1588,6 +1643,7 @@ int ExportMP3::Export(AudacityProject *project,
return false; return false;
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
// Retrieve preferences // Retrieve preferences
int highrate = 48000; int highrate = 48000;
@ -2018,13 +2074,17 @@ wxString GetMP3Version(wxWindow *parent, bool prompt)
MP3Exporter exporter; MP3Exporter exporter;
wxString versionString = _("MP3 export library not found"); wxString versionString = _("MP3 export library not found");
#ifndef DISABLE_DYNAMIC_LOADING_LAME
if (prompt) { if (prompt) {
exporter.FindLibrary(parent); exporter.FindLibrary(parent);
} }
if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) { if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) {
#endif // DISABLE_DYNAMIC_LOADING_LAME
versionString = exporter.GetLibraryVersion(); versionString = exporter.GetLibraryVersion();
#ifndef DISABLE_DYNAMIC_LOADING_LAME
} }
#endif // DISABLE_DYNAMIC_LOADING_LAME
return versionString; return versionString;
} }

View File

@ -349,7 +349,7 @@ int ODFFmpegDecoder::Decode(samplePtr & data, sampleFormat & format, sampleCount
} }
} }
if(mCurrentPos>start){ if(mCurrentPos>start){
mSeekingAllowedStatus = ODFFMPEG_SEEKING_TEST_FAILED; mSeekingAllowedStatus = (bool)ODFFMPEG_SEEKING_TEST_FAILED;
// url_fseek(mFormatContext->pb,sc->m_pkt.pos,SEEK_SET); // url_fseek(mFormatContext->pb,sc->m_pkt.pos,SEEK_SET);
printf("seek fail, reverting to previous pos\n"); printf("seek fail, reverting to previous pos\n");
return -1; return -1;

View File

@ -89,13 +89,17 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
S.AddVariableText(_("MP3 Library:"), S.AddVariableText(_("MP3 Library:"),
true, true,
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_MP3_FIND_BUTTON).AddButton(_("&Locate..."), wxButton *locate_button = S.Id(ID_MP3_FIND_BUTTON).AddButton(_("&Locate..."),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
S.AddVariableText(_("LAME MP3 Library:"), S.AddVariableText(_("LAME MP3 Library:"),
true, true,
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_MP3_DOWN_BUTTON).AddButton(_("&Download"), wxButton *download_button = S.Id(ID_MP3_DOWN_BUTTON).AddButton(_("&Download"),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
#ifdef DISABLE_DYNAMIC_LOADING_LAME
locate_button->Enable(FALSE);
download_button->Enable(FALSE);
#endif // DISABLE_DYNAMIC_LOADING_LAME
} }
S.EndTwoColumn(); S.EndTwoColumn();
} }

View File

@ -131,7 +131,9 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0); w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0);
w = new ExtImportPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new ExtImportPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
w = new ProjectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new ProjectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
w = new LibraryPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new LibraryPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
#endif
w = new SpectrumPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new SpectrumPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
w = new DirectoriesPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new DirectoriesPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
w = new WarningsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new WarningsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);