Update of /cvsroot/audacity/audacity-src/src/import In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv15003/src/import
Modified Files: Import.cpp ImportFFmpeg.cpp Log Message: String fixes. FreeLibs() now also sets mLibsLoaded to false. Hidden "NewImportingSession" preference - used as global variable, prevents FFmpeg from showing an error more than once for each import session (when multiple files are being imported) "Locate FFmpeg" dialog is shown only when Audacity can't find FFmpeg by itself. Reworked importing process: Importer will not try to import a file with the same plugin twice. Importer will only complain about unsupported format if none of the plugins really supports it. Before it complained, for example, that AC3 is not supported, in cases when FFmpeg failed to import an AC3 file. Index: Import.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/import/Import.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- Import.cpp 31 Aug 2008 06:26:23 -0000 1.48 +++ Import.cpp 15 Oct 2008 14:17:53 -0000 1.49 @@ -115,87 +115,103 @@ wxString extension = fName.AfterLast(wxT('.')); + // This list is used to call plugins in correct order + ImportPluginList *importPlugins = new ImportPluginList; + + bool haveCompatiblePlugin = false; + + ImportPluginList::Node *importPluginNode; + // If user explicitly selected a filter, // then we should try importing via corresponding plugin first wxString type = gPrefs->Read(wxT("/DefaultOpenType"),wxT("")); - ImportPluginList::Node *tryFirstNode = mImportPluginList->GetFirst(); - while(tryFirstNode) + + // First, add all explicitly compatible plugins + importPluginNode = mImportPluginList->GetFirst(); + while(importPluginNode) { - ImportPlugin *plugin = tryFirstNode->GetData(); + ImportPlugin *plugin = importPluginNode->GetData(); if (plugin->GetPluginFormatDescription().CompareTo(type) == 0) - break; - tryFirstNode= tryFirstNode->GetNext(); + { + // This plugin corresponds to user-selected filter, try it first. + importPlugins->Insert(plugin); + } + else if (plugin->SupportsExtension(extension)) + { + importPlugins->Append(plugin); + } + if (plugin->SupportsExtension(extension)) + haveCompatiblePlugin = true; + importPluginNode = importPluginNode->GetNext(); } - // see if any of the plugins expect this extension and if so give - // that plugin first dibs - ImportPluginList::Node *importPluginNode = mImportPluginList->GetFirst(); - ImportPluginList::Node *tmpNode; + // Next, add all other plugins + importPluginNode = mImportPluginList->GetFirst(); while(importPluginNode) { - if (tryFirstNode) + ImportPlugin *plugin = importPluginNode->GetData(); + if (importPlugins->Find(plugin) == NULL) { - tmpNode = importPluginNode; - importPluginNode = tryFirstNode; + // Skip MP3 import plugin. Opens some non-mp3 audio files (ac3 for example) as garbage. + if (plugin->GetPluginFormatDescription().CompareTo( _("MP3 files") ) != 0) + { + importPlugins->Append(plugin); + } } + importPluginNode = importPluginNode->GetNext(); + } + + importPluginNode = importPlugins->GetFirst(); + while(importPluginNode) + { ImportPlugin *plugin = importPluginNode->GetData(); - // Do not use this plugin if it doesn't supports the file's extension - if (plugin->SupportsExtension(extension)) + // Try to open the file with this plugin (probe it) + mInFile = plugin->Open(fName); + if ( (mInFile != NULL) && (mInFile->GetStreamCount() > 0) ) { - // Try to open the file with this plugin (probe it) - mInFile = plugin->Open(fName); - if ( (mInFile != NULL) && (mInFile->GetStreamCount() > 0) ) + // File has more than one stream - display stream selector + if (mInFile->GetStreamCount() > 1) { - // File has more than one stream - display stream selector - if (mInFile->GetStreamCount() > 1) - { - ImportStreamDialog ImportDlg(mInFile, NULL, -1, _("Select stream(s) to import")); + ImportStreamDialog ImportDlg(mInFile, NULL, -1, _("Select stream(s) to import")); - if (ImportDlg.ShowModal() == wxID_CANCEL) - { - return 0; - } + if (ImportDlg.ShowModal() == wxID_CANCEL) + { + return 0; } - // One stream - import it by default - else - mInFile->SetStreamUsage(0,TRUE); - - int res; - - res = mInFile->Import(trackFactory, tracks, &numTracks, tags); + } + // One stream - import it by default + else + mInFile->SetStreamUsage(0,TRUE); - delete mInFile; + int res; + + res = mInFile->Import(trackFactory, tracks, &numTracks, tags); - if (res == eImportSuccess) - { - // LOF ("list-of-files") has different semantics - if (extension.IsSameAs(wxT("lof"), false)) - return 1; + delete mInFile; - if (numTracks > 0) { - // success! - return numTracks; - } - } + if (res == eImportSuccess) + { + // LOF ("list-of-files") has different semantics + if (extension.IsSameAs(wxT("lof"), false)) + return 1; - if (res == eImportCancelled) - { - return 0; + if (numTracks > 0) { + // success! + return numTracks; } + } - // We could exit here since we had a match on the file extension, - // but there may be another plug-in that can import the file and - // that may recognize the extension, so we allow the loop to - // continue. + if (res == eImportCancelled) + { + return 0; } + + // We could exit here since we had a match on the file extension, + // but there may be another plug-in that can import the file and + // that may recognize the extension, so we allow the loop to + // continue. } - if (tryFirstNode) - { - importPluginNode = tmpNode; - tryFirstNode = NULL; - } - else - importPluginNode = importPluginNode->GetNext(); + importPluginNode = importPluginNode->GetNext(); } // None of our plugins can handle this file. It might be that @@ -218,39 +234,6 @@ /* warnings for unsupported data types */ - // if someone has sent us a .cda file, send them away - if (extension.IsSameAs(wxT("cda"), false)) { - /* i18n-hint: %s will be the filename */ - errorMessage.Printf(_("\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - // playlist type files - if ((extension.IsSameAs(wxT("m3u"), false))||(extension.IsSameAs(wxT("ram"), false))||(extension.IsSameAs(wxT("pls"), false))) { - errorMessage.Printf(_("\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files."), fName.c_str()); - return 0; - } - //WMA files of various forms - if ((extension.IsSameAs(wxT("wma"), false))||(extension.IsSameAs(wxT("asf"), false))) { - errorMessage.Printf(_("\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - //AAC files of various forms (probably not encrypted) - if ((extension.IsSameAs(wxT("aac"), false))||(extension.IsSameAs(wxT("m4a"), false))||(extension.IsSameAs(wxT("m4r"), false))||(extension.IsSameAs(wxT("mp4"), false))) { - errorMessage.Printf(_("\"%s\" is an Advanced Audio Coding file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - // encrypted itunes files - if ((extension.IsSameAs(wxT("m4p"), false))) { - errorMessage.Printf(_("\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF."), fName.c_str()); - return 0; - } - // Real Inc. files of various sorts - if ((extension.IsSameAs(wxT("ra"), false))||(extension.IsSameAs(wxT("rm"), false))||(extension.IsSameAs(wxT("rpm"), false))) { - errorMessage.Printf(_("\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - #ifdef USE_MIDI // MIDI files must be imported, not opened if ((extension.IsSameAs(wxT("midi"), false))||(extension.IsSameAs(wxT("mid"), false))) { @@ -259,105 +242,86 @@ } #endif - // Other notes-based formats - if ((extension.IsSameAs(wxT("kar"), false))||(extension.IsSameAs(wxT("mod"), false))||(extension.IsSameAs(wxT("rmi"), false))) { - errorMessage.Printf(_("\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity."), fName.c_str()); - return 0; - } - - // MusePack files - if ((extension.IsSameAs(wxT("mp+"), false))||(extension.IsSameAs(wxT("mpc"), false))||(extension.IsSameAs(wxT("mpp"), false))) { - errorMessage.Printf(_("\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - // WavPack files - if ((extension.IsSameAs(wxT("wv"), false))||(extension.IsSameAs(wxT("wvc"), false))) { - errorMessage.Printf(_("\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - // AC3 files - if ((extension.IsSameAs(wxT("ac3"), false))) { - errorMessage.Printf(_("\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - // Speex files - if ((extension.IsSameAs(wxT("spx"), false))) { - errorMessage.Printf(_("\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - // Video files of various forms - if ((extension.IsSameAs(wxT("mpg"), false))||(extension.IsSameAs(wxT("mpeg"), false))||(extension.IsSameAs(wxT("avi"), false))||(extension.IsSameAs(wxT("wmv"), false))||(extension.IsSameAs(wxT("rv"), false))) { - errorMessage.Printf(_("\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF."), fName.c_str()); - return 0; - } - - - // no importPlugin that recognized the extension succeeded. However, the - // file might be misnamed. So this time we try all the importPlugins - //in order and see if any of them can handle the file - importPluginNode = mImportPluginList->GetFirst(); - while(importPluginNode) + if (!haveCompatiblePlugin) { - ImportPlugin *plugin = importPluginNode->GetData(); - - // Skip MP3 import plugin. Opens some non-mp3 audio files (ac3 for example) as garbage. - while ( importPluginNode && ( plugin->GetPluginFormatDescription().CompareTo( _("MP3 files") ) == 0 ) ) - { - importPluginNode = importPluginNode->GetNext(); - plugin = importPluginNode->GetData(); + // if someone has sent us a .cda file, send them away + if (extension.IsSameAs(wxT("cda"), false)) { + /* i18n-hint: %s will be the filename */ + errorMessage.Printf(_("\"%s\" is an audio CD track. \nAudacity cannot open audio CDs directly. \nExtract (rip) the CD tracks to an audio format that \nAudacity can import, such as WAV or AIFF."), fName.c_str()); + return 0; } - - mInFile = plugin->Open(fName); - if ( (mInFile != NULL) && (mInFile->GetStreamCount() > 0) ) - { - if (mInFile->GetStreamCount() > 1) - { - ImportStreamDialog ImportDlg(mInFile, NULL, -1, _("Select stream(s) to import")); - - if (ImportDlg.ShowModal() == wxID_CANCEL) - { - return 0; - } - } - else - mInFile->SetStreamUsage(0,TRUE); - - - int res; - - numTracks = 0; - res = mInFile->Import(trackFactory, tracks, &numTracks, tags); - delete mInFile; - - if (res == eImportSuccess) - { - if (numTracks > 0) - { - // success! - errorMessage.Printf(_( "Audacity had to guess at the type of file.\n\nIt was identified as: \"%s\".\n\nIf the audio does not sound right, try renaming the file\nso that it has the correct extension before opening it."), - plugin->GetPluginFormatDescription().c_str()); - return numTracks; - } - } - - if (res == eImportCancelled) - { - return 0; - } - - // The import failed so we allow the loop to continue since - // there may be another plugin that can successfully load - // the file. + + // playlist type files + if ((extension.IsSameAs(wxT("m3u"), false))||(extension.IsSameAs(wxT("ram"), false))||(extension.IsSameAs(wxT("pls"), false))) { + errorMessage.Printf(_("\"%s\" is a playlist file. \nAudacity cannot open this file because it only contains links to other files. \nYou may be able to open it in a text editor and download the actual audio files."), fName.c_str()); + return 0; } - importPluginNode = importPluginNode->GetNext(); + //WMA files of various forms + if ((extension.IsSameAs(wxT("wma"), false))||(extension.IsSameAs(wxT("asf"), false))) { + errorMessage.Printf(_("\"%s\" is a Windows Media Audio file. \nAudacity cannot open this type of file due to patent restrictions. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + //AAC files of various forms (probably not encrypted) + if ((extension.IsSameAs(wxT("aac"), false))||(extension.IsSameAs(wxT("m4a"), false))||(extension.IsSameAs(wxT("m4r"), false))||(extension.IsSameAs(wxT("mp4"), false))) { + errorMessage.Printf(_("\"%s\" is an Advanced Audio Coding file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + // encrypted itunes files + if ((extension.IsSameAs(wxT("m4p"), false))) { + errorMessage.Printf(_("\"%s\" is an encrypted audio file. \nThese typically are from an online music store. \nAudacity cannot open this type of file due to the encryption. \nTry recording the file into Audacity, or burn it to audio CD then \nextract the CD track to a supported audio format such as WAV or AIFF."), fName.c_str()); + return 0; + } + // Real Inc. files of various sorts + if ((extension.IsSameAs(wxT("ra"), false))||(extension.IsSameAs(wxT("rm"), false))||(extension.IsSameAs(wxT("rpm"), false))) { + errorMessage.Printf(_("\"%s\" is a RealPlayer media file. \nAudacity cannot open this proprietary format. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // Other notes-based formats + if ((extension.IsSameAs(wxT("kar"), false))||(extension.IsSameAs(wxT("mod"), false))||(extension.IsSameAs(wxT("rmi"), false))) { + errorMessage.Printf(_("\"%s\" is a notes-based file, not an audio file. \nAudacity cannot open this type of file. \nTry converting it to an audio file such as WAV or AIFF and \nthen import it, or record it into Audacity."), fName.c_str()); + return 0; + } + + // MusePack files + if ((extension.IsSameAs(wxT("mp+"), false))||(extension.IsSameAs(wxT("mpc"), false))||(extension.IsSameAs(wxT("mpp"), false))) { + errorMessage.Printf(_("\"%s\" is a Musepack audio file. \nAudacity cannot open this type of file. \nIf you think it might be an mp3 file, rename it to end with \".mp3\" \nand try importing it again. Otherwise you need to convert it to a supported audio \nformat, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // WavPack files + if ((extension.IsSameAs(wxT("wv"), false))||(extension.IsSameAs(wxT("wvc"), false))) { + errorMessage.Printf(_("\"%s\" is a Wavpack audio file. \nAudacity cannot open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // AC3 files + if ((extension.IsSameAs(wxT("ac3"), false))) { + errorMessage.Printf(_("\"%s\" is a Dolby Digital audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // Speex files + if ((extension.IsSameAs(wxT("spx"), false))) { + errorMessage.Printf(_("\"%s\" is an Ogg Speex audio file. \nAudacity cannot currently open this type of file. \nYou need to convert it to a supported audio format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // Video files of various forms + if ((extension.IsSameAs(wxT("mpg"), false))||(extension.IsSameAs(wxT("mpeg"), false))||(extension.IsSameAs(wxT("avi"), false))||(extension.IsSameAs(wxT("wmv"), false))||(extension.IsSameAs(wxT("rv"), false))) { + errorMessage.Printf(_("\"%s\" is a video file. \nAudacity cannot currently open this type of file. \nYou need to extract the audio to a supported format, such as WAV or AIFF."), fName.c_str()); + return 0; + } + + // we were not able to recognize the file type + errorMessage.Printf(_("Audacity did not recognize the type of the file '%s'.\nIf it is uncompressed, try importing it using \"Import Raw\"."),fName.c_str()); + } + else + { + // We DO have a plugin for this file, but import failed. + errorMessage.Printf(_("Audacity recognized the type of the file '%s',\nbut was unable to import it."),fName.c_str()); } - // we were not able to recognize the file type - errorMessage = _("Audacity did not recognize the type of this file.\nIf it is uncompressed, try importing it using \"Import Raw\"." ); return 0; } Index: ImportFFmpeg.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/import/ImportFFmpeg.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ImportFFmpeg.cpp 14 Oct 2008 15:41:16 -0000 1.23 +++ ImportFFmpeg.cpp 15 Oct 2008 14:17:53 -0000 1.24 @@ -305,13 +305,16 @@ //If we don't have FFmpeg configured - tell the user about it. //Since this will be happening often, use disableable "FFmpeg not found" dialog //insdead of usual wxMessageBox() + bool newsession = false; + gPrefs->Read(wxT("/NewImportingSession"), &newsession); if (!FFmpegLibsInst->ValidLibsLoaded()) { int dontShowDlg; FFmpegNotFoundDialog *dlg; gPrefs->Read(wxT("/FFmpeg/NotFoundDontShow"),&dontShowDlg,0); - if (dontShowDlg == 0) + if (dontShowDlg == 0 && newsession) { + gPrefs->Write(wxT("/NewImportingSession"), false); dlg = new FFmpegNotFoundDialog(NULL); dlg->ShowModal(); delete dlg; ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs