mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-04 09:39:42 +02:00
ExportPlugins managed with smart pointers
This commit is contained in:
parent
1108c1376c
commit
456c8fb01e
@ -75,7 +75,6 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
#include <wx/arrimpl.cpp>
|
#include <wx/arrimpl.cpp>
|
||||||
|
|
||||||
WX_DEFINE_USER_EXPORTED_OBJARRAY(ExportPluginArray);
|
|
||||||
WX_DEFINE_USER_EXPORTED_OBJARRAY(FormatInfoArray);
|
WX_DEFINE_USER_EXPORTED_OBJARRAY(FormatInfoArray);
|
||||||
|
|
||||||
ExportPlugin::ExportPlugin()
|
ExportPlugin::ExportPlugin()
|
||||||
@ -112,11 +111,6 @@ int ExportPlugin::GetFormatCount()
|
|||||||
return mFormatInfos.Count();
|
return mFormatInfos.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportPlugin::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param index The plugin to set the format for (range 0 to one less than the
|
* @param index The plugin to set the format for (range 0 to one less than the
|
||||||
* count of formats)
|
* count of formats)
|
||||||
@ -299,11 +293,6 @@ Exporter::Exporter()
|
|||||||
|
|
||||||
Exporter::~Exporter()
|
Exporter::~Exporter()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++) {
|
|
||||||
mPlugins[i]->Destroy();
|
|
||||||
}
|
|
||||||
mPlugins.Clear();
|
|
||||||
|
|
||||||
if (mMixerSpec) {
|
if (mMixerSpec) {
|
||||||
delete mMixerSpec;
|
delete mMixerSpec;
|
||||||
}
|
}
|
||||||
@ -318,9 +307,9 @@ void Exporter::SetFileDialogTitle( const wxString & DialogTitle )
|
|||||||
int Exporter::FindFormatIndex(int exportindex)
|
int Exporter::FindFormatIndex(int exportindex)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
if (exportindex == c) return j;
|
if (exportindex == c) return j;
|
||||||
c++;
|
c++;
|
||||||
@ -329,12 +318,12 @@ int Exporter::FindFormatIndex(int exportindex)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exporter::RegisterPlugin(ExportPlugin *ExportPlugin)
|
void Exporter::RegisterPlugin(movable_ptr<ExportPlugin> &&ExportPlugin)
|
||||||
{
|
{
|
||||||
mPlugins.Add(ExportPlugin);
|
mPlugins.push_back(std::move(ExportPlugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExportPluginArray Exporter::GetPlugins()
|
const ExportPluginArray &Exporter::GetPlugins()
|
||||||
{
|
{
|
||||||
return mPlugins;
|
return mPlugins;
|
||||||
}
|
}
|
||||||
@ -399,10 +388,12 @@ bool Exporter::Process(AudacityProject *project, int numChannels,
|
|||||||
mT1 = t1;
|
mT1 = t1;
|
||||||
mActualName = mFilename;
|
mActualName = mFilename;
|
||||||
|
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++) {
|
int i = -1;
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
for (const auto &pPlugin : mPlugins) {
|
||||||
|
++i;
|
||||||
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
if (mPlugins[i]->GetFormat(j).IsSameAs(type, false))
|
if (pPlugin->GetFormat(j).IsSameAs(type, false))
|
||||||
{
|
{
|
||||||
mFormat = i;
|
mFormat = i;
|
||||||
mSubFormat = j;
|
mSubFormat = j;
|
||||||
@ -508,15 +499,19 @@ bool Exporter::GetFilename()
|
|||||||
|
|
||||||
mFilterIndex = 0;
|
mFilterIndex = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++) {
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
int i = -1;
|
||||||
{
|
for (const auto &pPlugin : mPlugins) {
|
||||||
maskString += mPlugins[i]->GetMask(j) + wxT("|");
|
++i;
|
||||||
if (mPlugins[i]->GetFormat(j) == defaultFormat) {
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
mFormat = i;
|
{
|
||||||
mSubFormat = j;
|
maskString += pPlugin->GetMask(j) + wxT("|");
|
||||||
|
if (mPlugins[i]->GetFormat(j) == defaultFormat) {
|
||||||
|
mFormat = i;
|
||||||
|
mSubFormat = j;
|
||||||
|
}
|
||||||
|
if (mFormat == -1) mFilterIndex++;
|
||||||
}
|
}
|
||||||
if (mFormat == -1) mFilterIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mFormat == -1)
|
if (mFormat == -1)
|
||||||
@ -561,9 +556,11 @@ bool Exporter::GetFilename()
|
|||||||
mFilterIndex = fd.GetFilterIndex();
|
mFilterIndex = fd.GetFilterIndex();
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
int i = -1;
|
||||||
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
++i;
|
||||||
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
if (mFilterIndex == c)
|
if (mFilterIndex == c)
|
||||||
{
|
{
|
||||||
@ -713,9 +710,11 @@ void Exporter::DisplayOptions(int index)
|
|||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int mf = -1, msf = -1;
|
int mf = -1, msf = -1;
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
int i = -1;
|
||||||
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
++i;
|
||||||
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
if (index == c)
|
if (index == c)
|
||||||
{
|
{
|
||||||
@ -856,11 +855,11 @@ void Exporter::CreateUserPane(wxWindow *parent)
|
|||||||
mBook = safenew wxSimplebook(S.GetParent());
|
mBook = safenew wxSimplebook(S.GetParent());
|
||||||
S.AddWindow(mBook, wxEXPAND);
|
S.AddWindow(mBook, wxEXPAND);
|
||||||
|
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
mBook->AddPage(mPlugins[i]->OptionsCreate(mBook, j), wxEmptyString);
|
mBook->AddPage(pPlugin->OptionsCreate(mBook, j), wxEmptyString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef __AUDACITY_EXPORT__
|
#ifndef __AUDACITY_EXPORT__
|
||||||
#define __AUDACITY_EXPORT__
|
#define __AUDACITY_EXPORT__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
|
#include <vector>
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#include <wx/dynarray.h>
|
#include <wx/dynarray.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
@ -57,7 +59,6 @@ public:
|
|||||||
|
|
||||||
ExportPlugin();
|
ExportPlugin();
|
||||||
virtual ~ExportPlugin();
|
virtual ~ExportPlugin();
|
||||||
virtual void Destroy();
|
|
||||||
|
|
||||||
int AddFormat();
|
int AddFormat();
|
||||||
void SetFormat(const wxString & format, int index);
|
void SetFormat(const wxString & format, int index);
|
||||||
@ -126,7 +127,7 @@ private:
|
|||||||
FormatInfoArray mFormatInfos;
|
FormatInfoArray mFormatInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DECLARE_USER_EXPORTED_OBJARRAY(ExportPlugin *, ExportPluginArray, AUDACITY_DLL_API);
|
using ExportPluginArray = std::vector < movable_ptr< ExportPlugin > > ;
|
||||||
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API);
|
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -140,7 +141,7 @@ public:
|
|||||||
virtual ~Exporter();
|
virtual ~Exporter();
|
||||||
|
|
||||||
void SetFileDialogTitle( const wxString & DialogTitle );
|
void SetFileDialogTitle( const wxString & DialogTitle );
|
||||||
void RegisterPlugin(ExportPlugin *plugin);
|
void RegisterPlugin(movable_ptr<ExportPlugin> &&plugin);
|
||||||
|
|
||||||
bool Process(AudacityProject *project, bool selectedOnly,
|
bool Process(AudacityProject *project, bool selectedOnly,
|
||||||
double t0, double t1);
|
double t0, double t1);
|
||||||
@ -151,7 +152,7 @@ public:
|
|||||||
void DisplayOptions(int index);
|
void DisplayOptions(int index);
|
||||||
int FindFormatIndex(int exportindex);
|
int FindFormatIndex(int exportindex);
|
||||||
|
|
||||||
const ExportPluginArray GetPlugins();
|
const ExportPluginArray &GetPlugins();
|
||||||
|
|
||||||
// Auto Export from Timer Recording
|
// Auto Export from Timer Recording
|
||||||
bool ProcessFromTimerRecording(AudacityProject *project,
|
bool ProcessFromTimerRecording(AudacityProject *project,
|
||||||
|
@ -279,7 +279,6 @@ class ExportCL final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportCL();
|
ExportCL();
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||||
@ -306,11 +305,6 @@ ExportCL::ExportCL()
|
|||||||
SetDescription(_("(external program)"),0);
|
SetDescription(_("(external program)"),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportCL::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ExportCL::Export(AudacityProject *project,
|
int ExportCL::Export(AudacityProject *project,
|
||||||
int channels,
|
int channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
@ -538,8 +532,8 @@ wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format)
|
|||||||
return safenew ExportCLOptions(parent, format);
|
return safenew ExportCLOptions(parent, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPlugin *New_ExportCL()
|
movable_ptr<ExportPlugin> New_ExportCL()
|
||||||
{
|
{
|
||||||
return new ExportCL();
|
return make_movable<ExportCL>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef __AUDACITY_EXPORTCL__
|
#ifndef __AUDACITY_EXPORTCL__
|
||||||
#define __AUDACITY_EXPORTCL__
|
#define __AUDACITY_EXPORTCL__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
// forward declaration of the ExportPlugin class from Export.h
|
// forward declaration of the ExportPlugin class from Export.h
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
@ -18,6 +19,6 @@ class ExportPlugin;
|
|||||||
* factory method New_ExportCL() which creates a NEW ExportCL object and
|
* factory method New_ExportCL() which creates a NEW ExportCL object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportCL.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportCL.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportCL();
|
movable_ptr<ExportPlugin> New_ExportCL();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,7 +95,7 @@ class ExportFFmpeg final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportFFmpeg();
|
ExportFFmpeg();
|
||||||
void Destroy();
|
~ExportFFmpeg() override;
|
||||||
|
|
||||||
/// Callback, called from GetFilename
|
/// Callback, called from GetFilename
|
||||||
bool CheckFileName(wxFileName &filename, int format = 0);
|
bool CheckFileName(wxFileName &filename, int format = 0);
|
||||||
@ -182,7 +182,7 @@ ExportFFmpeg::ExportFFmpeg()
|
|||||||
mSampleRate = 0;
|
mSampleRate = 0;
|
||||||
mSupportsUTF8 = true;
|
mSupportsUTF8 = true;
|
||||||
|
|
||||||
PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg::Destroy()
|
PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg destructor
|
||||||
int avfver = FFmpegLibsInst->ValidLibsLoaded() ? avformat_version() : 0;
|
int avfver = FFmpegLibsInst->ValidLibsLoaded() ? avformat_version() : 0;
|
||||||
int newfmt;
|
int newfmt;
|
||||||
// Adds export types from the export type list
|
// Adds export types from the export type list
|
||||||
@ -235,10 +235,9 @@ ExportFFmpeg::ExportFFmpeg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportFFmpeg::Destroy()
|
ExportFFmpeg::~ExportFFmpeg()
|
||||||
{
|
{
|
||||||
DropFFmpegLibs();
|
DropFFmpegLibs();
|
||||||
delete this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExportFFmpeg::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(format))
|
bool ExportFFmpeg::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(format))
|
||||||
@ -1014,9 +1013,9 @@ wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format)
|
|||||||
return ExportPlugin::OptionsCreate(parent, format);
|
return ExportPlugin::OptionsCreate(parent, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPlugin *New_ExportFFmpeg()
|
movable_ptr<ExportPlugin> New_ExportFFmpeg()
|
||||||
{
|
{
|
||||||
return new ExportFFmpeg();
|
return make_movable<ExportFFmpeg>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,12 +11,13 @@ LRN
|
|||||||
#ifndef __AUDACITY_EXPORTFFMPEG__
|
#ifndef __AUDACITY_EXPORTFFMPEG__
|
||||||
#define __AUDACITY_EXPORTFFMPEG__
|
#define __AUDACITY_EXPORTFFMPEG__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
/** The only part of this class which is publically accessible is the
|
/** The only part of this class which is publically accessible is the
|
||||||
* factory method New_ExportFFmpeg() which creates a NEW ExportFFmpeg object and
|
* factory method New_ExportFFmpeg() which creates a NEW ExportFFmpeg object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportFFmpeg.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportFFmpeg.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportFFmpeg();
|
movable_ptr<ExportPlugin> New_ExportFFmpeg();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -178,7 +178,6 @@ class ExportFLAC final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportFLAC();
|
ExportFLAC();
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
|
|
||||||
@ -213,11 +212,6 @@ ExportFLAC::ExportFLAC()
|
|||||||
SetDescription(_("FLAC Files"),0);
|
SetDescription(_("FLAC Files"),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportFLAC::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ExportFLAC::Export(AudacityProject *project,
|
int ExportFLAC::Export(AudacityProject *project,
|
||||||
int numChannels,
|
int numChannels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
@ -403,9 +397,9 @@ bool ExportFLAC::GetMetadata(AudacityProject *project, const Tags *tags)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPlugin *New_ExportFLAC()
|
movable_ptr<ExportPlugin> New_ExportFLAC()
|
||||||
{
|
{
|
||||||
return new ExportFLAC();
|
return make_movable<ExportFLAC>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_LIBFLAC
|
#endif // USE_LIBFLAC
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#ifndef __AUDACITY_EXPORTFLAC__
|
#ifndef __AUDACITY_EXPORTFLAC__
|
||||||
#define __AUDACITY_EXPORTFLAC__
|
#define __AUDACITY_EXPORTFLAC__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
/* The only part of this class which is publically accessible is the
|
/* The only part of this class which is publically accessible is the
|
||||||
* factory method New_ExportFLAC() which creates a NEW ExportFLAC object and
|
* factory method New_ExportFLAC() which creates a NEW ExportFLAC object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportFLAC.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportFLAC.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportFLAC();
|
movable_ptr<ExportPlugin> New_ExportFLAC();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -169,7 +169,6 @@ class ExportMP2 final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportMP2();
|
ExportMP2();
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
|
|
||||||
@ -204,11 +203,6 @@ ExportMP2::ExportMP2()
|
|||||||
SetDescription(_("MP2 Files"),0);
|
SetDescription(_("MP2 Files"),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportMP2::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ExportMP2::Export(AudacityProject *project,
|
int ExportMP2::Export(AudacityProject *project,
|
||||||
int channels, const wxString &fName,
|
int channels, const wxString &fName,
|
||||||
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
|
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
|
||||||
@ -443,9 +437,9 @@ void ExportMP2::AddFrame(struct id3_tag *tp, const wxString & n, const wxString
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExportPlugin *New_ExportMP2()
|
movable_ptr<ExportPlugin> New_ExportMP2()
|
||||||
{
|
{
|
||||||
return new ExportMP2();
|
return make_movable<ExportMP2>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef USE_LIBTWOLAME
|
#endif // #ifdef USE_LIBTWOLAME
|
||||||
|
@ -12,13 +12,14 @@
|
|||||||
#ifndef __AUDACITY_EXPORTMP2__
|
#ifndef __AUDACITY_EXPORTMP2__
|
||||||
#define __AUDACITY_EXPORTMP2__
|
#define __AUDACITY_EXPORTMP2__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
/** The only part of this class which is publically accessible is the
|
/** The only part of this class which is publically accessible is the
|
||||||
* factory method New_ExportMP2() which creates a NEW ExportMP2 object and
|
* factory method New_ExportMP2() which creates a NEW ExportMP2 object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportMP2.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportMP2.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportMP2();
|
movable_ptr<ExportPlugin> New_ExportMP2();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1581,7 +1581,6 @@ class ExportMP3 final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportMP3();
|
ExportMP3();
|
||||||
void Destroy();
|
|
||||||
bool CheckFileName(wxFileName & filename, int format);
|
bool CheckFileName(wxFileName & filename, int format);
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
@ -1620,11 +1619,6 @@ ExportMP3::ExportMP3()
|
|||||||
SetDescription(_("MP3 Files"),0);
|
SetDescription(_("MP3 Files"),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportMP3::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExportMP3::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(format))
|
bool ExportMP3::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(format))
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_DYNAMIC_LOADING_LAME
|
#ifndef DISABLE_DYNAMIC_LOADING_LAME
|
||||||
@ -2103,9 +2097,9 @@ void ExportMP3::AddFrame(struct id3_tag *tp, const wxString & n, const wxString
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExportPlugin *New_ExportMP3()
|
movable_ptr<ExportPlugin> New_ExportMP3()
|
||||||
{
|
{
|
||||||
return new ExportMP3();
|
return make_movable<ExportMP3>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -13,13 +13,14 @@
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
class wxString;
|
class wxString;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
/** Factory method New_ExportMP3() which creates a NEW ExportMP3 object and
|
/** Factory method New_ExportMP3() which creates a NEW ExportMP3 object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportMP3.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportMP3.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportMP3();
|
movable_ptr<ExportPlugin> New_ExportMP3();
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Get MP3 library versioqn
|
// Get MP3 library versioqn
|
||||||
|
@ -110,7 +110,9 @@ ExportMultiple::ExportMultiple(AudacityProject *project)
|
|||||||
|
|
||||||
mProject = project;
|
mProject = project;
|
||||||
mTracks = project->GetTracks();
|
mTracks = project->GetTracks();
|
||||||
mPlugins = mExporter.GetPlugins();
|
// Construct an array of non-owning pointers
|
||||||
|
for (const auto &plugin : mExporter.GetPlugins())
|
||||||
|
mPlugins.push_back(plugin.get());
|
||||||
|
|
||||||
this->CountTracksAndLabels();
|
this->CountTracksAndLabels();
|
||||||
|
|
||||||
@ -223,17 +225,23 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
|||||||
mPluginIndex = -1;
|
mPluginIndex = -1;
|
||||||
mFilterIndex = 0;
|
mFilterIndex = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++) {
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
int i = -1;
|
||||||
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
formats.Add(mPlugins[i]->GetDescription(j));
|
++i;
|
||||||
if (mPlugins[i]->GetFormat(j) == defaultFormat) {
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
mPluginIndex = i;
|
{
|
||||||
mSubFormatIndex = j;
|
formats.Add(mPlugins[i]->GetDescription(j));
|
||||||
|
if (mPlugins[i]->GetFormat(j) == defaultFormat) {
|
||||||
|
mPluginIndex = i;
|
||||||
|
mSubFormatIndex = j;
|
||||||
|
}
|
||||||
|
if (mPluginIndex == -1) mFilterIndex++;
|
||||||
}
|
}
|
||||||
if (mPluginIndex == -1) mFilterIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPluginIndex == -1)
|
if (mPluginIndex == -1)
|
||||||
{
|
{
|
||||||
mPluginIndex = 0;
|
mPluginIndex = 0;
|
||||||
@ -270,11 +278,11 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
|||||||
if (!mBook)
|
if (!mBook)
|
||||||
{
|
{
|
||||||
mBook = safenew wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC);
|
mBook = safenew wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC);
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
mBook->AddPage(mPlugins[i]->OptionsCreate(mBook, j), wxEmptyString);
|
mBook->AddPage(pPlugin->OptionsCreate(mBook, j), wxEmptyString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mBook->ChangeSelection(mFormat->GetSelection());
|
mBook->ChangeSelection(mFormat->GetSelection());
|
||||||
@ -431,9 +439,11 @@ void ExportMultiple::OnOptions(wxCommandEvent& WXUNUSED(event))
|
|||||||
if (sel != wxNOT_FOUND)
|
if (sel != wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
size_t c = 0;
|
size_t c = 0;
|
||||||
for (size_t i = 0; i < mPlugins.GetCount(); i++)
|
int i = -1;
|
||||||
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++)
|
++i;
|
||||||
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||||
{
|
{
|
||||||
if ((size_t)sel == c)
|
if ((size_t)sel == c)
|
||||||
{
|
{
|
||||||
@ -531,9 +541,12 @@ void ExportMultiple::OnExport(wxCommandEvent& WXUNUSED(event))
|
|||||||
mFilterIndex = mFormat->GetSelection();
|
mFilterIndex = mFormat->GetSelection();
|
||||||
if (mFilterIndex != wxNOT_FOUND)
|
if (mFilterIndex != wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
for (size_t c = 0, i = 0; i < mPlugins.GetCount(); i++)
|
size_t c = 0;
|
||||||
|
int i = -1;
|
||||||
|
for (const auto &pPlugin : mPlugins)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++, c++)
|
++i;
|
||||||
|
for (int j = 0; j < pPlugin->GetFormatCount(); j++, c++)
|
||||||
{
|
{
|
||||||
if ((size_t)mFilterIndex == c)
|
if ((size_t)mFilterIndex == c)
|
||||||
{ // this is the selected format. Store the plug-in and sub-format
|
{ // this is the selected format. Store the plug-in and sub-format
|
||||||
|
@ -103,7 +103,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Exporter mExporter;
|
Exporter mExporter;
|
||||||
ExportPluginArray mPlugins; /**< Array of references to available exporter
|
std::vector<ExportPlugin*> mPlugins; /**< Array of references to available exporter
|
||||||
plug-ins */
|
plug-ins */
|
||||||
AudacityProject *mProject;
|
AudacityProject *mProject;
|
||||||
TrackList *mTracks; /**< The list of tracks in the project that is
|
TrackList *mTracks; /**< The list of tracks in the project that is
|
||||||
|
@ -128,7 +128,6 @@ class ExportOGG final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportOGG();
|
ExportOGG();
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
@ -159,11 +158,6 @@ ExportOGG::ExportOGG()
|
|||||||
SetDescription(_("Ogg Vorbis Files"),0);
|
SetDescription(_("Ogg Vorbis Files"),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportOGG::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ExportOGG::Export(AudacityProject *project,
|
int ExportOGG::Export(AudacityProject *project,
|
||||||
int numChannels,
|
int numChannels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
@ -362,9 +356,9 @@ bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, c
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPlugin *New_ExportOGG()
|
movable_ptr<ExportPlugin> New_ExportOGG()
|
||||||
{
|
{
|
||||||
return new ExportOGG();
|
return make_movable<ExportOGG>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_LIBVORBIS
|
#endif // USE_LIBVORBIS
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#ifndef __AUDACITY_EXPORTOGG__
|
#ifndef __AUDACITY_EXPORTOGG__
|
||||||
#define __AUDACITY_EXPORTOGG__
|
#define __AUDACITY_EXPORTOGG__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
/** The only part of this class which is publically accessible is the
|
/** The only part of this class which is publically accessible is the
|
||||||
* factory method New_ExportOGG() which creates a NEW ExportOGG object and
|
* factory method New_ExportOGG() which creates a NEW ExportOGG object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportOGG.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportOGG.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportOGG();
|
movable_ptr<ExportPlugin> New_ExportOGG();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -308,7 +308,6 @@ class ExportPCM final : public ExportPlugin
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExportPCM();
|
ExportPCM();
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
|
|
||||||
@ -378,11 +377,6 @@ ExportPCM::ExportPCM()
|
|||||||
SetMaxChannels(255, format);
|
SetMaxChannels(255, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportPCM::Destroy()
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param subformat Control whether we are doing a "preset" export to a popular
|
* @param subformat Control whether we are doing a "preset" export to a popular
|
||||||
@ -915,7 +909,7 @@ bool ExportPCM::CheckFileName(wxFileName &filename, int format)
|
|||||||
return ExportPlugin::CheckFileName(filename, format);
|
return ExportPlugin::CheckFileName(filename, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportPlugin *New_ExportPCM()
|
movable_ptr<ExportPlugin> New_ExportPCM()
|
||||||
{
|
{
|
||||||
return new ExportPCM();
|
return make_movable<ExportPCM>();
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#ifndef __AUDACITY_EXPORTPCM__
|
#ifndef __AUDACITY_EXPORTPCM__
|
||||||
#define __AUDACITY_EXPORTPCM__
|
#define __AUDACITY_EXPORTPCM__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
class ExportPlugin;
|
class ExportPlugin;
|
||||||
|
|
||||||
/** The only part of this class which is publically accessible is the
|
/** The only part of this class which is publically accessible is the
|
||||||
* factory method New_ExportPCM() which creates a NEW ExportPCM object and
|
* factory method New_ExportPCM() which creates a NEW ExportPCM object and
|
||||||
* returns a pointer to it. The rest of the class declaration is in ExportPCM.cpp
|
* returns a pointer to it. The rest of the class declaration is in ExportPCM.cpp
|
||||||
*/
|
*/
|
||||||
ExportPlugin *New_ExportPCM();
|
movable_ptr<ExportPlugin> New_ExportPCM();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user