1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 00:30:07 +02:00

NEW SOURCE FILE: Remove naked news and deletes in directory import

New source file is only a header however.
This commit is contained in:
Paul Licameli 2016-08-11 11:51:45 -04:00
commit 9c0ac0aaa4
35 changed files with 251 additions and 247 deletions

View File

@ -1213,6 +1213,7 @@
5E74D2E31CC4429700D88B0B /* EditCursorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2DD1CC4429700D88B0B /* EditCursorOverlay.cpp */; }; 5E74D2E31CC4429700D88B0B /* EditCursorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2DD1CC4429700D88B0B /* EditCursorOverlay.cpp */; };
5E74D2E41CC4429700D88B0B /* PlayIndicatorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2DF1CC4429700D88B0B /* PlayIndicatorOverlay.cpp */; }; 5E74D2E41CC4429700D88B0B /* PlayIndicatorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2DF1CC4429700D88B0B /* PlayIndicatorOverlay.cpp */; };
5E74D2E51CC4429700D88B0B /* Scrubbing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2E11CC4429700D88B0B /* Scrubbing.cpp */; }; 5E74D2E51CC4429700D88B0B /* Scrubbing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E74D2E11CC4429700D88B0B /* Scrubbing.cpp */; };
5E79B3411D5CC38D001D677D /* ImportGStreamer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E79B33F1D5CC38D001D677D /* ImportGStreamer.cpp */; };
5E94A1BA1D1F1C8400A8713A /* wxPanelWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E94A1B81D1F1C8400A8713A /* wxPanelWrapper.cpp */; }; 5E94A1BA1D1F1C8400A8713A /* wxPanelWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E94A1B81D1F1C8400A8713A /* wxPanelWrapper.cpp */; };
5ED1D0AD1CDE55BD00471E3C /* Overlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0A91CDE55BD00471E3C /* Overlay.cpp */; }; 5ED1D0AD1CDE55BD00471E3C /* Overlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0A91CDE55BD00471E3C /* Overlay.cpp */; };
5ED1D0AE1CDE55BD00471E3C /* OverlayPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0AB1CDE55BD00471E3C /* OverlayPanel.cpp */; }; 5ED1D0AE1CDE55BD00471E3C /* OverlayPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ED1D0AB1CDE55BD00471E3C /* OverlayPanel.cpp */; };
@ -2990,8 +2991,11 @@
5E74D2E01CC4429700D88B0B /* PlayIndicatorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayIndicatorOverlay.h; sourceTree = "<group>"; }; 5E74D2E01CC4429700D88B0B /* PlayIndicatorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayIndicatorOverlay.h; sourceTree = "<group>"; };
5E74D2E11CC4429700D88B0B /* Scrubbing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scrubbing.cpp; sourceTree = "<group>"; }; 5E74D2E11CC4429700D88B0B /* Scrubbing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scrubbing.cpp; sourceTree = "<group>"; };
5E74D2E21CC4429700D88B0B /* Scrubbing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scrubbing.h; sourceTree = "<group>"; }; 5E74D2E21CC4429700D88B0B /* Scrubbing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scrubbing.h; sourceTree = "<group>"; };
5E79B33F1D5CC38D001D677D /* ImportGStreamer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImportGStreamer.cpp; sourceTree = "<group>"; };
5E79B3401D5CC38D001D677D /* ImportGStreamer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImportGStreamer.h; sourceTree = "<group>"; };
5E94A1B81D1F1C8400A8713A /* wxPanelWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wxPanelWrapper.cpp; sourceTree = "<group>"; }; 5E94A1B81D1F1C8400A8713A /* wxPanelWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wxPanelWrapper.cpp; sourceTree = "<group>"; };
5E94A1B91D1F1C8400A8713A /* wxPanelWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wxPanelWrapper.h; sourceTree = "<group>"; }; 5E94A1B91D1F1C8400A8713A /* wxPanelWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wxPanelWrapper.h; sourceTree = "<group>"; };
5EB9EA281D5B81270050AF40 /* ImportForwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImportForwards.h; sourceTree = "<group>"; };
5ED18DB61CC16B1E00FAFE95 /* Reverb_libSoX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reverb_libSoX.h; sourceTree = "<group>"; }; 5ED18DB61CC16B1E00FAFE95 /* Reverb_libSoX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reverb_libSoX.h; sourceTree = "<group>"; };
5ED18DB71CC290AB00FAFE95 /* wxFileNameWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wxFileNameWrapper.h; sourceTree = "<group>"; }; 5ED18DB71CC290AB00FAFE95 /* wxFileNameWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wxFileNameWrapper.h; sourceTree = "<group>"; };
5ED1D0A91CDE55BD00471E3C /* Overlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Overlay.cpp; sourceTree = "<group>"; }; 5ED1D0A91CDE55BD00471E3C /* Overlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Overlay.cpp; sourceTree = "<group>"; };
@ -4216,16 +4220,15 @@
children = ( children = (
28F67173197DFA1C00075C32 /* FormatClassifier.cpp */, 28F67173197DFA1C00075C32 /* FormatClassifier.cpp */,
28F67174197DFA1C00075C32 /* FormatClassifier.h */, 28F67174197DFA1C00075C32 /* FormatClassifier.h */,
28F67175197DFA1C00075C32 /* MultiFormatReader.cpp */,
28F67176197DFA1C00075C32 /* MultiFormatReader.h */,
28F67177197DFA1C00075C32 /* SpecPowerMeter.cpp */,
28F67178197DFA1C00075C32 /* SpecPowerMeter.h */,
1790B07F09883BFD008A330A /* Import.cpp */, 1790B07F09883BFD008A330A /* Import.cpp */,
1790B08009883BFD008A330A /* Import.h */, 1790B08009883BFD008A330A /* Import.h */,
283135EA0DFB9D110076D551 /* ImportFFmpeg.cpp */, 283135EA0DFB9D110076D551 /* ImportFFmpeg.cpp */,
283135EB0DFB9D110076D551 /* ImportFFmpeg.h */, 283135EB0DFB9D110076D551 /* ImportFFmpeg.h */,
1790B08109883BFD008A330A /* ImportFLAC.cpp */, 1790B08109883BFD008A330A /* ImportFLAC.cpp */,
1790B08209883BFD008A330A /* ImportFLAC.h */, 1790B08209883BFD008A330A /* ImportFLAC.h */,
5EB9EA281D5B81270050AF40 /* ImportForwards.h */,
5E79B33F1D5CC38D001D677D /* ImportGStreamer.cpp */,
5E79B3401D5CC38D001D677D /* ImportGStreamer.h */,
1790B08309883BFD008A330A /* ImportLOF.cpp */, 1790B08309883BFD008A330A /* ImportLOF.cpp */,
1790B08409883BFD008A330A /* ImportLOF.h */, 1790B08409883BFD008A330A /* ImportLOF.h */,
1790B08509883BFD008A330A /* ImportMIDI.cpp */, 1790B08509883BFD008A330A /* ImportMIDI.cpp */,
@ -4241,8 +4244,12 @@
2801A6440BF9268700648258 /* ImportQT.h */, 2801A6440BF9268700648258 /* ImportQT.h */,
1790B08E09883BFD008A330A /* ImportRaw.cpp */, 1790B08E09883BFD008A330A /* ImportRaw.cpp */,
1790B08F09883BFD008A330A /* ImportRaw.h */, 1790B08F09883BFD008A330A /* ImportRaw.h */,
28F67175197DFA1C00075C32 /* MultiFormatReader.cpp */,
28F67176197DFA1C00075C32 /* MultiFormatReader.h */,
1790B09009883BFD008A330A /* RawAudioGuess.cpp */, 1790B09009883BFD008A330A /* RawAudioGuess.cpp */,
1790B09109883BFD008A330A /* RawAudioGuess.h */, 1790B09109883BFD008A330A /* RawAudioGuess.h */,
28F67177197DFA1C00075C32 /* SpecPowerMeter.cpp */,
28F67178197DFA1C00075C32 /* SpecPowerMeter.h */,
); );
path = import; path = import;
sourceTree = "<group>"; sourceTree = "<group>";
@ -7378,6 +7385,7 @@
1790B16309883BFD008A330A /* FreqWindow.cpp in Sources */, 1790B16309883BFD008A330A /* FreqWindow.cpp in Sources */,
1790B16509883BFD008A330A /* HistoryWindow.cpp in Sources */, 1790B16509883BFD008A330A /* HistoryWindow.cpp in Sources */,
1790B16609883BFD008A330A /* ImageManipulation.cpp in Sources */, 1790B16609883BFD008A330A /* ImageManipulation.cpp in Sources */,
5E79B3411D5CC38D001D677D /* ImportGStreamer.cpp in Sources */,
1790B16709883BFD008A330A /* Import.cpp in Sources */, 1790B16709883BFD008A330A /* Import.cpp in Sources */,
1790B16809883BFD008A330A /* ImportFLAC.cpp in Sources */, 1790B16809883BFD008A330A /* ImportFLAC.cpp in Sources */,
1790B16909883BFD008A330A /* ImportLOF.cpp in Sources */, 1790B16909883BFD008A330A /* ImportLOF.cpp in Sources */,

View File

@ -418,6 +418,7 @@ audacity_SOURCES = \
import/Import.h \ import/Import.h \
import/ImportFLAC.cpp \ import/ImportFLAC.cpp \
import/ImportFLAC.h \ import/ImportFLAC.h \
import/ImportForwards.h \
import/ImportLOF.cpp \ import/ImportLOF.cpp \
import/ImportLOF.h \ import/ImportLOF.h \
import/ImportMP3.cpp \ import/ImportMP3.cpp \

View File

@ -17,6 +17,8 @@ the low-pass-like spectral behaviour of natural audio signals
for classification of the sample format and the used endianness. for classification of the sample format and the used endianness.
*//*******************************************************************/ *//*******************************************************************/
#include "FormatClassifier.h"
#include <stdint.h> #include <stdint.h>
#include <cmath> #include <cmath>
#include <cfloat> #include <cfloat>
@ -29,8 +31,6 @@ for classification of the sample format and the used endianness.
#include "SpecPowerMeter.h" #include "SpecPowerMeter.h"
#include "sndfile.h" #include "sndfile.h"
#include "FormatClassifier.h"
FormatClassifier::FormatClassifier(const char* filename) : FormatClassifier::FormatClassifier(const char* filename) :
mReader(filename), mReader(filename),
mMeter(cSiglen) mMeter(cSiglen)

View File

@ -11,6 +11,13 @@
#ifndef __AUDACITY_FORMATCLASSIFIER_H_ #ifndef __AUDACITY_FORMATCLASSIFIER_H_
#define __AUDACITY_FORMATCLASSIFIER_H_ #define __AUDACITY_FORMATCLASSIFIER_H_
#include <vector>
#include "../SampleFormat.h"
#include "MultiFormatReader.h"
#include "SpecPowerMeter.h"
#include <sndfile.h>
#ifndef SNDFILE_1 #ifndef SNDFILE_1
#error Requires libsndfile 1.0.3 or higher #error Requires libsndfile 1.0.3 or higher
#endif #endif

View File

@ -37,6 +37,8 @@ and ImportLOF.cpp.
#include "../Audacity.h" #include "../Audacity.h"
#include "Import.h" #include "Import.h"
#include <algorithm>
#include "ImportPlugin.h" #include "ImportPlugin.h"
#include <wx/textctrl.h> #include <wx/textctrl.h>
@ -61,10 +63,6 @@ and ImportLOF.cpp.
#include "ImportGStreamer.h" #include "ImportGStreamer.h"
#include "../Prefs.h" #include "../Prefs.h"
WX_DEFINE_LIST(ImportPluginList);
WX_DEFINE_LIST(UnusableImportPluginList);
WX_DEFINE_OBJARRAY(ExtImportItems);
// ============================================================================ // ============================================================================
// //
// Return reference to singleton // Return reference to singleton
@ -79,23 +77,17 @@ Importer & Importer::Get()
Importer::Importer() Importer::Importer()
{ {
mExtImportItems = NULL;
} }
Importer::~Importer() Importer::~Importer()
{ {
if (mExtImportItems != NULL)
{
delete mExtImportItems;
mExtImportItems = NULL;
}
} }
bool Importer::Initialize() bool Importer::Initialize()
{ {
mImportPluginList = new ImportPluginList; ImportPluginList{}.swap(mImportPluginList);
mUnusableImportPluginList = new UnusableImportPluginList; UnusableImportPluginList{}.swap(mUnusableImportPluginList);
mExtImportItems = NULL; ExtImportItems{}.swap(mExtImportItems);
// build the list of import plugin and/or unusableImporters. // build the list of import plugin and/or unusableImporters.
// order is significant. If none match, they will all be tried // order is significant. If none match, they will all be tried
@ -124,20 +116,16 @@ bool Importer::Initialize()
bool Importer::Terminate() bool Importer::Terminate()
{ {
WriteImportItems(); WriteImportItems();
mImportPluginList->DeleteContents(true); ImportPluginList{}.swap( mImportPluginList );
delete mImportPluginList; UnusableImportPluginList{}.swap( mUnusableImportPluginList );
mUnusableImportPluginList->DeleteContents(true);//JKC
delete mUnusableImportPluginList;
return true; return true;
} }
void Importer::GetSupportedImportFormats(FormatList *formatList) void Importer::GetSupportedImportFormats(FormatList *formatList)
{ {
ImportPluginList::compatibility_iterator importPluginNode = mImportPluginList->GetFirst(); for(const auto &importPlugin : mImportPluginList)
while(importPluginNode)
{ {
ImportPlugin *importPlugin = importPluginNode->GetData();
#ifdef __AUDACITY_OLD_STD__ #ifdef __AUDACITY_OLD_STD__
formatList->push_back(Format{importPlugin->GetPluginFormatDescription(), formatList->push_back(Format{importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions()}); importPlugin->GetSupportedExtensions()});
@ -145,7 +133,6 @@ void Importer::GetSupportedImportFormats(FormatList *formatList)
formatList->emplace_back(importPlugin->GetPluginFormatDescription(), formatList->emplace_back(importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions()); importPlugin->GetSupportedExtensions());
#endif #endif
importPluginNode = importPluginNode->GetNext();
} }
} }
@ -163,13 +150,8 @@ void Importer::ReadImportItems()
wxStringTokenizer toker; wxStringTokenizer toker;
wxString item_name; wxString item_name;
wxString item_value; wxString item_value;
ExtImportItem *new_item;
ImportPluginList::compatibility_iterator importPluginNode;
if (this->mExtImportItems != NULL) ExtImportItems{}.swap(mExtImportItems);
delete this->mExtImportItems;
this->mExtImportItems = new ExtImportItems();
/* Rule string format is: /* Rule string format is:
* extension1:extension2:extension3\mime_type1:mime_type2:mime_type3|filter1:filter2:filter3\unusedfilter1:unusedfilter2 * extension1:extension2:extension3\mime_type1:mime_type2:mime_type3|filter1:filter2:filter3\unusedfilter1:unusedfilter2
* backslashes are escaped and unescaped internally * backslashes are escaped and unescaped internally
@ -187,7 +169,7 @@ void Importer::ReadImportItems()
if (toker.CountTokens() != 2) if (toker.CountTokens() != 2)
break; break;
new_item = new ExtImportItem(); auto new_item = make_movable<ExtImportItem>();
/* First token is the filtering condition, second - the filter list */ /* First token is the filtering condition, second - the filter list */
condition = toker.GetNextToken(); condition = toker.GetNextToken();
@ -228,29 +210,27 @@ void Importer::ReadImportItems()
/* Find corresponding filter object for each filter ID */ /* Find corresponding filter object for each filter ID */
for (size_t i = 0; i < new_item->filters.Count(); i++) for (size_t i = 0; i < new_item->filters.Count(); i++)
{ {
for (importPluginNode = mImportPluginList->GetFirst(); bool found = false;
importPluginNode; importPluginNode = importPluginNode->GetNext()) for (const auto &importPlugin : mImportPluginList)
{ {
ImportPlugin *importPlugin = importPluginNode->GetData();
if (importPlugin->GetPluginStringID().Cmp(new_item->filters[i]) == 0) if (importPlugin->GetPluginStringID().Cmp(new_item->filters[i]) == 0)
{ {
new_item->filter_objects.Add (importPlugin); new_item->filter_objects.Add (importPlugin.get());
found = true;
break; break;
} }
} }
/* IDs that do not have corresponding filters, will be shown as-is */ /* IDs that do not have corresponding filters, will be shown as-is */
if (!importPluginNode) if (!found)
new_item->filter_objects.Add (NULL); new_item->filter_objects.Add (NULL);
} }
/* Find all filter objects that are not present in the filter list */ /* Find all filter objects that are not present in the filter list */
for (importPluginNode = mImportPluginList->GetFirst(); for (const auto &importPlugin : mImportPluginList)
importPluginNode; importPluginNode = importPluginNode->GetNext())
{ {
bool found = false; bool found = false;
ImportPlugin *importPlugin = importPluginNode->GetData();
for (size_t i = 0; i < new_item->filter_objects.Count(); i++) for (size_t i = 0; i < new_item->filter_objects.Count(); i++)
{ {
if (importPlugin == new_item->filter_objects[i]) if (importPlugin.get() == new_item->filter_objects[i])
{ {
found = true; found = true;
break; break;
@ -263,12 +243,12 @@ void Importer::ReadImportItems()
if (new_item->divider < 0) if (new_item->divider < 0)
index = new_item->filters.Count(); index = new_item->filters.Count();
new_item->filters.Insert(importPlugin->GetPluginStringID(),index); new_item->filters.Insert(importPlugin->GetPluginStringID(),index);
new_item->filter_objects.Insert (importPlugin, index); new_item->filter_objects.Insert (importPlugin.get(), index);
if (new_item->divider >= 0) if (new_item->divider >= 0)
new_item->divider++; new_item->divider++;
} }
} }
this->mExtImportItems->Add (new_item); this->mExtImportItems.push_back( std::move(new_item) );
} }
} }
@ -276,9 +256,9 @@ void Importer::WriteImportItems()
{ {
size_t i; size_t i;
wxString val, name; wxString val, name;
for (i = 0; i < this->mExtImportItems->Count(); i++) for (i = 0; i < this->mExtImportItems.size(); i++)
{ {
ExtImportItem *item = &(mExtImportItems->Item(i)); ExtImportItem *item = mExtImportItems[i].get();
val.Clear(); val.Clear();
for (size_t j = 0; j < item->extensions.Count(); j++) for (size_t j = 0; j < item->extensions.Count(); j++)
@ -318,7 +298,7 @@ void Importer::WriteImportItems()
/* If we used to have more items than we have now, DELETE the excess items. /* If we used to have more items than we have now, DELETE the excess items.
We just keep deleting items and incrementing until we find there aren't any We just keep deleting items and incrementing until we find there aren't any
more to DELETE.*/ more to DELETE.*/
i = this->mExtImportItems->Count(); i = this->mExtImportItems.size();
do { do {
name.Printf (wxT("/ExtImportItems/Item%d"), (int)i); name.Printf (wxT("/ExtImportItems/Item%d"), (int)i);
// No item to DELETE? Then it's time to finish. // No item to DELETE? Then it's time to finish.
@ -333,21 +313,16 @@ void Importer::WriteImportItems()
} while( true ); } while( true );
} }
ExtImportItem *Importer::CreateDefaultImportItem() movable_ptr<ExtImportItem> Importer::CreateDefaultImportItem()
{ {
ExtImportItem *new_item; auto new_item = make_movable<ExtImportItem>();
ImportPluginList::compatibility_iterator importPluginNode;
new_item = new ExtImportItem();
new_item->extensions.Add(wxT("*")); new_item->extensions.Add(wxT("*"));
new_item->mime_types.Add(wxT("*")); new_item->mime_types.Add(wxT("*"));
for (importPluginNode = mImportPluginList->GetFirst(); for (const auto &importPlugin : mImportPluginList)
importPluginNode; importPluginNode = importPluginNode->GetNext())
{ {
ImportPlugin *importPlugin = importPluginNode->GetData();
new_item->filters.Add (importPlugin->GetPluginStringID()); new_item->filters.Add (importPlugin->GetPluginStringID());
new_item->filter_objects.Add (importPlugin); new_item->filter_objects.Add (importPlugin.get());
} }
new_item->divider = -1; new_item->divider = -1;
return new_item; return new_item;
@ -365,12 +340,13 @@ bool Importer::Import(const wxString &fName,
wxString extension = fName.AfterLast(wxT('.')); wxString extension = fName.AfterLast(wxT('.'));
using ImportPluginPtrs = std::vector< ImportPlugin* >;
// This list is used to call plugins in correct order // This list is used to call plugins in correct order
ImportPluginList importPlugins; ImportPluginPtrs importPlugins;
ImportPluginList::compatibility_iterator importPluginNode;
// This list is used to remember plugins that should have been compatible with the file. // This list is used to remember plugins that should have been compatible with the file.
ImportPluginList compatiblePlugins; ImportPluginPtrs compatiblePlugins;
// If user explicitly selected a filter, // If user explicitly selected a filter,
// then we should try importing via corresponding plugin first // then we should try importing via corresponding plugin first
@ -388,26 +364,23 @@ bool Importer::Import(const wxString &fName,
if (usersSelectionOverrides) if (usersSelectionOverrides)
{ {
importPluginNode = mImportPluginList->GetFirst(); for (const auto &plugin : mImportPluginList)
while (importPluginNode)
{ {
ImportPlugin *plugin = importPluginNode->GetData();
if (plugin->GetPluginFormatDescription().CompareTo(type) == 0) if (plugin->GetPluginFormatDescription().CompareTo(type) == 0)
{ {
// This plugin corresponds to user-selected filter, try it first. // This plugin corresponds to user-selected filter, try it first.
wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID().c_str()); wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID().c_str());
importPlugins.Insert(plugin); importPlugins.insert(importPlugins.begin(), plugin.get());
} }
importPluginNode = importPluginNode->GetNext();
} }
} }
wxLogMessage(wxT("File name is %s"),(const char *) fName.c_str()); wxLogMessage(wxT("File name is %s"),(const char *) fName.c_str());
wxLogMessage(wxT("Mime type is %s"),(const char *) mime_type.Lower().c_str()); wxLogMessage(wxT("Mime type is %s"),(const char *) mime_type.Lower().c_str());
for (size_t i = 0; i < mExtImportItems->Count(); i++) for (const auto &uItem : mExtImportItems)
{ {
ExtImportItem *item = &(*mExtImportItems)[i]; ExtImportItem *item = uItem.get();
bool matches_ext = false, matches_mime = false; bool matches_ext = false, matches_mime = false;
wxLogDebug(wxT("Testing extensions")); wxLogDebug(wxT("Testing extensions"));
for (size_t j = 0; j < item->extensions.Count(); j++) for (size_t j = 0; j < item->extensions.Count(); j++)
@ -454,13 +427,12 @@ bool Importer::Import(const wxString &fName,
if (!(item->filter_objects[j])) if (!(item->filter_objects[j]))
continue; continue;
wxLogDebug(wxT("Inserting %s"),item->filter_objects[j]->GetPluginStringID().c_str()); wxLogDebug(wxT("Inserting %s"),item->filter_objects[j]->GetPluginStringID().c_str());
importPlugins.Append(item->filter_objects[j]); importPlugins.push_back(item->filter_objects[j]);
} }
} }
} }
// Add all plugins that support the extension // Add all plugins that support the extension
importPluginNode = mImportPluginList->GetFirst();
// Here we rely on the fact that the first plugin in mImportPluginList is libsndfile. // Here we rely on the fact that the first plugin in mImportPluginList is libsndfile.
// We want to save this for later insertion ahead of libmad, if libmad supports the extension. // We want to save this for later insertion ahead of libmad, if libmad supports the extension.
@ -468,14 +440,14 @@ bool Importer::Import(const wxString &fName,
// is not changed by user selection overrides or any other mechanism, but we include an assert // is not changed by user selection overrides or any other mechanism, but we include an assert
// in case subsequent code revisions to the constructor should break this assumption that // in case subsequent code revisions to the constructor should break this assumption that
// libsndfile is first. // libsndfile is first.
ImportPlugin *libsndfilePlugin = importPluginNode->GetData(); ImportPlugin *libsndfilePlugin = mImportPluginList.begin()->get();
wxASSERT(libsndfilePlugin->GetPluginStringID().IsSameAs(wxT("libsndfile"))); wxASSERT(libsndfilePlugin->GetPluginStringID().IsSameAs(wxT("libsndfile")));
while (importPluginNode) for (const auto &plugin : mImportPluginList)
{ {
ImportPlugin *plugin = importPluginNode->GetData();
// Make sure its not already in the list // Make sure its not already in the list
if (importPlugins.Find(plugin) == NULL) if (importPlugins.end() ==
std::find(importPlugins.begin(), importPlugins.end(), plugin.get()))
{ {
if (plugin->SupportsExtension(extension)) if (plugin->SupportsExtension(extension))
{ {
@ -490,45 +462,40 @@ bool Importer::Import(const wxString &fName,
if (plugin->GetPluginStringID().IsSameAs(wxT("libmad"))) if (plugin->GetPluginStringID().IsSameAs(wxT("libmad")))
{ {
// Make sure libsndfile is not already in the list // Make sure libsndfile is not already in the list
if (importPlugins.Find(libsndfilePlugin) == NULL) if (importPlugins.end() ==
std::find(importPlugins.begin(), importPlugins.end(), libsndfilePlugin))
{ {
wxLogDebug(wxT("Appending %s"),libsndfilePlugin->GetPluginStringID().c_str()); wxLogDebug(wxT("Appending %s"),libsndfilePlugin->GetPluginStringID().c_str());
importPlugins.Append(libsndfilePlugin); importPlugins.push_back(libsndfilePlugin);
} }
} }
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str()); wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
importPlugins.Append(plugin); importPlugins.push_back(plugin.get());
} }
} }
importPluginNode = importPluginNode->GetNext();
} }
// Add remaining plugins, except for libmad, which should not be used as a fallback for anything. // Add remaining plugins, except for libmad, which should not be used as a fallback for anything.
// Otherwise, if FFmpeg (libav) has not been installed, libmad will still be there near the // Otherwise, if FFmpeg (libav) has not been installed, libmad will still be there near the
// end of the preference list importPlugins, where it will claim success importing FFmpeg file // end of the preference list importPlugins, where it will claim success importing FFmpeg file
// formats unsuitable for it, and produce distorted results. // formats unsuitable for it, and produce distorted results.
importPluginNode = mImportPluginList->GetFirst(); for (const auto &plugin : mImportPluginList)
while (importPluginNode)
{ {
ImportPlugin *plugin = importPluginNode->GetData();
if (!(plugin->GetPluginStringID().IsSameAs(wxT("libmad")))) if (!(plugin->GetPluginStringID().IsSameAs(wxT("libmad"))))
{ {
// Make sure its not already in the list // Make sure its not already in the list
if (importPlugins.Find(plugin) == NULL) if (importPlugins.end() ==
std::find(importPlugins.begin(), importPlugins.end(), plugin.get()))
{ {
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str()); wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
importPlugins.Append(plugin); importPlugins.push_back(plugin.get());
} }
} }
importPluginNode = importPluginNode->GetNext();
} }
importPluginNode = importPlugins.GetFirst(); // Try the import plugins, in the permuted sequences just determined
while(importPluginNode) for (const auto plugin : importPlugins)
{ {
ImportPlugin *plugin = importPluginNode->GetData();
// Try to open the file with this plugin (probe it) // Try to open the file with this plugin (probe it)
wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID().c_str()); wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID().c_str());
auto inFile = plugin->Open(fName); auto inFile = plugin->Open(fName);
@ -582,18 +549,14 @@ bool Importer::Import(const wxString &fName,
// that may recognize the extension, so we allow the loop to // that may recognize the extension, so we allow the loop to
// continue. // continue.
} }
importPluginNode = importPluginNode->GetNext();
} }
wxLogError(wxT("Importer::Import: Opening failed.")); wxLogError(wxT("Importer::Import: Opening failed."));
// None of our plugins can handle this file. It might be that // None of our plugins can handle this file. It might be that
// Audacity supports this format, but support was not compiled in. // Audacity supports this format, but support was not compiled in.
// If so, notify the user of this fact // If so, notify the user of this fact
UnusableImportPluginList::compatibility_iterator unusableImporterNode for (const auto &unusableImportPlugin : mUnusableImportPluginList)
= mUnusableImportPluginList->GetFirst();
while(unusableImporterNode)
{ {
UnusableImportPlugin *unusableImportPlugin = unusableImporterNode->GetData();
if( unusableImportPlugin->SupportsExtension(extension) ) if( unusableImportPlugin->SupportsExtension(extension) )
{ {
errorMessage.Printf(_("This version of Audacity was not compiled with %s support."), errorMessage.Printf(_("This version of Audacity was not compiled with %s support."),
@ -602,7 +565,6 @@ bool Importer::Import(const wxString &fName,
pProj->mbBusyImporting = false; pProj->mbBusyImporting = false;
return false; return false;
} }
unusableImporterNode = unusableImporterNode->GetNext();
} }
/* warnings for unsupported data types */ /* warnings for unsupported data types */
@ -616,7 +578,7 @@ bool Importer::Import(const wxString &fName,
} }
#endif #endif
if (compatiblePlugins.GetCount() <= 0) if (compatiblePlugins.empty())
{ {
// if someone has sent us a .cda file, send them away // if someone has sent us a .cda file, send them away
if (extension.IsSameAs(wxT("cda"), false)) { if (extension.IsSameAs(wxT("cda"), false)) {
@ -714,15 +676,12 @@ bool Importer::Import(const wxString &fName,
// We DO have a plugin for this file, but import failed. // We DO have a plugin for this file, but import failed.
wxString pluglist = wxEmptyString; wxString pluglist = wxEmptyString;
importPluginNode = compatiblePlugins.GetFirst(); for (const auto &plugin : compatiblePlugins)
while(importPluginNode)
{ {
ImportPlugin *plugin = importPluginNode->GetData();
if (pluglist == wxEmptyString) if (pluglist == wxEmptyString)
pluglist = plugin->GetPluginFormatDescription(); pluglist = plugin->GetPluginFormatDescription();
else else
pluglist = pluglist + wxT(", ") + plugin->GetPluginFormatDescription(); pluglist = pluglist + wxT(", ") + plugin->GetPluginFormatDescription();
importPluginNode = importPluginNode->GetNext();
} }
errorMessage.Printf(_("Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format."),fName.c_str(), pluglist.c_str()); errorMessage.Printf(_("Audacity recognized the type of the file '%s'.\nImporters supposedly supporting such files are:\n%s,\nbut none of them understood this file format."),fName.c_str(), pluglist.c_str());

View File

@ -12,6 +12,7 @@
#define _IMPORT_ #define _IMPORT_
#include "ImportRaw.h" // defines TrackHolders #include "ImportRaw.h" // defines TrackHolders
#include "ImportForwards.h"
#include <vector> #include <vector>
#include <wx/arrstr.h> #include <wx/arrstr.h>
#include <wx/string.h> #include <wx/string.h>
@ -44,7 +45,7 @@ class ExtImportItem;
using FormatList = std::vector<Format> ; using FormatList = std::vector<Format> ;
WX_DEFINE_ARRAY_PTR(ImportPlugin *, ImportPluginPtrArray); WX_DEFINE_ARRAY_PTR(ImportPlugin *, ImportPluginPtrArray);
WX_DECLARE_OBJARRAY(ExtImportItem, ExtImportItems); using ExtImportItems = std::vector< movable_ptr<ExtImportItem> >;
class ExtImportItem class ExtImportItem
{ {
@ -85,9 +86,6 @@ class ExtImportItem
wxArrayString mime_types; wxArrayString mime_types;
}; };
class ImportPluginList;
class UnusableImportPluginList;
class Importer { class Importer {
public: public:
Importer(); Importer();
@ -131,13 +129,13 @@ public:
* Returns a pointer to internal items array. * Returns a pointer to internal items array.
* External objects are allowed to change the array contents. * External objects are allowed to change the array contents.
*/ */
ExtImportItems *GetImportItems() { return mExtImportItems; }; ExtImportItems &GetImportItems() { return mExtImportItems; };
/** /**
* Allocates NEW ExtImportItem, fills it with default data * Allocates NEW ExtImportItem, fills it with default data
* and returns a pointer to it. * and returns a pointer to it.
*/ */
ExtImportItem *CreateDefaultImportItem(); movable_ptr<ExtImportItem> CreateDefaultImportItem();
// if false, the import failed and errorMessage will be set. // if false, the import failed and errorMessage will be set.
bool Import(const wxString &fName, bool Import(const wxString &fName,
@ -149,9 +147,9 @@ public:
private: private:
static Importer mInstance; static Importer mInstance;
ExtImportItems *mExtImportItems; ExtImportItems mExtImportItems;
ImportPluginList *mImportPluginList; ImportPluginList mImportPluginList;
UnusableImportPluginList *mUnusableImportPluginList; UnusableImportPluginList mUnusableImportPluginList;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -20,10 +20,12 @@ Licensed under the GNU General Public License v2 or later
*//*******************************************************************/ *//*******************************************************************/
#include "../Audacity.h" // needed before FFmpeg.h
#include "ImportFFmpeg.h"
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include "../Audacity.h" // needed before FFmpeg.h
#include "../FFmpeg.h" // which brings in avcodec.h, avformat.h #include "../FFmpeg.h" // which brings in avcodec.h, avformat.h
#include "../ondemand/ODManager.h" #include "../ondemand/ODManager.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
@ -151,7 +153,6 @@ static const wxChar *exts[] =
// all the includes live here by default // all the includes live here by default
#include "Import.h" #include "Import.h"
#include "ImportFFmpeg.h"
#include "../Tags.h" #include "../Tags.h"
#include "../Internat.h" #include "../Internat.h"
#include "../WaveTrack.h" #include "../WaveTrack.h"
@ -282,10 +283,10 @@ private:
}; };
void GetFFmpegImportPlugin(ImportPluginList *importPluginList, void GetFFmpegImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *WXUNUSED(unusableImportPluginList)) UnusableImportPluginList &WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new FFmpegImportPlugin); importPluginList.push_back( make_movable<FFmpegImportPlugin>() );
} }

View File

@ -11,12 +11,9 @@ LRN
#ifndef __AUDACITY_IMPORT_FFMPEG__ #ifndef __AUDACITY_IMPORT_FFMPEG__
#define __AUDACITY_IMPORT_FFMPEG__ #define __AUDACITY_IMPORT_FFMPEG__
#include "ImportPlugin.h" #include "ImportForwards.h"
class ImportPluginList; void GetFFmpegImportPlugin(ImportPluginList &importPluginList,
class UnusableImportPluginList; UnusableImportPluginList &unusableImportPluginList);
void GetFFmpegImportPlugin(ImportPluginList *importPluginList,
UnusableImportPluginList *unusableImportPluginList);
#endif #endif

View File

@ -22,6 +22,9 @@
*//*******************************************************************/ *//*******************************************************************/
#include "../Audacity.h"
#include "ImportFLAC.h"
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h> #include <wx/wxprec.h>
@ -33,7 +36,6 @@
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/intl.h> // needed for _("translated stings") even if we #include <wx/intl.h> // needed for _("translated stings") even if we
// don't have libflac available // don't have libflac available
#include "../Audacity.h"
#include "Import.h" #include "Import.h"
#include "ImportPlugin.h" #include "ImportPlugin.h"
@ -54,19 +56,18 @@ static const wxChar *exts[] =
#ifndef USE_LIBFLAC #ifndef USE_LIBFLAC
void GetFLACImportPlugin(ImportPluginList *importPluginList, void GetFLACImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList) UnusableImportPluginList &unusableImportPluginList)
{ {
UnusableImportPlugin* flacIsUnsupported = unusableImportPluginList.push_back(
new UnusableImportPlugin(DESC, wxArrayString(WXSIZEOF(exts), exts)); make_movable<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts));
unusableImportPluginList->Append(flacIsUnsupported); );
} }
#else /* USE_LIBFLAC */ #else /* USE_LIBFLAC */
#include "../Internat.h" #include "../Internat.h"
#include "ImportFLAC.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/utils.h> #include <wx/utils.h>
@ -281,10 +282,10 @@ FLAC__StreamDecoderWriteStatus MyFLACFile::write_callback(const FLAC__Frame *fra
} }
void GetFLACImportPlugin(ImportPluginList *importPluginList, void GetFLACImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *WXUNUSED(unusableImportPluginList)) UnusableImportPluginList &WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new FLACImportPlugin); importPluginList.push_back( make_movable<FLACImportPlugin>() );
} }

View File

@ -11,11 +11,10 @@
#ifndef __AUDACITY_IMPORT_FLAC__ #ifndef __AUDACITY_IMPORT_FLAC__
#define __AUDACITY_IMPORT_FLAC__ #define __AUDACITY_IMPORT_FLAC__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetFLACImportPlugin(ImportPluginList *importPluginList, void GetFLACImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -0,0 +1,23 @@
//
// ImportForwards.h
// Audacity
//
// Created by Paul Licameli on 8/10/16.
//
//
#ifndef __AUDACITY_IMPORT_FORWARDS__
#define __AUDACITY_IMPORT_FORWARDS__
#include <vector>
#include "../MemoryX.h"
class ImportPlugin;
class UnusableImportPlugin;
using ImportPluginList =
std::vector< movable_ptr<ImportPlugin> >;
using UnusableImportPluginList =
std::vector< movable_ptr<UnusableImportPlugin> >;
#endif

View File

@ -261,8 +261,8 @@ public:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Instantiate GStreamerImportPlugin and add to the list of known importers // Instantiate GStreamerImportPlugin and add to the list of known importers
void void
GetGStreamerImportPlugin(ImportPluginList *importPluginList, GetGStreamerImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList * WXUNUSED(unusableImportPluginList)) UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{ {
wxLogMessage(wxT("Audacity is built against GStreamer version %d.%d.%d-%d"), wxLogMessage(wxT("Audacity is built against GStreamer version %d.%d.%d-%d"),
GST_VERSION_MAJOR, GST_VERSION_MAJOR,
@ -300,7 +300,7 @@ GetGStreamerImportPlugin(ImportPluginList *importPluginList,
return; return;
// Add to list of importers // Add to list of importers
importPluginList->push_back(std::move(plug)); importPluginList.push_back( std::move(plug) );
} }
// ============================================================================ // ============================================================================

View File

@ -13,7 +13,7 @@ LRN
#include "ImportPlugin.h" #include "ImportPlugin.h"
void GetGStreamerImportPlugin(ImportPluginList *importPluginList, void GetGStreamerImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -175,10 +175,10 @@ LOFImportFileHandle::LOFImportFileHandle
scrollOffset = 0; scrollOffset = 0;
} }
void GetLOFImportPlugin(ImportPluginList *importPluginList, void GetLOFImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList * WXUNUSED(unusableImportPluginList)) UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new LOFImportPlugin); importPluginList.push_back( make_movable<LOFImportPlugin>() );
} }
wxString LOFImportPlugin::GetPluginFormatDescription() wxString LOFImportPlugin::GetPluginFormatDescription()

View File

@ -54,10 +54,9 @@
#ifndef __AUDACITY_IMPORT_LOF__ #ifndef __AUDACITY_IMPORT_LOF__
#define __AUDACITY_IMPORT_LOF__ #define __AUDACITY_IMPORT_LOF__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetLOFImportPlugin(ImportPluginList *importPluginList, void GetLOFImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -8,13 +8,14 @@
**********************************************************************/ **********************************************************************/
#include "../Audacity.h"
#include "ImportMIDI.h"
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/ffile.h> #include <wx/ffile.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "../Audacity.h"
#if defined(USE_MIDI) #if defined(USE_MIDI)
//#include "allegro.h" //#include "allegro.h"
@ -23,7 +24,6 @@
#include "../Internat.h" #include "../Internat.h"
#include "../NoteTrack.h" #include "../NoteTrack.h"
#include "ImportMIDI.h"
bool ImportMIDI(const wxString &fName, NoteTrack * dest) bool ImportMIDI(const wxString &fName, NoteTrack * dest)
{ {

View File

@ -22,6 +22,7 @@ into a NoteTrack.
#if defined(USE_MIDI) #if defined(USE_MIDI)
class wxString;
class NoteTrack; class NoteTrack;
bool ImportMIDI(const wxString &fName, NoteTrack * dest); bool ImportMIDI(const wxString &fName, NoteTrack * dest);

View File

@ -26,6 +26,9 @@
*//*******************************************************************/ *//*******************************************************************/
#include "../Audacity.h"
#include "ImportMP3.h"
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h> #include <wx/wxprec.h>
@ -35,11 +38,9 @@
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "../Audacity.h"
#include "../Prefs.h" #include "../Prefs.h"
#include "Import.h" #include "Import.h"
#include "ImportMP3.h"
#include "ImportPlugin.h" #include "ImportPlugin.h"
#include "../Internat.h" #include "../Internat.h"
#include "../Tags.h" #include "../Tags.h"
@ -55,13 +56,13 @@ static const wxChar *exts[] =
#ifndef USE_LIBMAD #ifndef USE_LIBMAD
void GetMP3ImportPlugin(ImportPluginList *importPluginList, void GetMP3ImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList) UnusableImportPluginList &unusableImportPluginList)
{ {
UnusableImportPlugin* mp3IsUnsupported = unusableImportPluginList.push_back(
new UnusableImportPlugin(DESC, wxArrayString(WXSIZEOF(exts), exts)); make_movable<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
unusableImportPluginList->Append(mp3IsUnsupported); );
} }
#else /* USE_LIBMAD */ #else /* USE_LIBMAD */
@ -152,10 +153,10 @@ private:
mad_decoder mDecoder; mad_decoder mDecoder;
}; };
void GetMP3ImportPlugin(ImportPluginList *importPluginList, void GetMP3ImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList * WXUNUSED(unusableImportPluginList)) UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new MP3ImportPlugin); importPluginList.push_back( make_movable<MP3ImportPlugin>() );
} }
/* The MAD callbacks */ /* The MAD callbacks */

View File

@ -11,10 +11,9 @@
#ifndef __AUDACITY_IMPORT_MP3__ #ifndef __AUDACITY_IMPORT_MP3__
#define __AUDACITY_IMPORT_MP3__ #define __AUDACITY_IMPORT_MP3__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetMP3ImportPlugin(ImportPluginList *importPluginList, void GetMP3ImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -28,6 +28,9 @@
*//*******************************************************************/ *//*******************************************************************/
#include "../Audacity.h"
#include "ImportOGG.h"
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h> #include <wx/wxprec.h>
@ -36,12 +39,10 @@
#endif #endif
#include <wx/intl.h> #include <wx/intl.h>
#include "../Audacity.h"
#include "../Prefs.h" #include "../Prefs.h"
#include "../Internat.h" #include "../Internat.h"
#include "../Tags.h" #include "../Tags.h"
#include "ImportOGG.h"
#define DESC _("Ogg Vorbis files") #define DESC _("Ogg Vorbis files")
@ -54,13 +55,13 @@ static const wxChar *exts[] =
/* BPF There is no real reason to compile without LIBVORBIS, but if you do, you will needs this header */ /* BPF There is no real reason to compile without LIBVORBIS, but if you do, you will needs this header */
#include "ImportPlugin.h" #include "ImportPlugin.h"
void GetOGGImportPlugin(ImportPluginList *importPluginList, void GetOGGImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList) UnusableImportPluginList &unusableImportPluginList)
{ {
UnusableImportPlugin* oggIsUnsupported = unusableImportPluginList.push_back(
new UnusableImportPlugin(DESC, wxArrayString(WXSIZEOF(exts), exts)); make_movable<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
unusableImportPluginList->Append(oggIsUnsupported); );
} }
#else /* USE_LIBVORBIS */ #else /* USE_LIBVORBIS */
@ -159,10 +160,10 @@ private:
sampleFormat mFormat; sampleFormat mFormat;
}; };
void GetOGGImportPlugin(ImportPluginList *importPluginList, void GetOGGImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList * WXUNUSED(unusableImportPluginList)) UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new OggImportPlugin); importPluginList.push_back( make_movable<OggImportPlugin>() );
} }
wxString OggImportPlugin::GetPluginFormatDescription() wxString OggImportPlugin::GetPluginFormatDescription()

View File

@ -11,10 +11,9 @@
#ifndef __AUDACITY_IMPORT_OGG__ #ifndef __AUDACITY_IMPORT_OGG__
#define __AUDACITY_IMPORT_OGG__ #define __AUDACITY_IMPORT_OGG__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetOGGImportPlugin(ImportPluginList *importPluginList, void GetOGGImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -20,10 +20,10 @@
*//*******************************************************************/ *//*******************************************************************/
#include "../Audacity.h" #include "../Audacity.h"
#include "ImportPCM.h"
#include "../AudacityApp.h" #include "../AudacityApp.h"
#include "../Internat.h" #include "../Internat.h"
#include "../Tags.h" #include "../Tags.h"
#include "ImportPCM.h"
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/string.h> #include <wx/string.h>
@ -113,10 +113,10 @@ private:
sampleFormat mFormat; sampleFormat mFormat;
}; };
void GetPCMImportPlugin(ImportPluginList * importPluginList, void GetPCMImportPlugin(ImportPluginList & importPluginList,
UnusableImportPluginList * WXUNUSED(unusableImportPluginList)) UnusableImportPluginList & WXUNUSED(unusableImportPluginList))
{ {
importPluginList->Append(new PCMImportPlugin); importPluginList.push_back( make_movable<PCMImportPlugin>() );
} }
wxString PCMImportPlugin::GetPluginFormatDescription() wxString PCMImportPlugin::GetPluginFormatDescription()

View File

@ -11,11 +11,10 @@
#ifndef __AUDACITY_IMPORT_PCM__ #ifndef __AUDACITY_IMPORT_PCM__
#define __AUDACITY_IMPORT_PCM__ #define __AUDACITY_IMPORT_PCM__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetPCMImportPlugin(ImportPluginList *importPluginList, void GetPCMImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -59,7 +59,6 @@ but little else.
#include <wx/arrstr.h> #include <wx/arrstr.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/list.h>
#include "../MemoryX.h" #include "../MemoryX.h"
#include "../widgets/ProgressDialog.h" #include "../widgets/ProgressDialog.h"
@ -197,7 +196,4 @@ private:
wxArrayString mExtensions; wxArrayString mExtensions;
}; };
WX_DECLARE_LIST(ImportPlugin, ImportPluginList);
WX_DECLARE_LIST(UnusableImportPlugin, UnusableImportPluginList);
#endif #endif

View File

@ -13,6 +13,7 @@
**********************************************************************/ **********************************************************************/
#include "../Audacity.h" #include "../Audacity.h"
#include "ImportQT.h"
#include "ImportPlugin.h" #include "ImportPlugin.h"
#define DESC _("QuickTime files") #define DESC _("QuickTime files")
@ -26,13 +27,13 @@ static const wxChar *exts[] =
#ifndef USE_QUICKTIME #ifndef USE_QUICKTIME
void GetQTImportPlugin(ImportPluginList *importPluginList, void GetQTImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList) UnusableImportPluginList &unusableImportPluginList)
{ {
UnusableImportPlugin* qtIsUnsupported = unusableImportPluginList.push_back(
new UnusableImportPlugin(DESC, wxArrayString(WXSIZEOF(exts), exts)); make_movable<UnusableImportPlugin>
(DESC, wxArrayString(WXSIZEOF(exts), exts))
unusableImportPluginList->Append(qtIsUnsupported); );
} }
#else /* USE_QUICKTIME */ #else /* USE_QUICKTIME */
@ -66,7 +67,6 @@ void GetQTImportPlugin(ImportPluginList *importPluginList,
#include "../Internat.h" #include "../Internat.h"
#include "../Tags.h" #include "../Tags.h"
#include "../WaveTrack.h" #include "../WaveTrack.h"
#include "ImportQT.h"
#define kQTAudioPropertyID_MaxAudioSampleSize 'mssz' #define kQTAudioPropertyID_MaxAudioSampleSize 'mssz'
@ -162,10 +162,10 @@ class QTImportFileHandle final : public ImportFileHandle
Movie mMovie; Movie mMovie;
}; };
void GetQTImportPlugin(ImportPluginList *importPluginList, void GetQTImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList) UnusableImportPluginList &unusableImportPluginList)
{ {
importPluginList->Append(new QTImportPlugin); importPluginList.push_back( make_movable<QTImportPlugin>() );
} }
wxString QTImportPlugin::GetPluginFormatDescription() wxString QTImportPlugin::GetPluginFormatDescription()

View File

@ -11,10 +11,9 @@
#ifndef __AUDACITY_IMPORT_QT__ #ifndef __AUDACITY_IMPORT_QT__
#define __AUDACITY_IMPORT_QT__ #define __AUDACITY_IMPORT_QT__
class ImportPluginList; #include "ImportForwards.h"
class UnusableImportPluginList;
void GetQTImportPlugin(ImportPluginList *importPluginList, void GetQTImportPlugin(ImportPluginList &importPluginList,
UnusableImportPluginList *unusableImportPluginList); UnusableImportPluginList &unusableImportPluginList);
#endif #endif

View File

@ -22,8 +22,8 @@ and sample size to help you importing data of an unknown format.
#include "../Audacity.h" #include "../Audacity.h"
#include "ImportRaw.h" #include "ImportRaw.h"
#include "Import.h" #include "Import.h"
#include "../DirManager.h" #include "../DirManager.h"

View File

@ -14,6 +14,8 @@ machine endianness representations.
*//*******************************************************************/ *//*******************************************************************/
#include "MultiFormatReader.h"
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <cstring> #include <cstring>
@ -22,7 +24,18 @@ machine endianness representations.
#include <wx/defs.h> #include <wx/defs.h>
#include "MultiFormatReader.h" MachineEndianness::MachineEndianness()
{
if (wxBYTE_ORDER == wxLITTLE_ENDIAN)
{
mFlag = MachineEndianness::Little;
}
else
{
mFlag = MachineEndianness::Big;
}
}
MultiFormatReader::MultiFormatReader(const char* filename) MultiFormatReader::MultiFormatReader(const char* filename)
: mpFid(NULL) : mpFid(NULL)

View File

@ -11,6 +11,9 @@
#ifndef __AUDACITY_MULTIFORMATREADER_H__ #ifndef __AUDACITY_MULTIFORMATREADER_H__
#define __AUDACITY_MULTIFORMATREADER_H__ #define __AUDACITY_MULTIFORMATREADER_H__
#include <stdio.h>
#include <stdint.h>
class MachineEndianness class MachineEndianness
{ {
public: public:
@ -20,17 +23,7 @@ public:
Big Big
} EndiannessT; } EndiannessT;
MachineEndianness() MachineEndianness();
{
if (wxBYTE_ORDER == wxLITTLE_ENDIAN)
{
mFlag = MachineEndianness::Little;
}
else
{
mFlag = MachineEndianness::Big;
}
}
~MachineEndianness() ~MachineEndianness()
{} {}

View File

@ -13,6 +13,8 @@
**********************************************************************/ **********************************************************************/
#include "RawAudioGuess.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -22,7 +24,6 @@
#include <wx/ffile.h> #include <wx/ffile.h>
#include "../Internat.h" #include "../Internat.h"
#include "RawAudioGuess.h"
#define RAW_GUESS_DEBUG 0 #define RAW_GUESS_DEBUG 0

View File

@ -16,12 +16,13 @@ measurements in subbands or in the entire signal band.
*//*******************************************************************/ *//*******************************************************************/
#include "SpecPowerMeter.h"
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <wx/defs.h> #include <wx/defs.h>
#include "../FFT.h" #include "../FFT.h"
#include "SpecPowerMeter.h"
SpecPowerMeter::SpecPowerMeter(int sigLen) SpecPowerMeter::SpecPowerMeter(int sigLen)
{ {

View File

@ -146,10 +146,13 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER); PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER);
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
for (unsigned int i = 0; i < items->Count(); i++) {
AddItemToTable (i, &(*items)[i]); int i = -1;
if (items->Count() > 0) for (const auto &item : items)
AddItemToTable (++i, item.get());
}
if (!items.empty())
{ {
RuleTable->SelectRow(0); RuleTable->SelectRow(0);
RuleTable->SetGridCursor(0,0); RuleTable->SetGridCursor(0,0);
@ -212,8 +215,8 @@ void ExtImportPrefs::SwapPluginRows (int row1, int row2)
long d, d2; long d, d2;
ImportPlugin *ip1, *ip2; ImportPlugin *ip1, *ip2;
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
ExtImportItem *item = &(*items)[last_selected]; ExtImportItem *item = items[last_selected].get();
t = PluginList->GetItemText (row1); t = PluginList->GetItemText (row1);
d = PluginList->GetItemData (row1); d = PluginList->GetItemData (row1);
@ -261,8 +264,8 @@ bool ExtImportPrefs::DoOnPluginKeyDown (int code)
if (last_selected == -1) if (last_selected == -1)
return false; return false;
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
ExtImportItem *item = &(*items)[last_selected]; ExtImportItem *item = items[last_selected].get();
if (code == WXK_UP && itemIndex == 0) if (code == WXK_UP && itemIndex == 0)
return false; return false;
@ -298,7 +301,6 @@ bool ExtImportPrefs::DoOnPluginKeyDown (int code)
void ExtImportPrefs::SwapRows (int row1, int row2) void ExtImportPrefs::SwapRows (int row1, int row2)
{ {
int t; int t;
ExtImportItem *t1, *t2;
wxString ts; wxString ts;
if (row1 == row2) if (row1 == row2)
return; return;
@ -308,11 +310,12 @@ void ExtImportPrefs::SwapRows (int row1, int row2)
row1 = row2; row1 = row2;
row2 = t; row2 = t;
} }
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
t1 = items->Detach(row1);
t2 = items->Detach(row1); auto &t1 = items[row1];
items->Insert (t1, row1); auto &t2 = items[row2];
items->Insert (t2, row1); std::swap(t1, t2);
for (int i = 0; i < RuleTable->GetNumberCols(); i++) for (int i = 0; i < RuleTable->GetNumberCols(); i++)
{ {
ts = RuleTable->GetCellValue (row2, i); ts = RuleTable->GetCellValue (row2, i);
@ -411,14 +414,14 @@ void ExtImportPrefs::OnRuleTableSelectRange (wxGridRangeSelectEvent& event)
void ExtImportPrefs::DoOnRuleTableSelect (int toprow) void ExtImportPrefs::DoOnRuleTableSelect (int toprow)
{ {
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
if (toprow < 0 || toprow > (int)items->GetCount()) if (toprow < 0 || toprow > (int)items.size())
{ {
return; return;
} }
ExtImportItem *item = &(*items)[toprow]; ExtImportItem *item = items[toprow].get();
PluginList->DeleteAllItems(); PluginList->DeleteAllItems();
int fcount; int fcount;
@ -463,8 +466,8 @@ void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event)
{ {
int row = event.GetRow(); int row = event.GetRow();
int col = event.GetCol(); int col = event.GetCol();
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
ExtImportItem *item = &(*items)[row]; ExtImportItem *item = items[row].get();
RuleTable->SaveEditControlValue(); RuleTable->SaveEditControlValue();
wxString val = RuleTable->GetCellValue (row, col); wxString val = RuleTable->GetCellValue (row, col);
@ -534,7 +537,7 @@ Audacity to trim spaces for you?"
RuleTable->AutoSizeColumns (); RuleTable->AutoSizeColumns ();
} }
void ExtImportPrefs::AddItemToTable (int index, ExtImportItem *item) void ExtImportPrefs::AddItemToTable (int index, const ExtImportItem *item)
{ {
wxString extensions, mime_types; wxString extensions, mime_types;
if (item->extensions.Count() > 0) if (item->extensions.Count() > 0)
@ -566,11 +569,12 @@ void ExtImportPrefs::AddItemToTable (int index, ExtImportItem *item)
void ExtImportPrefs::OnAddRule(wxCommandEvent& WXUNUSED(event)) void ExtImportPrefs::OnAddRule(wxCommandEvent& WXUNUSED(event))
{ {
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
ExtImportItem *item = Importer::Get().CreateDefaultImportItem(); auto uitem = Importer::Get().CreateDefaultImportItem();
items->Add (item); auto item = uitem.get();
items.push_back(std::move(uitem));
AddItemToTable (RuleTable->GetNumberRows (), item); AddItemToTable (RuleTable->GetNumberRows (), item);
RuleTable->SelectRow(RuleTable->GetNumberRows () - 1); RuleTable->SelectRow(RuleTable->GetNumberRows () - 1);
RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0); RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0);
RuleTable->SetFocus(); RuleTable->SetFocus();
@ -580,7 +584,7 @@ void ExtImportPrefs::OnDelRule(wxCommandEvent& WXUNUSED(event))
{ {
if (last_selected < 0) if (last_selected < 0)
return; return;
ExtImportItems *items = Importer::Get().GetImportItems(); auto &items = Importer::Get().GetImportItems();
int msgres = wxMessageBox (_("Do you really want to delete selected rule?"), int msgres = wxMessageBox (_("Do you really want to delete selected rule?"),
_("Rule deletion confirmation"), wxYES_NO, RuleTable); _("Rule deletion confirmation"), wxYES_NO, RuleTable);
@ -588,7 +592,7 @@ void ExtImportPrefs::OnDelRule(wxCommandEvent& WXUNUSED(event))
return; return;
RuleTable->DeleteRows (last_selected); RuleTable->DeleteRows (last_selected);
items->RemoveAt (last_selected); items.erase (items.begin() + last_selected);
RuleTable->AutoSizeColumns (); RuleTable->AutoSizeColumns ();
if (last_selected >= RuleTable->GetNumberRows ()) if (last_selected >= RuleTable->GetNumberRows ())
last_selected = RuleTable->GetNumberRows () - 1; last_selected = RuleTable->GetNumberRows () - 1;

View File

@ -100,7 +100,7 @@ class ExtImportPrefs final : public PrefsPanel
void DoOnRuleTableKeyDown (int keycode); void DoOnRuleTableKeyDown (int keycode);
bool DoOnPluginKeyDown (int code); bool DoOnPluginKeyDown (int code);
void DoOnRuleTableSelect (int toprow); void DoOnRuleTableSelect (int toprow);
void AddItemToTable (int index, ExtImportItem *item); void AddItemToTable (int index, const ExtImportItem *item);
void Populate(); void Populate();
void PopulateOrExchange(ShuttleGui & S); void PopulateOrExchange(ShuttleGui & S);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@ -432,6 +432,7 @@
<ClInclude Include="..\..\..\src\effects\Phaser.h" /> <ClInclude Include="..\..\..\src\effects\Phaser.h" />
<ClInclude Include="..\..\..\src\effects\VST\VSTControlMSW.h" /> <ClInclude Include="..\..\..\src\effects\VST\VSTControlMSW.h" />
<ClInclude Include="..\..\..\src\import\FormatClassifier.h" /> <ClInclude Include="..\..\..\src\import\FormatClassifier.h" />
<ClInclude Include="..\..\..\src\import\ImportForwards.h" />
<ClInclude Include="..\..\..\src\import\ImportGStreamer.h" /> <ClInclude Include="..\..\..\src\import\ImportGStreamer.h" />
<ClInclude Include="..\..\..\src\import\MultiFormatReader.h" /> <ClInclude Include="..\..\..\src\import\MultiFormatReader.h" />
<ClInclude Include="..\..\..\src\import\SpecPowerMeter.h" /> <ClInclude Include="..\..\..\src\import\SpecPowerMeter.h" />

View File

@ -1795,6 +1795,9 @@
<ClInclude Include="..\..\..\src\widgets\wxPanelWrapper.h"> <ClInclude Include="..\..\..\src\widgets\wxPanelWrapper.h">
<Filter>src\widgets</Filter> <Filter>src\widgets</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\src\import\ImportForwards.h">
<Filter>src\import</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\audacity.ico"> <Image Include="..\..\audacity.ico">