mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
removed user-specified sample rates for Decoders
This commit is contained in:
+19
-19
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -84,11 +84,10 @@ namespace sound
|
||||
|
||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user