FFmpegSource2: no more exceptions

Originally committed to SVN as r2375.
This commit is contained in:
Fredrik Mellbin 2008-09-23 19:25:34 +00:00
parent b013a92923
commit 6898afabac
2 changed files with 20 additions and 20 deletions

View File

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

View File

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