mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
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:
@@ -94,7 +94,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @return Number of channels for recording.
|
* @return Number of channels for recording.
|
||||||
**/
|
**/
|
||||||
virtual int getChannels() const = 0;
|
virtual int getChannelCount() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if currently recording.
|
* @return True if currently recording.
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
virtual void setAirAbsorptionFactor(float factor) = 0;
|
virtual void setAirAbsorptionFactor(float factor) = 0;
|
||||||
virtual float getAirAbsorptionFactor() const = 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> ¶ms) = 0;
|
virtual bool setFilter(const std::map<Filter::Parameter, float> ¶ms) = 0;
|
||||||
virtual bool setFilter() = 0;
|
virtual bool setFilter() = 0;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ int RecordingDevice::getBitDepth() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RecordingDevice::getChannels() const
|
int RecordingDevice::getChannelCount() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual int getSampleCount() const;
|
virtual int getSampleCount() const;
|
||||||
virtual int getSampleRate() const;
|
virtual int getSampleRate() const;
|
||||||
virtual int getBitDepth() const;
|
virtual int getBitDepth() const;
|
||||||
virtual int getChannels() const;
|
virtual int getChannelCount() const;
|
||||||
virtual bool isRecording() const;
|
virtual bool isRecording() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ float Source::getAirAbsorptionFactor() const
|
|||||||
return absorptionFactor;
|
return absorptionFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Source::getChannels() const
|
int Source::getChannelCount() const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
virtual float getMaxDistance() const;
|
virtual float getMaxDistance() const;
|
||||||
virtual void setAirAbsorptionFactor(float factor);
|
virtual void setAirAbsorptionFactor(float factor);
|
||||||
virtual float getAirAbsorptionFactor() const;
|
virtual float getAirAbsorptionFactor() const;
|
||||||
virtual int getChannels() const;
|
virtual int getChannelCount() const;
|
||||||
|
|
||||||
virtual int getFreeBufferCount() const;
|
virtual int getFreeBufferCount() const;
|
||||||
virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels);
|
virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ int RecordingDevice::getBitDepth() const
|
|||||||
return bitDepth;
|
return bitDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RecordingDevice::getChannels() const
|
int RecordingDevice::getChannelCount() const
|
||||||
{
|
{
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
virtual int getMaxSamples() const;
|
virtual int getMaxSamples() const;
|
||||||
virtual int getSampleRate() const;
|
virtual int getSampleRate() const;
|
||||||
virtual int getBitDepth() const;
|
virtual int getBitDepth() const;
|
||||||
virtual int getChannels() const;
|
virtual int getChannelCount() const;
|
||||||
virtual bool isRecording() const;
|
virtual bool isRecording() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -122,12 +122,12 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
|||||||
: love::audio::Source(Source::TYPE_STATIC)
|
: love::audio::Source(Source::TYPE_STATIC)
|
||||||
, pool(pool)
|
, pool(pool)
|
||||||
, sampleRate(soundData->getSampleRate())
|
, sampleRate(soundData->getSampleRate())
|
||||||
, channels(soundData->getChannels())
|
, channels(soundData->getChannelCount())
|
||||||
, bitDepth(soundData->getBitDepth())
|
, bitDepth(soundData->getBitDepth())
|
||||||
{
|
{
|
||||||
ALenum fmt = Audio::getFormat(soundData->getBitDepth(), soundData->getChannels());
|
ALenum fmt = Audio::getFormat(soundData->getBitDepth(), soundData->getChannelCount());
|
||||||
if (fmt == AL_NONE)
|
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);
|
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)
|
: love::audio::Source(Source::TYPE_STREAM)
|
||||||
, pool(pool)
|
, pool(pool)
|
||||||
, sampleRate(decoder->getSampleRate())
|
, sampleRate(decoder->getSampleRate())
|
||||||
, channels(decoder->getChannels())
|
, channels(decoder->getChannelCount())
|
||||||
, bitDepth(decoder->getBitDepth())
|
, bitDepth(decoder->getBitDepth())
|
||||||
, decoder(decoder)
|
, decoder(decoder)
|
||||||
, buffers(DEFAULT_BUFFERS)
|
, buffers(DEFAULT_BUFFERS)
|
||||||
{
|
{
|
||||||
if (Audio::getFormat(decoder->getBitDepth(), decoder->getChannels()) == AL_NONE)
|
if (Audio::getFormat(decoder->getBitDepth(), decoder->getChannelCount()) == AL_NONE)
|
||||||
throw InvalidFormatException(decoder->getChannels(), decoder->getBitDepth());
|
throw InvalidFormatException(decoder->getChannelCount(), decoder->getBitDepth());
|
||||||
|
|
||||||
for (int i = 0; i < buffers; i++)
|
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.
|
// OpenAL implementations are allowed to ignore 0-size alBufferData calls.
|
||||||
if (decoded > 0)
|
if (decoded > 0)
|
||||||
{
|
{
|
||||||
int fmt = Audio::getFormat(d->getBitDepth(), d->getChannels());
|
int fmt = Audio::getFormat(d->getBitDepth(), d->getChannelCount());
|
||||||
|
|
||||||
if (fmt != AL_NONE)
|
if (fmt != AL_NONE)
|
||||||
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
||||||
@@ -1318,7 +1318,7 @@ float Source::getAirAbsorptionFactor() const
|
|||||||
return absorptionFactor;
|
return absorptionFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Source::getChannels() const
|
int Source::getChannelCount() const
|
||||||
{
|
{
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
virtual float getMaxDistance() const;
|
virtual float getMaxDistance() const;
|
||||||
virtual void setAirAbsorptionFactor(float factor);
|
virtual void setAirAbsorptionFactor(float factor);
|
||||||
virtual float getAirAbsorptionFactor() const;
|
virtual float getAirAbsorptionFactor() const;
|
||||||
virtual int getChannels() const;
|
virtual int getChannelCount() const;
|
||||||
|
|
||||||
virtual bool setFilter(const std::map<Filter::Parameter, float> ¶ms);
|
virtual bool setFilter(const std::map<Filter::Parameter, float> ¶ms);
|
||||||
virtual bool setFilter();
|
virtual bool setFilter();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ int w_RecordingDevice_start(lua_State *L)
|
|||||||
int samples = d->getMaxSamples();
|
int samples = d->getMaxSamples();
|
||||||
int samplerate = d->getSampleRate();
|
int samplerate = d->getSampleRate();
|
||||||
int bitdepth = d->getBitDepth();
|
int bitdepth = d->getBitDepth();
|
||||||
int channels = d->getChannels();
|
int channels = d->getChannelCount();
|
||||||
|
|
||||||
if (lua_gettop(L) > 1)
|
if (lua_gettop(L) > 1)
|
||||||
{
|
{
|
||||||
@@ -115,10 +115,10 @@ int w_RecordingDevice_getBitDepth(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_RecordingDevice_getChannels(lua_State *L)
|
int w_RecordingDevice_getChannelCount(lua_State *L)
|
||||||
{
|
{
|
||||||
RecordingDevice *d = luax_checkrecordingdevice(L, 1);
|
RecordingDevice *d = luax_checkrecordingdevice(L, 1);
|
||||||
lua_pushnumber(L, d->getChannels());
|
lua_pushnumber(L, d->getChannelCount());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ static const luaL_Reg w_RecordingDevice_functions[] =
|
|||||||
{ "getSampleCount", w_RecordingDevice_getSampleCount },
|
{ "getSampleCount", w_RecordingDevice_getSampleCount },
|
||||||
{ "getSampleRate", w_RecordingDevice_getSampleRate },
|
{ "getSampleRate", w_RecordingDevice_getSampleRate },
|
||||||
{ "getBitDepth", w_RecordingDevice_getBitDepth },
|
{ "getBitDepth", w_RecordingDevice_getBitDepth },
|
||||||
{ "getChannels", w_RecordingDevice_getChannels },
|
{ "getChannelCount", w_RecordingDevice_getChannelCount },
|
||||||
{ "getName", w_RecordingDevice_getName },
|
{ "getName", w_RecordingDevice_getName },
|
||||||
{ "isRecording", w_RecordingDevice_isRecording },
|
{ "isRecording", w_RecordingDevice_isRecording },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
|
|||||||
@@ -338,10 +338,10 @@ int w_Source_setAirAbsorption(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Source_getChannels(lua_State *L)
|
int w_Source_getChannelCount(lua_State *L)
|
||||||
{
|
{
|
||||||
Source *t = luax_checksource(L, 1);
|
Source *t = luax_checksource(L, 1);
|
||||||
lua_pushinteger(L, t->getChannels());
|
lua_pushinteger(L, t->getChannelCount());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +542,7 @@ int w_Source_queue(lua_State *L)
|
|||||||
|
|
||||||
luax_catchexcept(L, [&]() {
|
luax_catchexcept(L, [&]() {
|
||||||
success = t->queue((unsigned char *)s->getData() + offset, length,
|
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))
|
else if (lua_islightuserdata(L, 2))
|
||||||
@@ -580,6 +580,14 @@ int w_Source_getType(lua_State *L)
|
|||||||
return 1;
|
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[] =
|
static const luaL_Reg w_Source_functions[] =
|
||||||
{
|
{
|
||||||
{ "clone", w_Source_clone },
|
{ "clone", w_Source_clone },
|
||||||
@@ -618,7 +626,7 @@ static const luaL_Reg w_Source_functions[] =
|
|||||||
{ "setRolloff", w_Source_setRolloff },
|
{ "setRolloff", w_Source_setRolloff },
|
||||||
{ "getRolloff", w_Source_getRolloff },
|
{ "getRolloff", w_Source_getRolloff },
|
||||||
|
|
||||||
{ "getChannels", w_Source_getChannels },
|
{ "getChannelCount", w_Source_getChannelCount },
|
||||||
|
|
||||||
{ "setFilter", w_Source_setFilter },
|
{ "setFilter", w_Source_setFilter },
|
||||||
{ "getFilter", w_Source_getFilter },
|
{ "getFilter", w_Source_getFilter },
|
||||||
@@ -631,6 +639,9 @@ static const luaL_Reg w_Source_functions[] =
|
|||||||
|
|
||||||
{ "getType", w_Source_getType },
|
{ "getType", w_Source_getType },
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
|
{ "getChannels", w_Source_getChannels },
|
||||||
|
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public:
|
|||||||
* Gets the number of channels in a stream. Supported values are 1 (mono) or 2 (stereo).
|
* 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.
|
* @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.
|
* Gets the number of bits per sample. Supported values are 8 or 16.
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ SoundData::SoundData(Decoder *decoder)
|
|||||||
if (data && bufferSize > size)
|
if (data && bufferSize > size)
|
||||||
data = (uint8 *) realloc(data, size);
|
data = (uint8 *) realloc(data, size);
|
||||||
|
|
||||||
channels = decoder->getChannels();
|
channels = decoder->getChannelCount();
|
||||||
bitDepth = decoder->getBitDepth();
|
bitDepth = decoder->getBitDepth();
|
||||||
sampleRate = decoder->getSampleRate();
|
sampleRate = decoder->getSampleRate();
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ SoundData::SoundData(const SoundData &c)
|
|||||||
, bitDepth(0)
|
, bitDepth(0)
|
||||||
, channels(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()
|
SoundData::~SoundData()
|
||||||
@@ -179,7 +179,7 @@ size_t SoundData::getSize() const
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SoundData::getChannels() const
|
int SoundData::getChannelCount() const
|
||||||
{
|
{
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
void *getData() const;
|
void *getData() const;
|
||||||
size_t getSize() const;
|
size_t getSize() const;
|
||||||
|
|
||||||
virtual int getChannels() const;
|
virtual int getChannelCount() const;
|
||||||
virtual int getBitDepth() const;
|
virtual int getBitDepth() const;
|
||||||
virtual int getSampleRate() const;
|
virtual int getSampleRate() const;
|
||||||
virtual int getSampleCount() const;
|
virtual int getSampleCount() const;
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ bool CoreAudioDecoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CoreAudioDecoder::getChannels() const
|
int CoreAudioDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return outputInfo.mChannelsPerFrame;
|
return outputInfo.mChannelsPerFrame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ FLACDecoder::FLACDecoder(Data *data, const std::string &ext, int nbufferSize)
|
|||||||
process_until_end_of_metadata();
|
process_until_end_of_metadata();
|
||||||
process_single();
|
process_single();
|
||||||
seek(0);
|
seek(0);
|
||||||
bufferSize = 256 * getBitDepth() * getChannels() * 2;
|
bufferSize = 256 * getBitDepth() * getChannelCount() * 2;
|
||||||
delete[](char *) buffer;
|
delete[](char *) buffer;
|
||||||
buffer = new char[bufferSize];
|
buffer = new char[bufferSize];
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ bool FLACDecoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLACDecoder::getChannels() const
|
int FLACDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return get_channels();
|
return get_channels();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
int getSampleRate() const;
|
int getSampleRate() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ bool GmeDecoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GmeDecoder::getChannels() const
|
int GmeDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ bool ModPlugDecoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModPlugDecoder::getChannels() const
|
int ModPlugDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ bool Mpg123Decoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Mpg123Decoder::getChannels() const
|
int Mpg123Decoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ bool VorbisDecoder::isSeekable()
|
|||||||
return (result != 0);
|
return (result != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VorbisDecoder::getChannels() const
|
int VorbisDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return vorbisInfo->channels;
|
return vorbisInfo->channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
int getSampleRate() const;
|
int getSampleRate() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ bool WaveDecoder::isSeekable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WaveDecoder::getChannels() const
|
int WaveDecoder::getChannelCount() const
|
||||||
{
|
{
|
||||||
return info.channels;
|
return info.channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
bool seek(float s);
|
bool seek(float s);
|
||||||
bool rewind();
|
bool rewind();
|
||||||
bool isSeekable();
|
bool isSeekable();
|
||||||
int getChannels() const;
|
int getChannelCount() const;
|
||||||
int getBitDepth() const;
|
int getBitDepth() const;
|
||||||
int getSampleRate() const;
|
int getSampleRate() const;
|
||||||
double getDuration();
|
double getDuration();
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ Decoder *luax_checkdecoder(lua_State *L, int idx)
|
|||||||
return luax_checktype<Decoder>(L, 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);
|
Decoder *t = luax_checkdecoder(L, 1);
|
||||||
lua_pushinteger(L, t->getChannels());
|
lua_pushinteger(L, t->getChannelCount());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ int w_Decoder_decode(lua_State *L)
|
|||||||
{
|
{
|
||||||
luax_catchexcept(L, [&]() {
|
luax_catchexcept(L, [&]() {
|
||||||
SoundData *s = instance()->newSoundData(t->getBuffer(),
|
SoundData *s = instance()->newSoundData(t->getBuffer(),
|
||||||
decoded / (t->getBitDepth() / 8 * t->getChannels()),
|
decoded / (t->getBitDepth() / 8 * t->getChannelCount()),
|
||||||
t->getSampleRate(), t->getBitDepth(), t->getChannels());
|
t->getSampleRate(), t->getBitDepth(), t->getChannelCount());
|
||||||
|
|
||||||
luax_pushtype(L, s);
|
luax_pushtype(L, s);
|
||||||
s->release();
|
s->release();
|
||||||
@@ -96,14 +96,24 @@ int w_Decoder_seek(lua_State *L)
|
|||||||
return 0;
|
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[] =
|
static const luaL_Reg w_Decoder_functions[] =
|
||||||
{
|
{
|
||||||
{ "getChannels", w_Decoder_getChannels },
|
{ "getChannelCount", w_Decoder_getChannelCount },
|
||||||
{ "getBitDepth", w_Decoder_getBitDepth },
|
{ "getBitDepth", w_Decoder_getBitDepth },
|
||||||
{ "getSampleRate", w_Decoder_getSampleRate },
|
{ "getSampleRate", w_Decoder_getSampleRate },
|
||||||
{ "getDuration", w_Decoder_getDuration },
|
{ "getDuration", w_Decoder_getDuration },
|
||||||
{ "decode", w_Decoder_decode },
|
{ "decode", w_Decoder_decode },
|
||||||
{ "seek", w_Decoder_seek },
|
{ "seek", w_Decoder_seek },
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
|
{ "getChannels", w_Decoder_getChannels },
|
||||||
|
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ int w_SoundData_clone(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_SoundData_getChannels(lua_State *L)
|
int w_SoundData_getChannelCount(lua_State *L)
|
||||||
{
|
{
|
||||||
SoundData *t = luax_checksounddata(L, 1);
|
SoundData *t = luax_checksounddata(L, 1);
|
||||||
lua_pushinteger(L, t->getChannels());
|
lua_pushinteger(L, t->getChannelCount());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,16 +105,26 @@ int w_SoundData_getSample(lua_State *L)
|
|||||||
return 1;
|
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[] =
|
static const luaL_Reg w_SoundData_functions[] =
|
||||||
{
|
{
|
||||||
{ "clone", w_SoundData_clone },
|
{ "clone", w_SoundData_clone },
|
||||||
{ "getChannels", w_SoundData_getChannels },
|
{ "getChannelCount", w_SoundData_getChannelCount },
|
||||||
{ "getBitDepth", w_SoundData_getBitDepth },
|
{ "getBitDepth", w_SoundData_getBitDepth },
|
||||||
{ "getSampleRate", w_SoundData_getSampleRate },
|
{ "getSampleRate", w_SoundData_getSampleRate },
|
||||||
{ "getSampleCount", w_SoundData_getSampleCount },
|
{ "getSampleCount", w_SoundData_getSampleCount },
|
||||||
{ "getDuration", w_SoundData_getDuration },
|
{ "getDuration", w_SoundData_getDuration },
|
||||||
{ "setSample", w_SoundData_setSample },
|
{ "setSample", w_SoundData_setSample },
|
||||||
{ "getSample", w_SoundData_getSample },
|
{ "getSample", w_SoundData_getSample },
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
|
{ "getChannels", w_SoundData_getChannels },
|
||||||
|
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ local typemaxvals = {0x7F, 0x7FFF}
|
|||||||
local _getBitDepth = SoundData.getBitDepth
|
local _getBitDepth = SoundData.getBitDepth
|
||||||
local _getSampleCount = SoundData.getSampleCount
|
local _getSampleCount = SoundData.getSampleCount
|
||||||
local _getSampleRate = SoundData.getSampleRate
|
local _getSampleRate = SoundData.getSampleRate
|
||||||
local _getChannels = SoundData.getChannels
|
local _getChannelCount = SoundData.getChannelCount
|
||||||
local _getDuration = SoundData.getDuration
|
local _getDuration = SoundData.getDuration
|
||||||
local _release = SoundData.release
|
local _release = SoundData.release
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ local objectcache = setmetatable({}, {
|
|||||||
maxvalue = typemaxvals[bytedepth],
|
maxvalue = typemaxvals[bytedepth],
|
||||||
samplecount = _getSampleCount(sounddata),
|
samplecount = _getSampleCount(sounddata),
|
||||||
samplerate = _getSampleRate(sounddata),
|
samplerate = _getSampleRate(sounddata),
|
||||||
channels = _getChannels(sounddata),
|
channels = _getChannelCount(sounddata),
|
||||||
duration = _getDuration(sounddata),
|
duration = _getDuration(sounddata),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ function SoundData:getSampleRate()
|
|||||||
return objectcache[self].samplerate
|
return objectcache[self].samplerate
|
||||||
end
|
end
|
||||||
|
|
||||||
function SoundData:getChannels()
|
function SoundData:getChannelCount()
|
||||||
return objectcache[self].channels
|
return objectcache[self].channels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user