From 66a773d2a7a57525b6b7c155466ec4331ab28652 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 11 Aug 2013 04:15:42 -0300 Subject: [PATCH] Renamed Decoder:getBits to Decoder:getBitDepth (see issue #636) --- src/modules/audio/openal/Source.cpp | 12 +++---- src/modules/audio/openal/Source.h | 4 +-- src/modules/sound/Decoder.h | 4 +-- src/modules/sound/Sound.cpp | 4 +-- src/modules/sound/Sound.h | 4 +-- src/modules/sound/SoundData.cpp | 34 ++++++++++---------- src/modules/sound/SoundData.h | 6 ++-- src/modules/sound/lullaby/FLACDecoder.cpp | 4 +-- src/modules/sound/lullaby/FLACDecoder.h | 2 +- src/modules/sound/lullaby/GmeDecoder.cpp | 2 +- src/modules/sound/lullaby/GmeDecoder.h | 2 +- src/modules/sound/lullaby/ModPlugDecoder.cpp | 2 +- src/modules/sound/lullaby/ModPlugDecoder.h | 2 +- src/modules/sound/lullaby/Mpg123Decoder.cpp | 2 +- src/modules/sound/lullaby/Mpg123Decoder.h | 2 +- src/modules/sound/lullaby/VorbisDecoder.cpp | 4 +-- src/modules/sound/lullaby/VorbisDecoder.h | 2 +- src/modules/sound/wrap_Decoder.cpp | 6 ++-- src/modules/sound/wrap_Decoder.h | 2 +- src/modules/sound/wrap_Sound.cpp | 4 +-- 20 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index 92a3e39ed..061b2ffd2 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -544,15 +544,15 @@ void Source::setFloatv(float *dst, const float *src) const dst[2] = src[2]; } -ALenum Source::getFormat(int channels, int bits) const +ALenum Source::getFormat(int channels, int bitDepth) const { - if (channels == 1 && bits == 8) + if (channels == 1 && bitDepth == 8) return AL_FORMAT_MONO8; - else if (channels == 1 && bits == 16) + else if (channels == 1 && bitDepth == 16) return AL_FORMAT_MONO16; - else if (channels == 2 && bits == 8) + else if (channels == 2 && bitDepth == 8) return AL_FORMAT_STEREO8; - else if (channels == 2 && bits == 16) + else if (channels == 2 && bitDepth == 16) return AL_FORMAT_STEREO16; else return 0; @@ -563,7 +563,7 @@ int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d) // Get more sound data. int decoded = d->decode(); - int fmt = getFormat(d->getChannels(), d->getBits()); + int fmt = getFormat(d->getChannels(), d->getBitDepth()); if (fmt != 0) alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate()); diff --git a/src/modules/audio/openal/Source.h b/src/modules/audio/openal/Source.h index 5f06ce03f..5e502ac3b 100644 --- a/src/modules/audio/openal/Source.h +++ b/src/modules/audio/openal/Source.h @@ -108,10 +108,10 @@ private: * Gets the OpenAL format identifier based on number of * channels and bits. * @param channels Either 1 (mono) or 2 (stereo). - * @param bits Either 8-bit samples, or 16-bit samples. + * @param bitDepth Either 8-bit samples, or 16-bit samples. * @return One of AL_FORMAT_*, or 0 if unsupported format. **/ - ALenum getFormat(int channels, int bits) const; + ALenum getFormat(int channels, int bitDepth) const; int streamAtomic(ALuint buffer, love::sound::Decoder *d); diff --git a/src/modules/sound/Decoder.h b/src/modules/sound/Decoder.h index 1b17fc556..2690874c1 100644 --- a/src/modules/sound/Decoder.h +++ b/src/modules/sound/Decoder.h @@ -55,7 +55,7 @@ public: /** * 16 bit audio is the default. **/ - static const int DEFAULT_BITS = 16; + static const int DEFAULT_BIT_DEPTH = 16; /** * Creates a deep of itself. The sound stream can (and should) be @@ -126,7 +126,7 @@ public: * Gets the number of bits per sample. Supported values are 8 or 16. * @return Either 8, 16, or 0 if unsupported. **/ - virtual int getBits() const = 0; + virtual int getBitDepth() const = 0; /** * Gets the sample rate for the Decoder, that is, samples per second. diff --git a/src/modules/sound/Sound.cpp b/src/modules/sound/Sound.cpp index 7249a5d4e..47290df70 100644 --- a/src/modules/sound/Sound.cpp +++ b/src/modules/sound/Sound.cpp @@ -34,9 +34,9 @@ SoundData *Sound::newSoundData(Decoder *decoder) return new SoundData(decoder); } -SoundData *Sound::newSoundData(int samples, int sampleRate, int bits, int channels) +SoundData *Sound::newSoundData(int samples, int sampleRate, int bitDepth, int channels) { - return new SoundData(samples, sampleRate, bits, channels); + return new SoundData(samples, sampleRate, bitDepth, channels); } diff --git a/src/modules/sound/Sound.h b/src/modules/sound/Sound.h index e1e296ada..6f2d04883 100644 --- a/src/modules/sound/Sound.h +++ b/src/modules/sound/Sound.h @@ -60,11 +60,11 @@ public: * Creates a new SoundData with the specified number of samples and format. * @param duration In seconds. * @param sampleRate Number of samples per second. - * @param bits Bits per sample (8 or 16). + * @param bitDepth Bits per sample (8 or 16). * @param channels Either 1 for mono, or 2 for stereo. * @return A new SoundData object, or zero in case of errors. **/ - SoundData *newSoundData(int samples, int sampleRate, int bits, int channels); + SoundData *newSoundData(int samples, int sampleRate, int bitDepth, int channels); /** * Attempts to find a decoder for the encoded sound data in the diff --git a/src/modules/sound/SoundData.cpp b/src/modules/sound/SoundData.cpp index b9d3dbef9..065a0a0d5 100644 --- a/src/modules/sound/SoundData.cpp +++ b/src/modules/sound/SoundData.cpp @@ -38,7 +38,7 @@ SoundData::SoundData(Decoder *decoder) : data(0) , size(0) , sampleRate(Decoder::DEFAULT_SAMPLE_RATE) - , bits(0) + , bitDepth(0) , channels(0) { size_t bufferSize = 524288; @@ -79,19 +79,19 @@ SoundData::SoundData(Decoder *decoder) data = (char *) realloc(data, size); channels = decoder->getChannels(); - bits = decoder->getBits(); + bitDepth = decoder->getBitDepth(); sampleRate = decoder->getSampleRate(); } -SoundData::SoundData(int samples, int sampleRate, int bits, int channels) +SoundData::SoundData(int samples, int sampleRate, int bitDepth, int channels) : data(0) - , size(samples*(bits/8)*channels) + , size(samples*(bitDepth/8)*channels) , sampleRate(sampleRate) - , bits(bits) + , bitDepth(bitDepth) , channels(channels) { double realsize = samples; - realsize *= (bits/8)*channels; + realsize *= (bitDepth/8)*channels; if (realsize > INT_MAX) throw love::Exception("Data is too big!"); data = (char *)malloc(size); @@ -99,15 +99,15 @@ SoundData::SoundData(int samples, int sampleRate, int bits, int channels) throw love::Exception("Not enough memory."); } -SoundData::SoundData(void *d, int samples, int sampleRate, int bits, int channels) +SoundData::SoundData(void *d, int samples, int sampleRate, int bitDepth, int channels) : data(0) - , size(samples*(bits/8)*channels) + , size(samples*(bitDepth/8)*channels) , sampleRate(sampleRate) - , bits(bits) + , bitDepth(bitDepth) , channels(channels) { double realsize = samples; - realsize *= (bits/8)*channels; + realsize *= (bitDepth/8)*channels; if (realsize > INT_MAX) throw love::Exception("Data is too big!"); data = (char *)malloc(size); @@ -139,7 +139,7 @@ int SoundData::getChannels() const int SoundData::getBitDepth() const { - return bits; + return bitDepth; } int SoundData::getSampleRate() const @@ -149,21 +149,21 @@ int SoundData::getSampleRate() const int SoundData::getSampleCount() const { - return (size/channels)/(bits/8); + return (size/channels)/(bitDepth/8); } float SoundData::getDuration() const { - return float(size) / (channels*sampleRate*bits/8); + return float(size) / (channels*sampleRate*bitDepth/8); } void SoundData::setSample(int i, float sample) { // Check range. - if (i < 0 || i >= size/(bits/8)) + if (i < 0 || i >= size/(bitDepth/8)) throw love::Exception("Attempt to set out-of-range sample!"); - if (bits == 16) + if (bitDepth == 16) { short *s = (short *)data; s[i] = (short)(sample*(float)SHRT_MAX); @@ -179,10 +179,10 @@ void SoundData::setSample(int i, float sample) float SoundData::getSample(int i) const { // Check range. - if (i < 0 || i >= size/(bits/8)) + if (i < 0 || i >= size/(bitDepth/8)) throw love::Exception("Attempt to get out-of-range sample!"); - if (bits == 16) + if (bitDepth == 16) { short *s = (short *)data; return (float)s[i]/(float)SHRT_MAX; diff --git a/src/modules/sound/SoundData.h b/src/modules/sound/SoundData.h index ffcaf92ce..278e069bb 100644 --- a/src/modules/sound/SoundData.h +++ b/src/modules/sound/SoundData.h @@ -36,8 +36,8 @@ class SoundData : public love::Data public: SoundData(Decoder *decoder); - SoundData(int samples, int sampleRate, int bits, int channels); - SoundData(void *d, int samples, int sampleRate, int bits, int channels); + SoundData(int samples, int sampleRate, int bitDepth, int channels); + SoundData(void *d, int samples, int sampleRate, int bitDepth, int channels); virtual ~SoundData(); @@ -61,7 +61,7 @@ private: int size; int sampleRate; - int bits; + int bitDepth; int channels; }; // SoundData diff --git a/src/modules/sound/lullaby/FLACDecoder.cpp b/src/modules/sound/lullaby/FLACDecoder.cpp index 431685b75..955000fe0 100644 --- a/src/modules/sound/lullaby/FLACDecoder.cpp +++ b/src/modules/sound/lullaby/FLACDecoder.cpp @@ -41,7 +41,7 @@ FLACDecoder::FLACDecoder(Data *data, const std::string &ext, int nbufferSize) process_until_end_of_metadata(); process_single(); seek(0); - bufferSize = 256 * getBits() * getChannels() * 2; + bufferSize = 256 * getBitDepth() * getChannels() * 2; delete[](char *) buffer; buffer = new char[bufferSize]; } @@ -98,7 +98,7 @@ int FLACDecoder::getChannels() const return get_channels(); } -int FLACDecoder::getBits() const +int FLACDecoder::getBitDepth() const { return get_bits_per_sample(); } diff --git a/src/modules/sound/lullaby/FLACDecoder.h b/src/modules/sound/lullaby/FLACDecoder.h index d0379830d..58a3af100 100644 --- a/src/modules/sound/lullaby/FLACDecoder.h +++ b/src/modules/sound/lullaby/FLACDecoder.h @@ -50,7 +50,7 @@ public: bool rewind(); bool isSeekable(); int getChannels() const; - int getBits() const; + int getBitDepth() const; int getSampleRate() const; //needed for FLAC diff --git a/src/modules/sound/lullaby/GmeDecoder.cpp b/src/modules/sound/lullaby/GmeDecoder.cpp index 137000890..f07864879 100644 --- a/src/modules/sound/lullaby/GmeDecoder.cpp +++ b/src/modules/sound/lullaby/GmeDecoder.cpp @@ -137,7 +137,7 @@ int GmeDecoder::getChannels() const return 2; } -int GmeDecoder::getBits() const +int GmeDecoder::getBitDepth() const { return 16; } diff --git a/src/modules/sound/lullaby/GmeDecoder.h b/src/modules/sound/lullaby/GmeDecoder.h index 05a274ddd..57dbbdaac 100644 --- a/src/modules/sound/lullaby/GmeDecoder.h +++ b/src/modules/sound/lullaby/GmeDecoder.h @@ -55,7 +55,7 @@ public: bool rewind(); bool isSeekable(); int getChannels() const; - int getBits() const; + int getBitDepth() const; private: Music_Emu *emu; diff --git a/src/modules/sound/lullaby/ModPlugDecoder.cpp b/src/modules/sound/lullaby/ModPlugDecoder.cpp index 67525e01f..ab16cbf56 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.cpp +++ b/src/modules/sound/lullaby/ModPlugDecoder.cpp @@ -137,7 +137,7 @@ int ModPlugDecoder::getChannels() const return 2; } -int ModPlugDecoder::getBits() const +int ModPlugDecoder::getBitDepth() const { return 16; } diff --git a/src/modules/sound/lullaby/ModPlugDecoder.h b/src/modules/sound/lullaby/ModPlugDecoder.h index 01e4405f1..30c9685ed 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.h +++ b/src/modules/sound/lullaby/ModPlugDecoder.h @@ -50,7 +50,7 @@ public: bool rewind(); bool isSeekable(); int getChannels() const; - int getBits() const; + int getBitDepth() const; private: diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index 987f86168..dd1142e68 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/src/modules/sound/lullaby/Mpg123Decoder.cpp @@ -207,7 +207,7 @@ int Mpg123Decoder::getChannels() const return channels; } -int Mpg123Decoder::getBits() const +int Mpg123Decoder::getBitDepth() const { return 16; } diff --git a/src/modules/sound/lullaby/Mpg123Decoder.h b/src/modules/sound/lullaby/Mpg123Decoder.h index d73e3a5d0..61d571e21 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.h +++ b/src/modules/sound/lullaby/Mpg123Decoder.h @@ -55,7 +55,7 @@ public: bool rewind(); bool isSeekable(); int getChannels() const; - int getBits() const; + int getBitDepth() const; private: diff --git a/src/modules/sound/lullaby/VorbisDecoder.cpp b/src/modules/sound/lullaby/VorbisDecoder.cpp index 1165eba46..81fe85d19 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.cpp +++ b/src/modules/sound/lullaby/VorbisDecoder.cpp @@ -188,7 +188,7 @@ int VorbisDecoder::decode() while (size < bufferSize) { - int result = ov_read(&handle, (char *) buffer + size, bufferSize - size, endian, (getBits() == 16 ? 2 : 1), 1, 0); + int result = ov_read(&handle, (char *) buffer + size, bufferSize - size, endian, (getBitDepth() == 16 ? 2 : 1), 1, 0); if (result == OV_HOLE) continue; @@ -243,7 +243,7 @@ int VorbisDecoder::getChannels() const return vorbisInfo->channels; } -int VorbisDecoder::getBits() const +int VorbisDecoder::getBitDepth() const { return 16; } diff --git a/src/modules/sound/lullaby/VorbisDecoder.h b/src/modules/sound/lullaby/VorbisDecoder.h index d744a8431..f60bbd956 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.h +++ b/src/modules/sound/lullaby/VorbisDecoder.h @@ -59,7 +59,7 @@ public: bool rewind(); bool isSeekable(); int getChannels() const; - int getBits() const; + int getBitDepth() const; int getSampleRate() const; private: diff --git a/src/modules/sound/wrap_Decoder.cpp b/src/modules/sound/wrap_Decoder.cpp index c6045d85e..96af1820a 100644 --- a/src/modules/sound/wrap_Decoder.cpp +++ b/src/modules/sound/wrap_Decoder.cpp @@ -37,10 +37,10 @@ int w_Decoder_getChannels(lua_State *L) return 1; } -int w_Decoder_getBits(lua_State *L) +int w_Decoder_getBitDepth(lua_State *L) { Decoder *t = luax_checkdecoder(L, 1); - lua_pushinteger(L, t->getBits()); + lua_pushinteger(L, t->getBitDepth()); return 1; } @@ -54,7 +54,7 @@ int w_Decoder_getSampleRate(lua_State *L) static const luaL_Reg functions[] = { { "getChannels", w_Decoder_getChannels }, - { "getBits", w_Decoder_getBits }, + { "getBitDepth", w_Decoder_getBitDepth }, { "getSampleRate", w_Decoder_getSampleRate }, { 0, 0 } }; diff --git a/src/modules/sound/wrap_Decoder.h b/src/modules/sound/wrap_Decoder.h index 9f25bde8c..7edadf939 100644 --- a/src/modules/sound/wrap_Decoder.h +++ b/src/modules/sound/wrap_Decoder.h @@ -32,7 +32,7 @@ namespace sound Decoder *luax_checkdecoder(lua_State *L, int idx); int w_Decoder_getChannels(lua_State *L); -int w_Decoder_getBits(lua_State *L); +int w_Decoder_getBitDepth(lua_State *L); int w_Decoder_getSampleRate(lua_State *L); extern "C" int luaopen_decoder(lua_State *L); diff --git a/src/modules/sound/wrap_Sound.cpp b/src/modules/sound/wrap_Sound.cpp index 67424194e..0ef52e425 100644 --- a/src/modules/sound/wrap_Sound.cpp +++ b/src/modules/sound/wrap_Sound.cpp @@ -38,12 +38,12 @@ int w_newSoundData(lua_State *L) { int samples = luaL_checkint(L, 1); int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE); - int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS); + int bitDepth = luaL_optint(L, 3, Decoder::DEFAULT_BIT_DEPTH); int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS); try { - t = instance->newSoundData(samples, sampleRate, bits, channels); + t = instance->newSoundData(samples, sampleRate, bitDepth, channels); } catch(love::Exception &e) {