1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-03 06:03:13 +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 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
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])
@ -357,6 +357,7 @@ dnl AUDACITY_CHECKLIB_LIBLRDF
AUDACITY_CHECKLIB_PORTSMF
dnl AUDACITY_CHECKLIB_TAGLIB
AUDACITY_CHECKLIB_PORTAUDIO
AUDACITY_CHECKLIB_LAME
dnl Decide what libraries to build with, and whether to use system or local libraries
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
/* Use system LAME library and disable dynamic loading of it. */
#undef DISABLE_DYNAMIC_LOADING_LAME
/* Define if LADSPA plug-ins are enabled */
#undef USE_LADSPA

View File

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

View File

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

View File

@ -89,13 +89,17 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
S.AddVariableText(_("MP3 Library:"),
true,
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);
S.AddVariableText(_("LAME MP3 Library:"),
true,
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);
#ifdef DISABLE_DYNAMIC_LOADING_LAME
locate_button->Enable(FALSE);
download_button->Enable(FALSE);
#endif // DISABLE_DYNAMIC_LOADING_LAME
}
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 ExtImportPrefs(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);
#endif
w = new SpectrumPrefs(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);