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
@@ -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