Move audio decode error handling to GetAudio

Errors when not getting with volume need to be handled too.

Updates #1509.
This commit is contained in:
Thomas Goyne 2012-09-01 21:43:06 -07:00
parent e995cd2616
commit 1c9af767e5

View file

@ -61,21 +61,7 @@
#include <libaegisub/log.h> #include <libaegisub/log.h>
void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) const { void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) const {
try { GetAudio(buf,start,count);
GetAudio(buf,start,count);
}
catch (AudioDecodeError const& e) {
LOG_E("audio_provider") << e.GetChainedMessage();
memset(buf, 0, count*bytes_per_sample);
return;
}
catch (...) {
// FIXME: Poor error handling though better than none, to patch issue #800.
// Just return blank audio if real provider fails.
LOG_E("audio_provider") << "Unknown audio decoding error";
memset(buf, 0, count*bytes_per_sample);
return;
}
if (volume == 1.0) return; if (volume == 1.0) return;
@ -128,8 +114,23 @@ void AudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const {
memset(zero_buf, 0, zero_count * bytes_per_sample * channels); memset(zero_buf, 0, zero_count * bytes_per_sample * channels);
} }
if (count > 0) if (count > 0) {
FillBuffer(buf, start, count); try {
FillBuffer(buf, start, count);
}
catch (AudioDecodeError const& e) {
LOG_E("audio_provider") << e.GetChainedMessage();
memset(buf, 0, count*bytes_per_sample);
return;
}
catch (...) {
// FIXME: Poor error handling though better than none, to patch issue #800.
// Just return blank audio if real provider fails.
LOG_E("audio_provider") << "Unknown audio decoding error";
memset(buf, 0, count*bytes_per_sample);
return;
}
}
} }
AudioProvider *AudioProviderFactory::GetProvider(wxString const& filename, int cache) { AudioProvider *AudioProviderFactory::GetProvider(wxString const& filename, int cache) {