1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-19 17:40:51 +02:00

Bug 372 (P2) - import MP2s with libmad (Patch by Leland Lucius)

This commit is contained in:
mchinen 2011-06-01 14:47:43 +00:00
parent a0c1ac4cd3
commit 6e6367e958
2 changed files with 35 additions and 38 deletions

View File

@ -343,13 +343,14 @@ int Importer::Import(wxString fName,
// False if override filter is not found // False if override filter is not found
bool foundOverride = false; bool foundOverride = false;
gPrefs->Read(wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), &usersSelectionOverrides, false); gPrefs->Read(wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), &usersSelectionOverrides, false);
wxLogDebug(wxT("LastOpenType is %s"),type.c_str()); wxLogDebug(wxT("LastOpenType is %s"),type.c_str());
wxLogDebug(wxT("OverrideExtendedImportByOpenFileDialogChoice is %i"),usersSelectionOverrides); wxLogDebug(wxT("OverrideExtendedImportByOpenFileDialogChoice is %i"),usersSelectionOverrides);
if (usersSelectionOverrides) if (usersSelectionOverrides)
{ {
importPluginNode = mImportPluginList->GetFirst(); importPluginNode = mImportPluginList->GetFirst();
while(importPluginNode) while (importPluginNode)
{ {
ImportPlugin *plugin = importPluginNode->GetData(); ImportPlugin *plugin = importPluginNode->GetData();
if (plugin->GetPluginFormatDescription().CompareTo(type) == 0) if (plugin->GetPluginFormatDescription().CompareTo(type) == 0)
@ -362,9 +363,11 @@ int Importer::Import(wxString fName,
importPluginNode = importPluginNode->GetNext(); importPluginNode = importPluginNode->GetNext();
} }
} }
bool foundItem = false;
wxLogMessage(wxT("File name is %s"),fName.Lower().c_str()); wxLogMessage(wxT("File name is %s"),fName.Lower().c_str());
wxLogMessage(wxT("Mime type is %s"),mime_type.Lower().c_str()); wxLogMessage(wxT("Mime type is %s"),mime_type.Lower().c_str());
bool foundItem = false;
for (size_t i = 0; i < mExtImportItems->Count(); i++) for (size_t i = 0; i < mExtImportItems->Count(); i++)
{ {
ExtImportItem *item = &(*mExtImportItems)[i]; ExtImportItem *item = &(*mExtImportItems)[i];
@ -415,44 +418,37 @@ int Importer::Import(wxString fName,
} }
} }
if (!foundItem || (usersSelectionOverrides && !foundOverride)) // Add all plugins that support the extension
{
bool prioritizeMp3 = false;
if (usersSelectionOverrides && !foundOverride)
importPlugins.Clear();
wxLogDebug(wxT("Applying default rule"));
// Special treatment for mp3 files
if (wxMatchWild (wxT("*.mp3"),fName.Lower(), false))
prioritizeMp3 = true;
// By default just add all plugins (except for MP3)
importPluginNode = mImportPluginList->GetFirst(); importPluginNode = mImportPluginList->GetFirst();
while(importPluginNode) while (importPluginNode)
{ {
ImportPlugin *plugin = importPluginNode->GetData(); ImportPlugin *plugin = importPluginNode->GetData();
// Make sure its not already in the list
if (importPlugins.Find(plugin) == NULL) if (importPlugins.Find(plugin) == NULL)
{ {
// Skip MP3 import plugin. Opens some non-mp3 audio files (ac3 for example) as garbage. if (plugin->SupportsExtension(extension))
if (plugin->GetPluginFormatDescription().CompareTo( _("MP3 files") ) != 0)
{ {
wxLogDebug(wxT("Inserting %s"),plugin->GetPluginStringID().c_str()); wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
importPlugins.Append(plugin); importPlugins.Append(plugin);
} }
else if (prioritizeMp3)
{
if (usersSelectionOverrides)
{
wxLogDebug(wxT("Inserting %s at 1"),plugin->GetPluginStringID().c_str());
importPlugins.Insert((size_t) 1, plugin);
}
else
{
wxLogDebug(wxT("Inserting %s at 0"),plugin->GetPluginStringID().c_str());
importPlugins.Insert((size_t) 0, plugin);
}
}
} }
importPluginNode = importPluginNode->GetNext(); importPluginNode = importPluginNode->GetNext();
} }
// Add all remaining plugins
importPluginNode = mImportPluginList->GetFirst();
while (importPluginNode)
{
ImportPlugin *plugin = importPluginNode->GetData();
// Make sure its not already in the list
if (importPlugins.Find(plugin) == NULL)
{
wxLogDebug(wxT("Appending %s"),plugin->GetPluginStringID().c_str());
importPlugins.Append(plugin);
}
importPluginNode = importPluginNode->GetNext();
} }
importPluginNode = importPlugins.GetFirst(); importPluginNode = importPlugins.GetFirst();
@ -511,6 +507,7 @@ int Importer::Import(wxString fName,
importPluginNode = importPluginNode->GetNext(); 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

View File

@ -89,9 +89,9 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
{ {
S.SetBorder(2); S.SetBorder(2);
S.TieCheckBox(_("Filter chosen in OpenFile dialog overrides any rules"), S.TieCheckBox(_("Attempt to use filter in OpenFile dialog first"),
wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"), wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
false); true);
S.StartStatic(_("Rules to choose import filters"), 1); S.StartStatic(_("Rules to choose import filters"), 1);
{ {
S.SetSizerProportion(1); S.SetSizerProportion(1);