diff --git a/aegisub/src/audio_provider_ffmpegsource.cpp b/aegisub/src/audio_provider_ffmpegsource.cpp index fb71a7fab..1134b2445 100644 --- a/aegisub/src/audio_provider_ffmpegsource.cpp +++ b/aegisub/src/audio_provider_ffmpegsource.cpp @@ -170,7 +170,7 @@ void FFmpegSourceAudioProvider::LoadAudio(wxString filename) { TrackMask = (1 << TrackNumber); try { - Index = DoIndexing(Indexer, CacheName, TrackMask, false); + Index = DoIndexing(Indexer, CacheName, TrackMask, GetErrorHandlingMode()); } catch (wxString temp) { ErrorMsg.Append(temp); throw ErrorMsg; diff --git a/aegisub/src/ffmpegsource_common.cpp b/aegisub/src/ffmpegsource_common.cpp index b2fb3acf6..4313b08ce 100644 --- a/aegisub/src/ffmpegsource_common.cpp +++ b/aegisub/src/ffmpegsource_common.cpp @@ -84,7 +84,7 @@ int FFMS_CC FFmpegSourceProvider::UpdateIndexingProgress(int64_t Current, int64_ /// @param IgnoreDecodeErrors True if audio decoding errors will be tolerated, false otherwise /// @return Returns the index object on success, NULL otherwise /// -FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, const wxString &CacheName, int Trackmask, bool IgnoreDecodeErrors) { +FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, const wxString &CacheName, int Trackmask, FFMS_IndexErrorHandling IndexEH) { char FFMSErrMsg[1024]; FFMS_ErrorInfo ErrInfo; ErrInfo.Buffer = FFMSErrMsg; @@ -101,10 +101,8 @@ FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, const wxStri Progress.ProgressDialog->Show(); Progress.ProgressDialog->SetProgress(0,1); - int ErrHandling = IgnoreDecodeErrors ? FFMS_IEH_IGNORE : FFMS_IEH_STOP_TRACK; - // index all audio tracks - FFMS_Index *Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE, NULL, NULL, ErrHandling, + FFMS_Index *Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE, NULL, NULL, IndexEH, FFmpegSourceProvider::UpdateIndexingProgress, &Progress, &ErrInfo); if (Index == NULL) { Progress.ProgressDialog->Destroy(); @@ -199,6 +197,21 @@ void FFmpegSourceProvider::SetLogLevel() { } +FFMS_IndexErrorHandling FFmpegSourceProvider::GetErrorHandlingMode() { + wxString Mode = Options.AsText(_T("FFmpegSource audio decoding error handling")); + + if (!Mode.CmpNoCase(_T("ignore"))) + return FFMS_IEH_IGNORE; + else if (!Mode.CmpNoCase(_T("clear"))) + return FFMS_IEH_CLEAR_TRACK; + else if (!Mode.CmpNoCase(_T("stop"))) + return FFMS_IEH_STOP_TRACK; + else if (!Mode.CmpNoCase(_T("abort"))) + return FFMS_IEH_ABORT; + else + return FFMS_IEH_STOP_TRACK; // questionable default? +} + /// @brief Generates an unique name for the ffms2 index file and prepares the cache folder if it doesn't exist /// @param filename The name of the source file diff --git a/aegisub/src/ffmpegsource_common.h b/aegisub/src/ffmpegsource_common.h index b12c97985..f9199e3c2 100644 --- a/aegisub/src/ffmpegsource_common.h +++ b/aegisub/src/ffmpegsource_common.h @@ -87,11 +87,12 @@ public: static int FFMS_CC UpdateIndexingProgress(int64_t Current, int64_t Total, void *Private); - FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, const wxString& Cachename, int Trackmask, bool IgnoreDecodeErrors); + FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, const wxString& Cachename, int Trackmask, FFMS_IndexErrorHandling IndexEH); std::map GetTracksOfType(FFMS_Indexer *Indexer, FFMS_TrackType Type); int AskForTrackSelection(const std::map& TrackList, FFMS_TrackType Type); wxString GetCacheFilename(const wxString& filename); void SetLogLevel(); + FFMS_IndexErrorHandling GetErrorHandlingMode(); virtual ~FFmpegSourceProvider() {} }; diff --git a/aegisub/src/options.cpp b/aegisub/src/options.cpp index 0ce82154e..6c914e0de 100644 --- a/aegisub/src/options.cpp +++ b/aegisub/src/options.cpp @@ -188,6 +188,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) { SetInt(_T("FFmpegSource max cache files"),20); SetInt(_T("FFmpegSource always index all tracks"), true); SetText(_T("FFmpegSource log level"), _T("quiet")); + SetText(_T("FFmpegSource audio decoding error handling"), _T("stop")); // Audio Options SetModificationType(MOD_AUTOMATIC); diff --git a/aegisub/src/video_provider_ffmpegsource.cpp b/aegisub/src/video_provider_ffmpegsource.cpp index d783be86f..ff329d298 100644 --- a/aegisub/src/video_provider_ffmpegsource.cpp +++ b/aegisub/src/video_provider_ffmpegsource.cpp @@ -171,7 +171,7 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) { int TrackMask = Options.AsBool(_T("FFmpegSource always index all tracks")) ? FFMS_TRACKMASK_ALL : FFMS_TRACKMASK_NONE; try { // ignore audio decoding errors here, we don't care right now - Index = DoIndexing(Indexer, CacheName, TrackMask, true); + Index = DoIndexing(Indexer, CacheName, TrackMask, FFMS_IEH_IGNORE); } catch (wxString temp) { ErrorMsg.Append(temp); throw ErrorMsg;