Rename Source/SoundData/Decoder:getChannels to getChannelCount (resolves issue #1307). Deprecate the old methods rather than completely removing them.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-08-27 14:40:46 -03:00
parent 0325663283
commit bf6983beac
32 changed files with 87 additions and 56 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ public:
/**
* @return Number of channels for recording.
**/
virtual int getChannels() const = 0;
virtual int getChannelCount() const = 0;
/**
* @return True if currently recording.
+1 -1
View File
@@ -107,7 +107,7 @@ public:
virtual void setAirAbsorptionFactor(float factor) = 0;
virtual float getAirAbsorptionFactor() const = 0;
virtual int getChannels() const = 0;
virtual int getChannelCount() const = 0;
virtual bool setFilter(const std::map<Filter::Parameter, float> &params) = 0;
virtual bool setFilter() = 0;
+1 -1
View File
@@ -72,7 +72,7 @@ int RecordingDevice::getBitDepth() const
return 0;
}
int RecordingDevice::getChannels() const
int RecordingDevice::getChannelCount() const
{
return 0;
}
+1 -1
View File
@@ -44,7 +44,7 @@ public:
virtual int getSampleCount() const;
virtual int getSampleRate() const;
virtual int getBitDepth() const;
virtual int getChannels() const;
virtual int getChannelCount() const;
virtual bool isRecording() const;
private:
+1 -1
View File
@@ -224,7 +224,7 @@ float Source::getAirAbsorptionFactor() const
return absorptionFactor;
}
int Source::getChannels() const
int Source::getChannelCount() const
{
return 2;
}
+1 -1
View File
@@ -77,7 +77,7 @@ public:
virtual float getMaxDistance() const;
virtual void setAirAbsorptionFactor(float factor);
virtual float getAirAbsorptionFactor() const;
virtual int getChannels() const;
virtual int getChannelCount() const;
virtual int getFreeBufferCount() const;
virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels);
+1 -1
View File
@@ -132,7 +132,7 @@ int RecordingDevice::getBitDepth() const
return bitDepth;
}
int RecordingDevice::getChannels() const
int RecordingDevice::getChannelCount() const
{
return channels;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
virtual int getMaxSamples() const;
virtual int getSampleRate() const;
virtual int getBitDepth() const;
virtual int getChannels() const;
virtual int getChannelCount() const;
virtual bool isRecording() const;
private:
+8 -8
View File
@@ -122,12 +122,12 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
: love::audio::Source(Source::TYPE_STATIC)
, pool(pool)
, sampleRate(soundData->getSampleRate())
, channels(soundData->getChannels())
, channels(soundData->getChannelCount())
, bitDepth(soundData->getBitDepth())
{
ALenum fmt = Audio::getFormat(soundData->getBitDepth(), soundData->getChannels());
ALenum fmt = Audio::getFormat(soundData->getBitDepth(), soundData->getChannelCount());
if (fmt == AL_NONE)
throw InvalidFormatException(soundData->getChannels(), soundData->getBitDepth());
throw InvalidFormatException(soundData->getChannelCount(), soundData->getBitDepth());
staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), (ALsizei) soundData->getSize(), sampleRate), Acquire::NORETAIN);
@@ -145,13 +145,13 @@ Source::Source(Pool *pool, love::sound::Decoder *decoder)
: love::audio::Source(Source::TYPE_STREAM)
, pool(pool)
, sampleRate(decoder->getSampleRate())
, channels(decoder->getChannels())
, channels(decoder->getChannelCount())
, bitDepth(decoder->getBitDepth())
, decoder(decoder)
, buffers(DEFAULT_BUFFERS)
{
if (Audio::getFormat(decoder->getBitDepth(), decoder->getChannels()) == AL_NONE)
throw InvalidFormatException(decoder->getChannels(), decoder->getBitDepth());
if (Audio::getFormat(decoder->getBitDepth(), decoder->getChannelCount()) == AL_NONE)
throw InvalidFormatException(decoder->getChannelCount(), decoder->getBitDepth());
for (int i = 0; i < buffers; i++)
{
@@ -1138,7 +1138,7 @@ int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
// OpenAL implementations are allowed to ignore 0-size alBufferData calls.
if (decoded > 0)
{
int fmt = Audio::getFormat(d->getBitDepth(), d->getChannels());
int fmt = Audio::getFormat(d->getBitDepth(), d->getChannelCount());
if (fmt != AL_NONE)
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
@@ -1318,7 +1318,7 @@ float Source::getAirAbsorptionFactor() const
return absorptionFactor;
}
int Source::getChannels() const
int Source::getChannelCount() const
{
return channels;
}
+1 -1
View File
@@ -142,7 +142,7 @@ public:
virtual float getMaxDistance() const;
virtual void setAirAbsorptionFactor(float factor);
virtual float getAirAbsorptionFactor() const;
virtual int getChannels() const;
virtual int getChannelCount() const;
virtual bool setFilter(const std::map<Filter::Parameter, float> &params);
virtual bool setFilter();
+4 -4
View File
@@ -39,7 +39,7 @@ int w_RecordingDevice_start(lua_State *L)
int samples = d->getMaxSamples();
int samplerate = d->getSampleRate();
int bitdepth = d->getBitDepth();
int channels = d->getChannels();
int channels = d->getChannelCount();
if (lua_gettop(L) > 1)
{
@@ -115,10 +115,10 @@ int w_RecordingDevice_getBitDepth(lua_State *L)
return 1;
}
int w_RecordingDevice_getChannels(lua_State *L)
int w_RecordingDevice_getChannelCount(lua_State *L)
{
RecordingDevice *d = luax_checkrecordingdevice(L, 1);
lua_pushnumber(L, d->getChannels());
lua_pushnumber(L, d->getChannelCount());
return 1;
}
@@ -144,7 +144,7 @@ static const luaL_Reg w_RecordingDevice_functions[] =
{ "getSampleCount", w_RecordingDevice_getSampleCount },
{ "getSampleRate", w_RecordingDevice_getSampleRate },
{ "getBitDepth", w_RecordingDevice_getBitDepth },
{ "getChannels", w_RecordingDevice_getChannels },
{ "getChannelCount", w_RecordingDevice_getChannelCount },
{ "getName", w_RecordingDevice_getName },
{ "isRecording", w_RecordingDevice_isRecording },
{ 0, 0 }
+15 -4
View File
@@ -338,10 +338,10 @@ int w_Source_setAirAbsorption(lua_State *L)
return 0;
}
int w_Source_getChannels(lua_State *L)
int w_Source_getChannelCount(lua_State *L)
{
Source *t = luax_checksource(L, 1);
lua_pushinteger(L, t->getChannels());
lua_pushinteger(L, t->getChannelCount());
return 1;
}
@@ -542,7 +542,7 @@ int w_Source_queue(lua_State *L)
luax_catchexcept(L, [&]() {
success = t->queue((unsigned char *)s->getData() + offset, length,
s->getSampleRate(), s->getBitDepth(), s->getChannels());
s->getSampleRate(), s->getBitDepth(), s->getChannelCount());
});
}
else if (lua_islightuserdata(L, 2))
@@ -580,6 +580,14 @@ int w_Source_getType(lua_State *L)
return 1;
}
// Deprecated
int w_Source_getChannels(lua_State *L)
{
luax_markdeprecated(L, "Source:getChannels", DEPRECATED_RENAMED, "Source:getChannelCount");
return w_Source_getChannelCount(L);
}
static const luaL_Reg w_Source_functions[] =
{
{ "clone", w_Source_clone },
@@ -618,7 +626,7 @@ static const luaL_Reg w_Source_functions[] =
{ "setRolloff", w_Source_setRolloff },
{ "getRolloff", w_Source_getRolloff },
{ "getChannels", w_Source_getChannels },
{ "getChannelCount", w_Source_getChannelCount },
{ "setFilter", w_Source_setFilter },
{ "getFilter", w_Source_getFilter },
@@ -631,6 +639,9 @@ static const luaL_Reg w_Source_functions[] =
{ "getType", w_Source_getType },
// Deprecated
{ "getChannels", w_Source_getChannels },
{ 0, 0 }
};
+1 -1
View File
@@ -123,7 +123,7 @@ public:
* Gets the number of channels in a stream. Supported values are 1 (mono) or 2 (stereo).
* @return Either 1 for mono, 2 for stereo, or 0 on errors.
**/
virtual int getChannels() const = 0;
virtual int getChannelCount() const = 0;
/**
* Gets the number of bits per sample. Supported values are 8 or 16.
+3 -3
View File
@@ -83,7 +83,7 @@ SoundData::SoundData(Decoder *decoder)
if (data && bufferSize > size)
data = (uint8 *) realloc(data, size);
channels = decoder->getChannels();
channels = decoder->getChannelCount();
bitDepth = decoder->getBitDepth();
sampleRate = decoder->getSampleRate();
}
@@ -115,7 +115,7 @@ SoundData::SoundData(const SoundData &c)
, bitDepth(0)
, channels(0)
{
load(c.getSampleCount(), c.getSampleRate(), c.getBitDepth(), c.getChannels(), c.getData());
load(c.getSampleCount(), c.getSampleRate(), c.getBitDepth(), c.getChannelCount(), c.getData());
}
SoundData::~SoundData()
@@ -179,7 +179,7 @@ size_t SoundData::getSize() const
return size;
}
int SoundData::getChannels() const
int SoundData::getChannelCount() const
{
return channels;
}
+1 -1
View File
@@ -49,7 +49,7 @@ public:
void *getData() const;
size_t getSize() const;
virtual int getChannels() const;
virtual int getChannelCount() const;
virtual int getBitDepth() const;
virtual int getSampleRate() const;
virtual int getSampleCount() const;
@@ -258,7 +258,7 @@ bool CoreAudioDecoder::isSeekable()
return true;
}
int CoreAudioDecoder::getChannels() const
int CoreAudioDecoder::getChannelCount() const
{
return outputInfo.mChannelsPerFrame;
}
+1 -1
View File
@@ -57,7 +57,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
double getDuration();
+2 -2
View File
@@ -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 * getBitDepth() * getChannels() * 2;
bufferSize = 256 * getBitDepth() * getChannelCount() * 2;
delete[](char *) buffer;
buffer = new char[bufferSize];
}
@@ -93,7 +93,7 @@ bool FLACDecoder::isSeekable()
return true;
}
int FLACDecoder::getChannels() const
int FLACDecoder::getChannelCount() const
{
return get_channels();
}
+1 -1
View File
@@ -49,7 +49,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
int getSampleRate() const;
double getDuration();
+1 -1
View File
@@ -132,7 +132,7 @@ bool GmeDecoder::isSeekable()
return true;
}
int GmeDecoder::getChannels() const
int GmeDecoder::getChannelCount() const
{
return 2;
}
+1 -1
View File
@@ -54,7 +54,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
double getDuration();
+1 -1
View File
@@ -132,7 +132,7 @@ bool ModPlugDecoder::isSeekable()
return true;
}
int ModPlugDecoder::getChannels() const
int ModPlugDecoder::getChannelCount() const
{
return 2;
}
+1 -1
View File
@@ -57,7 +57,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
double getDuration();
+1 -1
View File
@@ -257,7 +257,7 @@ bool Mpg123Decoder::isSeekable()
return true;
}
int Mpg123Decoder::getChannels() const
int Mpg123Decoder::getChannelCount() const
{
return channels;
}
+1 -1
View File
@@ -69,7 +69,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
double getDuration();
+1 -1
View File
@@ -250,7 +250,7 @@ bool VorbisDecoder::isSeekable()
return (result != 0);
}
int VorbisDecoder::getChannels() const
int VorbisDecoder::getChannelCount() const
{
return vorbisInfo->channels;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
int getSampleRate() const;
double getDuration();
+1 -1
View File
@@ -174,7 +174,7 @@ bool WaveDecoder::isSeekable()
return true;
}
int WaveDecoder::getChannels() const
int WaveDecoder::getChannelCount() const
{
return info.channels;
}
+1 -1
View File
@@ -56,7 +56,7 @@ public:
bool seek(float s);
bool rewind();
bool isSeekable();
int getChannels() const;
int getChannelCount() const;
int getBitDepth() const;
int getSampleRate() const;
double getDuration();
+15 -5
View File
@@ -34,10 +34,10 @@ Decoder *luax_checkdecoder(lua_State *L, int idx)
return luax_checktype<Decoder>(L, idx);
}
int w_Decoder_getChannels(lua_State *L)
int w_Decoder_getChannelCount(lua_State *L)
{
Decoder *t = luax_checkdecoder(L, 1);
lua_pushinteger(L, t->getChannels());
lua_pushinteger(L, t->getChannelCount());
return 1;
}
@@ -71,8 +71,8 @@ int w_Decoder_decode(lua_State *L)
{
luax_catchexcept(L, [&]() {
SoundData *s = instance()->newSoundData(t->getBuffer(),
decoded / (t->getBitDepth() / 8 * t->getChannels()),
t->getSampleRate(), t->getBitDepth(), t->getChannels());
decoded / (t->getBitDepth() / 8 * t->getChannelCount()),
t->getSampleRate(), t->getBitDepth(), t->getChannelCount());
luax_pushtype(L, s);
s->release();
@@ -96,14 +96,24 @@ int w_Decoder_seek(lua_State *L)
return 0;
}
int w_Decoder_getChannels(lua_State *L)
{
luax_markdeprecated(L, "Decoder:getChannels", DEPRECATED_RENAMED, "Decoder:getChannelCount");
return w_Decoder_getChannelCount(L);
}
static const luaL_Reg w_Decoder_functions[] =
{
{ "getChannels", w_Decoder_getChannels },
{ "getChannelCount", w_Decoder_getChannelCount },
{ "getBitDepth", w_Decoder_getBitDepth },
{ "getSampleRate", w_Decoder_getSampleRate },
{ "getDuration", w_Decoder_getDuration },
{ "decode", w_Decoder_decode },
{ "seek", w_Decoder_seek },
// Deprecated
{ "getChannels", w_Decoder_getChannels },
{ 0, 0 }
};
+13 -3
View File
@@ -51,10 +51,10 @@ int w_SoundData_clone(lua_State *L)
return 1;
}
int w_SoundData_getChannels(lua_State *L)
int w_SoundData_getChannelCount(lua_State *L)
{
SoundData *t = luax_checksounddata(L, 1);
lua_pushinteger(L, t->getChannels());
lua_pushinteger(L, t->getChannelCount());
return 1;
}
@@ -105,16 +105,26 @@ int w_SoundData_getSample(lua_State *L)
return 1;
}
int w_SoundData_getChannels(lua_State *L)
{
luax_markdeprecated(L, "SoundData:getChannels", DEPRECATED_RENAMED, "SoundData:getChannelCount");
return w_SoundData_getChannelCount(L);
}
static const luaL_Reg w_SoundData_functions[] =
{
{ "clone", w_SoundData_clone },
{ "getChannels", w_SoundData_getChannels },
{ "getChannelCount", w_SoundData_getChannelCount },
{ "getBitDepth", w_SoundData_getBitDepth },
{ "getSampleRate", w_SoundData_getSampleRate },
{ "getSampleCount", w_SoundData_getSampleCount },
{ "getDuration", w_SoundData_getDuration },
{ "setSample", w_SoundData_setSample },
{ "getSample", w_SoundData_getSample },
// Deprecated
{ "getChannels", w_SoundData_getChannels },
{ 0, 0 }
};
+3 -3
View File
@@ -45,7 +45,7 @@ local typemaxvals = {0x7F, 0x7FFF}
local _getBitDepth = SoundData.getBitDepth
local _getSampleCount = SoundData.getSampleCount
local _getSampleRate = SoundData.getSampleRate
local _getChannels = SoundData.getChannels
local _getChannelCount = SoundData.getChannelCount
local _getDuration = SoundData.getDuration
local _release = SoundData.release
@@ -64,7 +64,7 @@ local objectcache = setmetatable({}, {
maxvalue = typemaxvals[bytedepth],
samplecount = _getSampleCount(sounddata),
samplerate = _getSampleRate(sounddata),
channels = _getChannels(sounddata),
channels = _getChannelCount(sounddata),
duration = _getDuration(sounddata),
}
@@ -131,7 +131,7 @@ function SoundData:getSampleRate()
return objectcache[self].samplerate
end
function SoundData:getChannels()
function SoundData:getChannelCount()
return objectcache[self].channels
end