From caf5d71d44b8bb0382842b56b65148cde4baa8d1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 Mar 2012 03:18:28 -0700 Subject: [PATCH] Make the sound decoder's Open method return void Errors are thrown, not returned --- apps/openmw/mwsound/ffmpeg_decoder.cpp | 3 +-- apps/openmw/mwsound/ffmpeg_decoder.hpp | 2 +- apps/openmw/mwsound/mpgsnd_decoder.cpp | 7 +++---- apps/openmw/mwsound/mpgsnd_decoder.hpp | 2 +- apps/openmw/mwsound/openal_output.cpp | 3 +-- apps/openmw/mwsound/sound_decoder.hpp | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index d3715d5fe9..5c64e4dd10 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -9,10 +9,9 @@ namespace MWSound static void fail(const std::string &msg) { throw std::runtime_error("FFmpeg exception: "+msg); } -bool FFmpeg_Decoder::Open(const std::string &fname) +void FFmpeg_Decoder::Open(const std::string &fname) { fail("Not currently working"); - return false; } void FFmpeg_Decoder::Close() diff --git a/apps/openmw/mwsound/ffmpeg_decoder.hpp b/apps/openmw/mwsound/ffmpeg_decoder.hpp index 6ff93904af..205fe8865b 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.hpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.hpp @@ -16,7 +16,7 @@ namespace MWSound { class FFmpeg_Decoder : public Sound_Decoder { - virtual bool Open(const std::string &fname); + virtual void Open(const std::string &fname); virtual void Close(); virtual void GetInfo(int *samplerate, ChannelConfig *chans, SampleType *type); diff --git a/apps/openmw/mwsound/mpgsnd_decoder.cpp b/apps/openmw/mwsound/mpgsnd_decoder.cpp index 4ba48f607a..2c35adeb33 100644 --- a/apps/openmw/mwsound/mpgsnd_decoder.cpp +++ b/apps/openmw/mwsound/mpgsnd_decoder.cpp @@ -12,7 +12,7 @@ static void fail(const std::string &msg) namespace MWSound { -bool MpgSnd_Decoder::Open(const std::string &fname) +void MpgSnd_Decoder::Open(const std::string &fname) { Close(); @@ -31,7 +31,7 @@ bool MpgSnd_Decoder::Open(const std::string &fname) fail("Unsupported channel count in "+fname); } sampleRate = info.samplerate; - return true; + return; } mpgFile = mpg123_new(NULL, NULL); @@ -49,7 +49,7 @@ bool MpgSnd_Decoder::Open(const std::string &fname) fail("Unsupported channel count in "+fname); chanConfig = ((channels==2)?StereoChannels:MonoChannels); sampleRate = rate; - return true; + return; } catch(std::exception &e) { @@ -64,7 +64,6 @@ bool MpgSnd_Decoder::Open(const std::string &fname) mpgFile = NULL; fail("Unsupported file type: "+fname); - return false; } void MpgSnd_Decoder::Close() diff --git a/apps/openmw/mwsound/mpgsnd_decoder.hpp b/apps/openmw/mwsound/mpgsnd_decoder.hpp index 641d891a3e..391cfbd6d3 100644 --- a/apps/openmw/mwsound/mpgsnd_decoder.hpp +++ b/apps/openmw/mwsound/mpgsnd_decoder.hpp @@ -19,7 +19,7 @@ namespace MWSound ChannelConfig chanConfig; int sampleRate; - virtual bool Open(const std::string &fname); + virtual void Open(const std::string &fname); virtual void Close(); virtual void GetInfo(int *samplerate, ChannelConfig *chans, SampleType *type); diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 766fa018a0..7668dcac29 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -236,8 +236,7 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr sound; - if(!decoder->Open(fname)) - return NULL; + decoder->Open(fname); sound.reset(new OpenAL_SoundStream(decoder)); sound->Play(); diff --git a/apps/openmw/mwsound/sound_decoder.hpp b/apps/openmw/mwsound/sound_decoder.hpp index fd8f4ac515..4f778c3b31 100644 --- a/apps/openmw/mwsound/sound_decoder.hpp +++ b/apps/openmw/mwsound/sound_decoder.hpp @@ -14,7 +14,7 @@ namespace MWSound MonoChannels, StereoChannels }; - virtual bool Open(const std::string &fname) = 0; + virtual void Open(const std::string &fname) = 0; virtual void Close() = 0; virtual void GetInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;