From 4479e8dfc48fbc8a9a8d558e694b6e781ae54bf6 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Sat, 15 Jan 2011 14:29:10 -0600 Subject: [PATCH] removed user-specified sample rates for Decoders --- src/modules/sound/Sound.h | 38 ++++++++++---------- src/modules/sound/lullaby/Decoder.cpp | 4 +-- src/modules/sound/lullaby/Decoder.h | 2 +- src/modules/sound/lullaby/FLACDecoder.cpp | 4 +-- src/modules/sound/lullaby/FLACDecoder.h | 2 +- src/modules/sound/lullaby/ModPlugDecoder.cpp | 6 ++-- src/modules/sound/lullaby/ModPlugDecoder.h | 2 +- src/modules/sound/lullaby/Mpg123Decoder.cpp | 6 ++-- src/modules/sound/lullaby/Mpg123Decoder.h | 2 +- src/modules/sound/lullaby/Sound.cpp | 10 +++--- src/modules/sound/lullaby/Sound.h | 38 ++++++++++---------- src/modules/sound/lullaby/VorbisDecoder.cpp | 6 ++-- src/modules/sound/lullaby/VorbisDecoder.h | 2 +- src/modules/sound/wrap_Sound.cpp | 17 +++++---- 14 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/modules/sound/Sound.h b/src/modules/sound/Sound.h index 8f1ff3139..9df8689dc 100644 --- a/src/modules/sound/Sound.h +++ b/src/modules/sound/Sound.h @@ -1,21 +1,21 @@ -/** -* Copyright (c) 2006-2010 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. +/** +* Copyright (c) 2006-2010 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. **/ #ifndef LOVE_SOUND_SOUND_H @@ -74,7 +74,7 @@ namespace sound * @param sampleRate Samples per second, or quality of the audio. 44100 is a good value. * @return A Decoder object on success, or zero if no decoder could be found. **/ - virtual Decoder * newDecoder(filesystem::File * file, int bufferSize, int sampleRate) = 0; + virtual Decoder * newDecoder(filesystem::File * file, int bufferSize) = 0; }; // Sound diff --git a/src/modules/sound/lullaby/Decoder.cpp b/src/modules/sound/lullaby/Decoder.cpp index 48c93e4f0..250cb4373 100644 --- a/src/modules/sound/lullaby/Decoder.cpp +++ b/src/modules/sound/lullaby/Decoder.cpp @@ -28,8 +28,8 @@ namespace sound { namespace lullaby { - Decoder::Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate) - :data(data), ext(ext), bufferSize(bufferSize), sampleRate(sampleRate), buffer(0), eof(false) + Decoder::Decoder(Data * data, const std::string & ext, int bufferSize) + :data(data), ext(ext), bufferSize(bufferSize), sampleRate(DEFAULT_SAMPLE_RATE), buffer(0), eof(false) { data->retain(); buffer = new char[bufferSize]; diff --git a/src/modules/sound/lullaby/Decoder.h b/src/modules/sound/lullaby/Decoder.h index e083ff51f..106e6b564 100644 --- a/src/modules/sound/lullaby/Decoder.h +++ b/src/modules/sound/lullaby/Decoder.h @@ -59,7 +59,7 @@ namespace lullaby public: - Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate); + Decoder(Data * data, const std::string & ext, int bufferSize); virtual ~Decoder(); diff --git a/src/modules/sound/lullaby/FLACDecoder.cpp b/src/modules/sound/lullaby/FLACDecoder.cpp index 1b460e04a..bd67d7fc1 100644 --- a/src/modules/sound/lullaby/FLACDecoder.cpp +++ b/src/modules/sound/lullaby/FLACDecoder.cpp @@ -31,8 +31,8 @@ namespace sound { namespace lullaby { - FLACDecoder::FLACDecoder(Data * data, const std::string & ext, int nbufferSize, int sampleRate) - : Decoder(data, ext, nbufferSize, sampleRate), pos(0) + FLACDecoder::FLACDecoder(Data * data, const std::string & ext, int nbufferSize) + : Decoder(data, ext, nbufferSize), pos(0) { init(); init_ogg(); diff --git a/src/modules/sound/lullaby/FLACDecoder.h b/src/modules/sound/lullaby/FLACDecoder.h index 9b5dcda95..83f645c96 100644 --- a/src/modules/sound/lullaby/FLACDecoder.h +++ b/src/modules/sound/lullaby/FLACDecoder.h @@ -42,7 +42,7 @@ namespace lullaby int pos; public: - FLACDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate); + FLACDecoder(Data * data, const std::string & ext, int bufferSize); ~FLACDecoder(); static bool accepts(const std::string &ext); diff --git a/src/modules/sound/lullaby/ModPlugDecoder.cpp b/src/modules/sound/lullaby/ModPlugDecoder.cpp index 66b4e77e5..1dd19af16 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.cpp +++ b/src/modules/sound/lullaby/ModPlugDecoder.cpp @@ -28,8 +28,8 @@ namespace sound { namespace lullaby { - ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate) - : Decoder(data, ext, bufferSize, sampleRate), plug(0) + ModPlugDecoder::ModPlugDecoder(Data * data, const std::string & ext, int bufferSize) + : Decoder(data, ext, bufferSize), plug(0) { // Set some ModPlug settings. @@ -77,7 +77,7 @@ namespace lullaby love::sound::Decoder * ModPlugDecoder::clone() { - return new ModPlugDecoder(data, ext, bufferSize, settings.mFrequency); + return new ModPlugDecoder(data, ext, bufferSize); } int ModPlugDecoder::decode() diff --git a/src/modules/sound/lullaby/ModPlugDecoder.h b/src/modules/sound/lullaby/ModPlugDecoder.h index 9b1f947b7..f561cfb92 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.h +++ b/src/modules/sound/lullaby/ModPlugDecoder.h @@ -43,7 +43,7 @@ namespace lullaby public: - ModPlugDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate); + ModPlugDecoder(Data * data, const std::string & ext, int bufferSize); virtual ~ModPlugDecoder(); static bool accepts(const std::string & ext); diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index a7e526169..342bb77f5 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/src/modules/sound/lullaby/Mpg123Decoder.cpp @@ -33,8 +33,8 @@ namespace lullaby bool Mpg123Decoder::inited = false; - Mpg123Decoder::Mpg123Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate) - : Decoder(data, ext, bufferSize, sampleRate), handle(0), channels(MPG123_STEREO) + Mpg123Decoder::Mpg123Decoder(Data * data, const std::string & ext, int bufferSize) + : Decoder(data, ext, bufferSize), handle(0), channels(MPG123_STEREO) { data_size = data->getSize(); @@ -93,7 +93,7 @@ namespace lullaby love::sound::Decoder * Mpg123Decoder::clone() { - return new Mpg123Decoder(data, ext, bufferSize, sampleRate); + return new Mpg123Decoder(data, ext, bufferSize); } int Mpg123Decoder::decode() diff --git a/src/modules/sound/lullaby/Mpg123Decoder.h b/src/modules/sound/lullaby/Mpg123Decoder.h index 10ad109d9..45981ad25 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.h +++ b/src/modules/sound/lullaby/Mpg123Decoder.h @@ -52,7 +52,7 @@ namespace lullaby public: - Mpg123Decoder(Data * data, const std::string & ext, int bufferSize, int sampleRate); + Mpg123Decoder(Data * data, const std::string & ext, int bufferSize); virtual ~Mpg123Decoder(); static bool accepts(const std::string & ext); diff --git a/src/modules/sound/lullaby/Sound.cpp b/src/modules/sound/lullaby/Sound.cpp index 42aac0cb9..5e9d9c2d7 100644 --- a/src/modules/sound/lullaby/Sound.cpp +++ b/src/modules/sound/lullaby/Sound.cpp @@ -45,7 +45,7 @@ namespace lullaby return "love.sound.lullaby"; } - sound::Decoder * Sound::newDecoder(love::filesystem::File * file, int bufferSize, int sampleRate) + sound::Decoder * Sound::newDecoder(love::filesystem::File * file, int bufferSize) { Data * data = file->read(); std::string ext = file->getExtension(); @@ -54,13 +54,13 @@ namespace lullaby // Find a suitable decoder here, and return it. if(ModPlugDecoder::accepts(ext)) - decoder = new ModPlugDecoder(data, ext, bufferSize, sampleRate); + decoder = new ModPlugDecoder(data, ext, bufferSize); else if(Mpg123Decoder::accepts(ext)) - decoder = new Mpg123Decoder(data, ext, bufferSize, sampleRate); + decoder = new Mpg123Decoder(data, ext, bufferSize); else if(VorbisDecoder::accepts(ext)) - decoder = new VorbisDecoder(data, ext, bufferSize, sampleRate); + decoder = new VorbisDecoder(data, ext, bufferSize); /*else if (FLACDecoder::accepts(ext)) - decoder = new FLACDecoder(data, ext, bufferSize, sampleRate);*/ + decoder = new FLACDecoder(data, ext, bufferSize);*/ // else if(OtherDecoder::accept(ext)) diff --git a/src/modules/sound/lullaby/Sound.h b/src/modules/sound/lullaby/Sound.h index 9819a1225..4d8cbad91 100644 --- a/src/modules/sound/lullaby/Sound.h +++ b/src/modules/sound/lullaby/Sound.h @@ -1,21 +1,21 @@ -/** -* Copyright (c) 2006-2010 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. +/** +* Copyright (c) 2006-2010 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. **/ @@ -58,7 +58,7 @@ namespace lullaby const char * getName() const; /// @copydoc love::sound::Sound::newDecoder - sound::Decoder * newDecoder(love::filesystem::File * file, int bufferSize, int sampleRate); + sound::Decoder * newDecoder(love::filesystem::File * file, int bufferSize); }; // Sound diff --git a/src/modules/sound/lullaby/VorbisDecoder.cpp b/src/modules/sound/lullaby/VorbisDecoder.cpp index a5e0991f7..932bb39fa 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.cpp +++ b/src/modules/sound/lullaby/VorbisDecoder.cpp @@ -125,8 +125,8 @@ namespace lullaby * END CALLBACK FUNCTIONS **/ - VorbisDecoder::VorbisDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate) - : Decoder(data, ext, bufferSize, sampleRate) + VorbisDecoder::VorbisDecoder(Data * data, const std::string & ext, int bufferSize) + : Decoder(data, ext, bufferSize) { // Initialize callbacks vorbisCallbacks.close_func = vorbisClose; @@ -177,7 +177,7 @@ namespace lullaby love::sound::Decoder * VorbisDecoder::clone() { - return new VorbisDecoder(data, ext, bufferSize, sampleRate); + return new VorbisDecoder(data, ext, bufferSize); } int VorbisDecoder::decode() diff --git a/src/modules/sound/lullaby/VorbisDecoder.h b/src/modules/sound/lullaby/VorbisDecoder.h index f72f2c486..9208b66f3 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.h +++ b/src/modules/sound/lullaby/VorbisDecoder.h @@ -55,7 +55,7 @@ namespace lullaby public: - VorbisDecoder(Data * data, const std::string & ext, int bufferSize, int sampleRate); + VorbisDecoder(Data * data, const std::string & ext, int bufferSize); virtual ~VorbisDecoder(); static bool accepts(const std::string & ext); diff --git a/src/modules/sound/wrap_Sound.cpp b/src/modules/sound/wrap_Sound.cpp index fd8be44c8..9a8229792 100644 --- a/src/modules/sound/wrap_Sound.cpp +++ b/src/modules/sound/wrap_Sound.cpp @@ -84,11 +84,10 @@ namespace sound love::filesystem::File * file = luax_checktype(L, 1, "File", FILESYSTEM_FILE_T); int bufferSize = luaL_optint(L, 2, Decoder::DEFAULT_BUFFER_SIZE); - int sampleRate = luaL_optint(L, 3, Decoder::DEFAULT_SAMPLE_RATE); try { - Decoder * t = instance->newDecoder(file, bufferSize, sampleRate); + Decoder * t = instance->newDecoder(file, bufferSize); if(t == 0) return luaL_error(L, "Extension \"%s\" not supported.", file->getExtension().c_str()); luax_newtype(L, "Decoder", SOUND_DECODER_T, (void*)t); @@ -131,13 +130,13 @@ namespace sound instance->retain(); - WrappedModule w; - w.module = instance; - w.name = "sound"; - w.flags = MODULE_SOUND_T; - w.functions = functions; - w.types = types; - + WrappedModule w; + w.module = instance; + w.name = "sound"; + w.flags = MODULE_SOUND_T; + w.functions = functions; + w.types = types; + return luax_register_module(L, w); }