Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv18906/src
Modified Files:
FFmpeg.cpp FFmpeg.h
Log Message:
Code comments and cosmetic fixes.
Index: FFmpeg.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FFmpeg.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- FFmpeg.cpp 2 Aug 2008 11:38:40 -0000 1.20
+++ FFmpeg.cpp 9 Aug 2008 03:04:45 -0000 1.21
@@ -27,8 +27,9 @@
#endif
#endif
-
#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)
{
return wxString(wxT("FFmpeg support not compiled in"));
@@ -71,7 +72,7 @@
{
PickFFmpegLibs();
- wxString versionString = _("FFmpeg library not found");
+ wxString versionString = _("FFmpeg library is not found");
if (prompt) {
FFmpegLibsInst->FindLibs(parent);
@@ -88,6 +89,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
int av_log_level = AV_LOG_WARNING;
AVClass* avc = ptr ? *(AVClass**)ptr : NULL;
if (level > av_log_level)
@@ -123,6 +125,7 @@
#define ID_FFMPEG_BROWSE 5000
#define ID_FFMPEG_DLOAD 5001
+/// Allows user to locate libav* libraries
class FindFFmpegDialog : public wxDialog
{
public:
@@ -210,7 +213,7 @@
void OnDownload(wxCommandEvent & event)
{
- wxString page = wxT("http://audacity.sourceforge.net/ffmpeg");
+ wxString page =
wxT("http://audacityteam.org/wiki/index.php?title=FFmpeg");
::OpenInDefaultBrowser(page);
}
@@ -233,8 +236,8 @@
};
BEGIN_EVENT_TABLE(FindFFmpegDialog, wxDialog)
-EVT_BUTTON(ID_FFMPEG_BROWSE, FindFFmpegDialog::OnBrowse)
-EVT_BUTTON(ID_FFMPEG_DLOAD, FindFFmpegDialog::OnDownload)
+ EVT_BUTTON(ID_FFMPEG_BROWSE, FindFFmpegDialog::OnBrowse)
+ EVT_BUTTON(ID_FFMPEG_DLOAD, FindFFmpegDialog::OnDownload)
END_EVENT_TABLE()
@@ -242,6 +245,9 @@
// 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:
@@ -300,7 +306,7 @@
};
BEGIN_EVENT_TABLE(FFmpegNotFoundDialog, wxDialog)
-EVT_BUTTON(wxID_OK, FFmpegNotFoundDialog::OnOk)
+ EVT_BUTTON(wxID_OK, FFmpegNotFoundDialog::OnOk)
END_EVENT_TABLE()
@@ -395,6 +401,7 @@
mLibsLoaded = InitLibs(mLibAVFormatPath,showerr);
}
+ // If libraries aren't loaded - nag user about that
if (!ValidLibsLoaded())
{
wxLogMessage(wxT("Failed to load libraries altogether."));
@@ -425,21 +432,22 @@
bool FFmpegLibs::InitLibs(wxString libpath_format, bool showerr)
{
- //Initially we don't know where's the avcodec and avutl libs
+ // Initially we don't know where are the avcodec and avutl libs
wxString libpath_codec(wxT(""));
wxString libpath_util(wxT(""));
bool gotError = false;
#if defined(__WXMSW__)
- //On Windows force system to show error messages (as they are
- //more informative than wxMessages).
+ // On Windows force system to show error messages (as they are
+ // more informative than wxMessages).
unsigned int erm = SetErrorMode(showerr ? 0 : SEM_FAILCRITICALERRORS);
#endif
wxString syspath;
bool pathfix = false;
wxLogMessage(wxT("Looking up PATH..."));
+ // First take PATH environment variable (store it's content)
if (wxGetEnv(wxT("PATH"),&syspath))
{
wxLogMessage(wxT("PATH = %s"),syspath.c_str());
@@ -447,6 +455,7 @@
wxString scfmtdir = wxT(";") + wxPathOnly(libpath_format);
wxString fmtdir = wxPathOnly(libpath_format);
wxLogMessage(wxT("Checking that %s is in PATH..."),fmtdir.c_str());
+ // If the directory, where libavformat is, is not in PATH - add it
if (!syspath.Contains(fmtdirsc) && !syspath.Contains(scfmtdir) &&
!syspath.Contains(fmtdir))
{
wxLogMessage(wxT("not in PATH!"));
@@ -463,6 +472,7 @@
if (wxSetEnv(wxT("PATH"),syspath.c_str()))
{
+ // Remember to change PATH back to normal after we're done
pathfix = true;
}
else
@@ -479,6 +489,8 @@
{
wxLogMessage(wxT("PATH does not exists."));
}
+
+ //Load libavformat
avformat = new wxDynamicLibrary();
if (!avformat->IsLoaded() && !gotError)
{
@@ -502,6 +514,7 @@
wxString libname = litem.GetName();
wxLogMessage(wxT("Item %d: path=%s ,
name=%s"),i,libpath.c_str(),libname.c_str());
//Match name against a pattern to find avcodec and avutil
+ ///\todo own sections for Mac and *nix
#if defined(__WXMSW__)
if (libname.Matches(wxT("*avcodec*.dll*")))
#else
@@ -524,7 +537,7 @@
//avformat loaded all right. If it didn't linked two other
//libs to itself in process, then it's statically linked.
//"or" operator ensures that we won't count misnamed statically linked
- //avformat library as dynamic one.
+ //avformat library as a dynamic one.
if ((libpath_codec.CompareTo(wxT("")) == 0)
|| (libpath_util.CompareTo(wxT("")) == 0))
{
@@ -552,6 +565,7 @@
}
}
+ //Return PATH to normal
if ( pathfix )
{
wxString oldpath = syspath.BeforeLast(wxT(';'));
Index: FFmpeg.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FFmpeg.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- FFmpeg.h 4 Jul 2008 07:03:51 -0000 1.21
+++ FFmpeg.h 9 Aug 2008 03:04:46 -0000 1.22
@@ -65,6 +65,8 @@
/* These defines apply whether or not ffmpeg is available */
#define INITDYN(w,f) if ((*(void**)&this->f=(void*)w->GetSymbol(wxT(#f))) ==
NULL) { wxLogMessage(wxT("Failed to load symbol ") wxT(#f)); return false; };
+/// Callback function to catch FFmpeg log messages.
+/// Uses wxLogMessage.
void av_log_wx_callback(void* ptr, int level, const char* fmt, va_list vl);
//----------------------------------------------------------------------------
@@ -75,6 +77,11 @@
/* from here on in, this stuff only applies when ffmpeg is available */
#if defined(USE_FFMPEG)
+/// 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,
+/// eventually (at next major FFmpeg version change) we'll have to review
+/// them and update if necessary.
class FFmpegLibs
{
public:
@@ -138,14 +145,29 @@
void (*av_freep) (void *ptr);
int64_t (*av_rescale_q) (int64_t a, AVRational
bq, AVRational cq);
+ ///! Finds libav* libraries
+ ///\return true if found, false if not found
bool FindLibs(wxWindow *parent);
+ ///! Loads libav* libraries
+ ///\param showerr - controls whether or not to show an error dialog if
libraries cannot be loaded
+ ///\return true if loaded, false if not loaded
bool LoadLibs(wxWindow *parent, bool showerr);
+ ///! Checks if libraries are loaded
+ ///\return true if libraries are loaded, false otherwise
bool ValidLibsLoaded();
- /* initialize the library interface */
+ ///! Initializes the libraries. Call after LoadLibs (when ValidLibsLoaded
returns true)
+ ///\param libpath_codec - full file path to the libavformat library
+ ///\param showerr - controls whether or not to show an error dialog if
libraries cannot be loaded
+ ///\return true if initialization completed without errors, false otherwise
+ /// do not call (it is called by FindLibs automatically)
bool InitLibs(wxString libpath_codec, bool showerr);
+
+ ///! Frees (unloads) loaded libraries
void FreeLibs();
+ ///! Returns library version as string
+ ///\return libavformat library version or empty string?
wxString GetLibraryVersion()
{
return mVersion;
@@ -185,25 +207,39 @@
return wxT("libavformat.so");
}
#endif //__WXMSW__
- //Ugly reference counting. I thought of using wxStuff for that,
- //but decided that wx reference counting is not useful, since
- //there's no data sharing - object is shared because libraries are.
+
+ /// Ugly reference counting. I thought of using wxStuff for that,
+ /// but decided that wx reference counting is not useful, since
+ /// there's no data sharing - object is shared because libraries are.
int refcount;
private:
+ ///! Stored path to libavformat library
wxString mLibAVFormatPath;
+
+ ///! Stored library version
wxString mVersion;
+ ///! wx interfaces for dynamic libraries
wxDynamicLibrary *avformat;
wxDynamicLibrary *avcodec;
wxDynamicLibrary *avutil;
+ ///! true if libavformat has internal static linkage, false otherwise
bool mStatic;
+
+ ///! true if libraries are loaded, false otherwise
bool mLibsLoaded;
};
+///! Helper function - creates FFmpegLibs object if it does not exists
+///! or just increments reference count if it does
+///! It is usually called by constructors or initializators
FFmpegLibs *PickFFmpegLibs();
+
+///! Helper function - destroys FFmpegLibs object if there is no need for it
+///! anymore, or just decrements it's reference count
void DropFFmpegLibs();
#endif // USE_FFMPEG
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs