From 73cc2d21c6a7157aa21e4d77d28ab8b2bddb9548 Mon Sep 17 00:00:00 2001 From: Thomas Goyne <plorkyeran@aegisub.org> Date: Mon, 17 Dec 2012 10:11:33 -0800 Subject: [PATCH] Check the error code when FFMS2 can't create an indexer Creating an indexer can fail for reasons other than the file not existing. This check is still not completely correct, since FFMS2 uses the wrong error codes in a bunch of places. --- aegisub/src/audio_provider_ffmpegsource.cpp | 8 ++++++-- aegisub/src/video_provider_ffmpegsource.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aegisub/src/audio_provider_ffmpegsource.cpp b/aegisub/src/audio_provider_ffmpegsource.cpp index 48e425409..cabfca9de 100644 --- a/aegisub/src/audio_provider_ffmpegsource.cpp +++ b/aegisub/src/audio_provider_ffmpegsource.cpp @@ -76,8 +76,12 @@ void FFmpegSourceAudioProvider::LoadAudio(wxString filename) { wxString FileNameShort = wxFileName(filename).GetShortPath(); FFMS_Indexer *Indexer = FFMS_CreateIndexer(FileNameShort.utf8_str(), &ErrInfo); - if (!Indexer) - throw agi::FileNotFoundError(ErrInfo.Buffer); + if (!Indexer) { + if (ErrInfo.SubType == FFMS_ERROR_FILE_READ) + throw agi::FileNotFoundError(ErrInfo.Buffer); + else + throw agi::AudioDataNotFoundError(ErrInfo.Buffer, 0); + } std::map<int,wxString> TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO); if (TrackList.size() <= 0) diff --git a/aegisub/src/video_provider_ffmpegsource.cpp b/aegisub/src/video_provider_ffmpegsource.cpp index f131a773b..ce28e6839 100644 --- a/aegisub/src/video_provider_ffmpegsource.cpp +++ b/aegisub/src/video_provider_ffmpegsource.cpp @@ -89,8 +89,12 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) { wxString FileNameShort = wxFileName(filename).GetShortPath(); FFMS_Indexer *Indexer = FFMS_CreateIndexer(FileNameShort.utf8_str(), &ErrInfo); - if (!Indexer) - throw agi::FileNotFoundError(ErrInfo.Buffer); + if (!Indexer) { + if (ErrInfo.SubType == FFMS_ERROR_FILE_READ) + throw agi::FileNotFoundError(ErrInfo.Buffer); + else + throw VideoNotSupported(ErrInfo.Buffer); + } std::map<int,wxString> TrackList = GetTracksOfType(Indexer, FFMS_TYPE_VIDEO); if (TrackList.size() <= 0) -- GitLab