Allow user to set behavior of audio decoding errors during indexing with the FFMS2 providers.

Originally committed to SVN as r3822.
This commit is contained in:
Karl Blomster 2009-11-28 21:13:47 +00:00
parent b8561bf01d
commit 85d645b44a
5 changed files with 22 additions and 7 deletions

View File

@ -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;

View File

@ -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

View File

@ -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<int,wxString> GetTracksOfType(FFMS_Indexer *Indexer, FFMS_TrackType Type);
int AskForTrackSelection(const std::map<int,wxString>& TrackList, FFMS_TrackType Type);
wxString GetCacheFilename(const wxString& filename);
void SetLogLevel();
FFMS_IndexErrorHandling GetErrorHandlingMode();
virtual ~FFmpegSourceProvider() {}
};

View File

@ -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);

View File

@ -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;