Update of /cvsroot/audacity/audacity-src/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv2336/src
Modified Files: AudacityApp.cpp FFmpeg.cpp FFmpeg.h Log Message: Check for FFmpeg at startup. If it is enabled - load it and keep it loaded. If it can't be loaded - disable it. FFmpeg can only be enabled in Preferences. FFmpeg can only be loaded in Preferences or at startup. When doing something FFmpeg-related, Audacity will not try to load FFmpeg libraries, and will do nothing (notifying the user) if they are not loaded. GetFFmpegVersion() now does only what it should do - gets FFmpeg version. Actual loading and prompting are moved into other routines. Moved FFmpegNotFound into FFmpeg.h . FFmpegNotFound is now used only for imports. For exports simple wxMessageBox() is used. Index: FFmpeg.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/FFmpeg.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- FFmpeg.cpp 11 Oct 2008 07:38:28 -0000 1.25 +++ FFmpeg.cpp 14 Oct 2008 15:41:16 -0000 1.26 @@ -31,10 +31,15 @@ #if !defined(USE_FFMPEG) /// FFmpeg support may or may not be compiled in, /// but Preferences dialog requires this function nevertheless -wxString GetFFmpegVersion(wxWindow *parent, bool prompt) +wxString GetFFmpegVersion(wxWindow *parent) { return wxString(wxT("FFmpeg support not compiled in")); } + +void FFmpegStartup() +{ +} + #else /** This pointer to the shared object has global scope and is used to track the @@ -68,18 +73,45 @@ } } +bool LoadFFmpeg(bool showerror) +{ + PickFFmpegLibs(); + if (FFmpegLibsInst->ValidLibsLoaded()) + { + DropFFmpegLibs(); + return true; + } + if (!FFmpegLibsInst->LoadLibs(NULL,showerror)) + { + DropFFmpegLibs(); + gPrefs->Write(wxT("/FFmpeg/Enabled"), false); + return false; + } + else + { + gPrefs->Write(wxT("/FFmpeg/Enabled"), true); + return true; + } +} -wxString GetFFmpegVersion(wxWindow *parent, bool prompt) +void FFmpegStartup() +{ + bool enabled = false; + gPrefs->Read(wxT("/FFmpeg/Enabled"),&enabled); + // 'false' means that no errors should be shown whatsoever + if (enabled && !LoadFFmpeg(false)) + { + wxMessageBox(wxT("FFmpeg was enabled in preferences, but Audacity failed to load it at startup.\nYou may wish go to Preferences and re-configure it."),wxT("FFmpeg startup failed")); + } +} + +wxString GetFFmpegVersion(wxWindow *parent) { PickFFmpegLibs(); wxString versionString = _("FFmpeg library is not found"); - if (prompt) { - FFmpegLibsInst->FindLibs(parent); - } - - if (FFmpegLibsInst->LoadLibs(parent, false)) { + if (FFmpegLibsInst->ValidLibsLoaded()) { versionString = FFmpegLibsInst->GetLibraryVersion(); } @@ -90,7 +122,7 @@ void av_log_wx_callback(void* ptr, int level, const char* fmt, va_list vl) { - //Most of this stuff is taked from FFmpeg tutorials and FFmpeg itself + //Most of this stuff is taken from FFmpeg tutorials and FFmpeg itself int av_log_level = AV_LOG_WARNING; AVClass* avc = ptr ? *(AVClass**)ptr : NULL; if (level > av_log_level) @@ -102,7 +134,7 @@ } wxString frm(fmt,wxConvLibc); -#if defined(wxMSW) +#if defined(__WXMSW__) frm.Replace(wxT("%t"),wxT("%i"),true); //TODO: on Windows vprintf won't handle %t, and probably some others. Investigate. #endif printstring.Append(wxString::FormatV(frm,vl)); @@ -246,66 +278,6 @@ // FFmpegNotFoundDialog //---------------------------------------------------------------------------- -/// If Audacity failed to load libav*, this dialog -/// shows up and tells user about that. It will pop-up -/// again and again until it is disabled. -class FFmpegNotFoundDialog : public wxDialog -{ -public: - - FFmpegNotFoundDialog(wxWindow *parent) - : wxDialog(parent, wxID_ANY, wxString(_("FFmpeg not found"))) - { - ShuttleGui S(this, eIsCreating); - PopulateOrExchange(S); - } - - void PopulateOrExchange(ShuttleGui & S) - { - wxString text; - - S.SetBorder(10); - S.StartVerticalLay(true); - { - S.AddFixedText(wxT( -"Audacity attempted to load FFmpeg libraries\n\ -to either import or export an audio file,\n\ -but libraries were not found.\n\ -If you want to use the FFmpeg import/export feature,\n\ -please go to Preferences->Import/Export\n\ -and tell Audacity where to look for the libraries." - )); - - mDontShow = S.AddCheckBox(wxT("Do not show this warning again"),wxT("false")); - - S.AddStandardButtons(eOkButton); - } - S.EndVerticalLay(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - Center(); - - return; - } - - void OnOk(wxCommandEvent & event) - { - if (mDontShow->GetValue()) - { - gPrefs->Write(wxT("/FFmpeg/NotFoundDontShow"),1); - } - this->EndModal(0); - } - -private: - - wxCheckBox *mDontShow; - - DECLARE_EVENT_TABLE() -}; - BEGIN_EVENT_TABLE(FFmpegNotFoundDialog, wxDialog) EVT_BUTTON(wxID_OK, FFmpegNotFoundDialog::OnOk) END_EVENT_TABLE() @@ -403,6 +375,7 @@ } // If libraries aren't loaded - nag user about that + /* if (!ValidLibsLoaded()) { wxLogMessage(wxT("Failed to load libraries altogether.")); @@ -416,7 +389,7 @@ delete dlg; } } - + */ // Oh well, just give up if (!ValidLibsLoaded()) { if (showerr) wxMessageBox(wxT("Failed to find compatible FFmpeg libraries")); Index: FFmpeg.h =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/FFmpeg.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- FFmpeg.h 12 Oct 2008 01:13:00 -0000 1.24 +++ FFmpeg.h 14 Oct 2008 15:41:16 -0000 1.25 @@ -72,11 +72,78 @@ //---------------------------------------------------------------------------- // Get FFmpeg library version //---------------------------------------------------------------------------- -wxString GetFFmpegVersion(wxWindow *parent, bool prompt); +wxString GetFFmpegVersion(wxWindow *parent); + +//---------------------------------------------------------------------------- +// Attempt to load and enable/disable FFmpeg at startup +//---------------------------------------------------------------------------- +void FFmpegStartup(); /* from here on in, this stuff only applies when ffmpeg is available */ #if defined(USE_FFMPEG) +bool LoadFFmpeg(bool showerror); + +/// If Audacity failed to load libav*, this dialog +/// shows up and tells user about that. It will pop-up +/// again and again until it is disabled. +class FFmpegNotFoundDialog : public wxDialog +{ +public: + + FFmpegNotFoundDialog(wxWindow *parent) + : wxDialog(parent, wxID_ANY, wxString(_("FFmpeg not found"))) + { + ShuttleGui S(this, eIsCreating); + PopulateOrExchange(S); + } + + void PopulateOrExchange(ShuttleGui & S) + { + wxString text; + + S.SetBorder(10); + S.StartVerticalLay(true); + { + S.AddFixedText(wxT( +"Audacity attempted to use FFmpeg libraries to import or export an audio file,\n\ +but libraries were not found.\n\ +If you want to use the FFmpeg import feature, please go to Preferences->Import/Export\n\ +and tell Audacity where to look for the libraries." + )); + + int dontShowDlg = 0; + gPrefs->Read(wxT("/FFmpeg/NotFoundDontShow"),&dontShowDlg,0); + mDontShow = S.AddCheckBox(wxT("Do not show this warning again"),dontShowDlg ? wxT("true") : wxT("false")); + + S.AddStandardButtons(eOkButton); + } + S.EndVerticalLay(); + + Layout(); + Fit(); + SetMinSize(GetSize()); + Center(); + + return; + } + + void OnOk(wxCommandEvent & event) + { + if (mDontShow->GetValue()) + { + gPrefs->Write(wxT("/FFmpeg/NotFoundDontShow"),1); + } + this->EndModal(0); + } + +private: + + wxCheckBox *mDontShow; + + DECLARE_EVENT_TABLE() +}; + /// Manages liabv* libraries - loads/unloads libraries, imports symbols. /// Only one instance of this class should exist at each given moment. /// function definitions are taken from FFmpeg headers manually, Index: AudacityApp.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v retrieving revision 1.209 retrieving revision 1.210 diff -u -d -r1.209 -r1.210 --- AudacityApp.cpp 11 Oct 2008 00:21:31 -0000 1.209 +++ AudacityApp.cpp 14 Oct 2008 15:41:16 -0000 1.210 @@ -89,6 +89,8 @@ #include "import/ImportQT.h" #endif +#include "FFmpeg.h" + #ifdef _DEBUG #ifdef _MSC_VER #undef THIS_FILE @@ -858,6 +860,8 @@ mLogger->EnableLogging(true); mLogger->SetLogLevel(wxLOG_Max); + FFmpegStartup(); + // // Auto-recovery // ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs