From 6898afabacae2100528407d47b3c6a88b898319d Mon Sep 17 00:00:00 2001 From: Fredrik Mellbin Date: Tue, 23 Sep 2008 19:25:34 +0000 Subject: [PATCH] FFmpegSource2: no more exceptions Originally committed to SVN as r2375. --- FFmpegSource2/ffavisynth.cpp | 16 ++++------------ FFmpegSource2/ffms.cpp | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/FFmpegSource2/ffavisynth.cpp b/FFmpegSource2/ffavisynth.cpp index 47bdbecc0..5d5f05d94 100644 --- a/FFmpegSource2/ffavisynth.cpp +++ b/FFmpegSource2/ffavisynth.cpp @@ -26,13 +26,9 @@ AvisynthVideoSource::AvisynthVideoSource(const char *SourceFile, int Track, Fram SWS = NULL; ConvertToFormat = PIX_FMT_NONE; - try { - VS = FFMS_CreateVideoSource(SourceFile, Track, TrackIndices, PP, Threads, SeekMode, ErrorMsg, MsgSize); - if (!VS) - throw ErrorMsg; - } catch (...) { + VS = FFMS_CreateVideoSource(SourceFile, Track, TrackIndices, PP, Threads, SeekMode, ErrorMsg, MsgSize); + if (!VS) Env->ThrowError(ErrorMsg); - } const VideoProperties VP = *FFMS_GetVideoProperties(VS); @@ -145,13 +141,9 @@ PVideoFrame AvisynthVideoSource::GetFrame(int n, IScriptEnvironment *Env) { AvisynthAudioSource::AvisynthAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize) { memset(&VI, 0, sizeof(VI)); - try { - AS = FFMS_CreateAudioSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); - if (!AS) - throw ErrorMsg; - } catch (...) { + AS = FFMS_CreateAudioSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); + if (!AS) Env->ThrowError(ErrorMsg); - } const AudioProperties AP = *FFMS_GetAudioProperties(AS); diff --git a/FFmpegSource2/ffms.cpp b/FFmpegSource2/ffms.cpp index ee5423842..fa935072a 100644 --- a/FFmpegSource2/ffms.cpp +++ b/FFmpegSource2/ffms.cpp @@ -31,18 +31,26 @@ FFMS_API(void) FFMS_Init() { } FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize) { - switch (TrackIndices->Decoder) { - case 0: return new FFVideoSource(SourceFile, Track, TrackIndices, PP, Threads, SeekMode, ErrorMsg, MsgSize); - case 1: return new MatroskaVideoSource(SourceFile, Track, TrackIndices, PP, Threads, ErrorMsg, MsgSize); - default: return NULL; + try { + switch (TrackIndices->Decoder) { + case 0: return new FFVideoSource(SourceFile, Track, TrackIndices, PP, Threads, SeekMode, ErrorMsg, MsgSize); + case 1: return new MatroskaVideoSource(SourceFile, Track, TrackIndices, PP, Threads, ErrorMsg, MsgSize); + default: return NULL; + } + } catch (...) { + return NULL; } } FFMS_API(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize) { - switch (TrackIndices->Decoder) { - //case 0: return new FFVideoSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); - case 1: return new MatroskaAudioSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); - default: return NULL; + try { + switch (TrackIndices->Decoder) { + //case 0: return new FFVideoSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); + case 1: return new MatroskaAudioSource(SourceFile, Track, TrackIndices, ErrorMsg, MsgSize); + default: return NULL; + } + } catch (...) { + return NULL; } }