From fabcd033b0cd23cd915388ed1560b6840f21c3ee Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Tue, 23 Sep 2008 21:06:11 +0000 Subject: [PATCH] ffms2 providers: better error messages Originally committed to SVN as r2382. --- aegisub/audio_provider_ffmpegsource.cpp | 13 +++++++++---- aegisub/video_provider_ffmpegsource.cpp | 22 +++++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/aegisub/audio_provider_ffmpegsource.cpp b/aegisub/audio_provider_ffmpegsource.cpp index 4889791fd..74e094d80 100644 --- a/aegisub/audio_provider_ffmpegsource.cpp +++ b/aegisub/audio_provider_ffmpegsource.cpp @@ -46,6 +46,7 @@ FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) { FFMS_Init(); MsgSize = sizeof(FFMSErrMsg); + MsgString = _T("FFmpegSource audio provider: "); AudioSource = NULL; Index = NULL; @@ -85,14 +86,16 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) { Index = FFMS_MakeIndex(FileNameWX.char_str(), FFMSTrackMaskAll, CacheName.char_str(), FFmpegSourceProvider::UpdateIndexingProgress, &Progress, FFMSErrMsg, MsgSize); if (Index == NULL) { Progress.ProgressDialog->Destroy(); - MsgString.Printf(_T("FFmpegSource audio provider: %s"), FFMSErrMsg); + wxString temp(FFMSErrMsg, wxConvUTF8); + MsgString << _T("failed to index: ") << temp; throw MsgString; } Progress.ProgressDialog->Destroy(); // write index to disk for later use if (FFMS_WriteIndex(CacheName.char_str(), Index, FFMSErrMsg, MsgSize)) { - MsgString.Printf(_T("FFmpegSource audio provider: %s"), FFMSErrMsg); + wxString temp(FFMSErrMsg, wxConvUTF8); + MsgString << _T("failed to write index: ") << temp; throw MsgString; } } @@ -100,7 +103,8 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) { // FIXME: provide a way to choose which audio track to load? AudioSource = FFMS_CreateAudioSource(FileNameWX.char_str(), FFMSFirstSuitableTrack, Index, FFMSErrMsg, MsgSize); if (!AudioSource) { - MsgString.Printf(_T("FFmpegSource audio provider: %s"), FFMSErrMsg); + wxString temp(FFMSErrMsg, wxConvUTF8); + MsgString << _T("failed to open audio track: ") << temp; throw MsgString; } @@ -149,7 +153,8 @@ void FFmpegSourceAudioProvider::Close() { // Get audio void FFmpegSourceAudioProvider::GetAudio(void *Buf, int64_t Start, int64_t Count) { if (FFMS_GetAudio(AudioSource, Buf, Start, Count, FFMSErrMsg, MsgSize)) { - MsgString.Printf(_T("FFmpegSource audio provider: %s"), FFMSErrMsg); + wxString temp(FFMSErrMsg, wxConvUTF8); + MsgString << _T("failed to get audio samples: ") << temp; throw MsgString; } } diff --git a/aegisub/video_provider_ffmpegsource.cpp b/aegisub/video_provider_ffmpegsource.cpp index ab6230b99..69fd2bb59 100644 --- a/aegisub/video_provider_ffmpegsource.cpp +++ b/aegisub/video_provider_ffmpegsource.cpp @@ -56,6 +56,7 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, d KeyFramesLoaded = false; FrameNumber = -1; MessageSize = sizeof(FFMSErrorMessage); + ErrorMsg = _T("FFmpegSource video provider: "); // and here we go try { @@ -99,14 +100,16 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) Index = FFMS_MakeIndex(FileNameWX.char_str(), FFMSTrackMaskAll, CacheName.char_str(), FFmpegSourceProvider::UpdateIndexingProgress, &Progress, FFMSErrorMessage, MessageSize); if (Index == NULL) { Progress.ProgressDialog->Destroy(); - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("failed to index: ") << temp; throw ErrorMsg; } Progress.ProgressDialog->Destroy(); // write it to disk if (FFMS_WriteIndex(CacheName.char_str(), Index, FFMSErrorMessage, MessageSize)) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("failed to write index: ") << temp; throw ErrorMsg; } } @@ -126,7 +129,8 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) VideoSource = FFMS_CreateVideoSource(FileNameWX.char_str(), FFMSFirstSuitableTrack, Index, "", Threads, SeekMode, FFMSErrorMessage, MessageSize); if (VideoSource == NULL) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("failed to open video track: ") << temp; throw ErrorMsg; } @@ -136,12 +140,14 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) // get frame info data FrameInfoVector *FrameData = FFMS_GetVSTrackIndex(VideoSource, FFMSErrorMessage, MessageSize); if (FrameData == NULL) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("couldn't get track data: ") << temp; throw ErrorMsg; } const TrackTimeBase *TimeBase = FFMS_GetTimeBase(FrameData, FFMSErrorMessage, MessageSize); if (TimeBase == NULL) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("couldn't get track time base: ") << temp; throw ErrorMsg; } @@ -151,7 +157,8 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) for (int CurFrameNum = 0; CurFrameNum < VideoInfo->NumFrames; CurFrameNum++) { CurFrameData = FFMS_GetFrameInfo(FrameData, CurFrameNum, FFMSErrorMessage, MessageSize); if (CurFrameData == NULL) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("couldn't get framedata for frame ") << CurFrameNum << _T(": ") << temp; throw ErrorMsg; } @@ -245,7 +252,8 @@ const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int _n, int FormatType) // decode frame const AVFrameLite *SrcFrame = FFMS_GetFrame(VideoSource, n, FFMSErrorMessage, MessageSize); if (SrcFrame == NULL) { - ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); + wxString temp(FFMSErrorMessage, wxConvUTF8); + ErrorMsg << _T("failed to retrieve frame: ") << temp; throw ErrorMsg; }