From 200fab03efaa2cbe1b8fce4a742b0195f8912295 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Wed, 18 Aug 2010 12:59:21 +0200 Subject: [PATCH] Improved WAV error checking --- sound/filters/openal_various.hpp | 5 ++--- sound/sources/mpg123_source.cpp | 5 ----- sound/sources/wav_source.cpp | 5 ++++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/filters/openal_various.hpp b/sound/filters/openal_various.hpp index 87030f4b6..945b3dabd 100644 --- a/sound/filters/openal_various.hpp +++ b/sound/filters/openal_various.hpp @@ -17,9 +17,8 @@ namespace Sound { MP3: mpg123 WAV: custom wav loader (PCM only) - This could be an alternative to using eg. libsndfile or other 3rd - party decoder libraries. (We implemented this for OpenMW because - we were experiencing crashes when using libsndfile.) + This could be an alternative to using eg. 3rd party decoder + libraries like libsndfile. */ class OpenAL_Various_Factory : public InputFilter { diff --git a/sound/sources/mpg123_source.cpp b/sound/sources/mpg123_source.cpp index 8a0dbd102..b0eeb77bb 100644 --- a/sound/sources/mpg123_source.cpp +++ b/sound/sources/mpg123_source.cpp @@ -106,11 +106,6 @@ Mpg123Source::Mpg123Source(const std::string &file) // This is the only bit size we support. bits = 16; - - // Ensure the output format does not change. (The tutorial on the - // mpg123 site did this, I assume it's kosher.) - mpg123_format_none(mhh); - mpg123_format(mhh,rate,channels,encoding); } Mpg123Source::~Mpg123Source() diff --git a/sound/sources/wav_source.cpp b/sound/sources/wav_source.cpp index 5ee87d492..8e3e8558c 100644 --- a/sound/sources/wav_source.cpp +++ b/sound/sources/wav_source.cpp @@ -30,7 +30,10 @@ size_t WavSource::read(void *data, size_t length) { if(length > left) length = left; - input->read(data, length); + size_t read = input->read(data, length); + if(read < length) + // Something went wrong + fail("WAV read error"); return length; }