Moved the base Decoder implementation out of the lullaby subfolder.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-23 21:32:20 -03:00
parent 0341fc1189
commit ddc4b06eba
12 changed files with 41 additions and 106 deletions
+1 -2
View File
@@ -818,6 +818,7 @@ source_group("modules\\physics\\box2d" FILES ${LOVE_SRC_MODULE_PHYSICS_BOX2D})
#
set(LOVE_SRC_MODULE_SOUND_ROOT
src/modules/sound/Decoder.cpp
src/modules/sound/Decoder.h
src/modules/sound/Sound.cpp
src/modules/sound/Sound.h
@@ -832,8 +833,6 @@ set(LOVE_SRC_MODULE_SOUND_ROOT
)
set(LOVE_SRC_MODULE_SOUND_LULLABY
src/modules/sound/lullaby/Decoder.cpp
src/modules/sound/lullaby/Decoder.h
src/modules/sound/lullaby/FLACDecoder.cpp
src/modules/sound/lullaby/FLACDecoder.h
src/modules/sound/lullaby/GmeDecoder.cpp
@@ -719,7 +719,6 @@
FA0B7E871A95902C000E1D17 /* CoreAudioDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C7F1A95902C000E1D17 /* CoreAudioDecoder.h */; };
FA0B7E881A95902C000E1D17 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C801A95902C000E1D17 /* Decoder.cpp */; };
FA0B7E891A95902C000E1D17 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C801A95902C000E1D17 /* Decoder.cpp */; };
FA0B7E8A1A95902C000E1D17 /* Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C811A95902C000E1D17 /* Decoder.h */; };
FA0B7E8B1A95902C000E1D17 /* FLACDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C821A95902C000E1D17 /* FLACDecoder.cpp */; };
FA0B7E8C1A95902C000E1D17 /* FLACDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7C821A95902C000E1D17 /* FLACDecoder.cpp */; };
FA0B7E8D1A95902C000E1D17 /* FLACDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7C831A95902C000E1D17 /* FLACDecoder.h */; };
@@ -1441,7 +1440,6 @@
FA0B7C7E1A95902C000E1D17 /* CoreAudioDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreAudioDecoder.cpp; sourceTree = "<group>"; };
FA0B7C7F1A95902C000E1D17 /* CoreAudioDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreAudioDecoder.h; sourceTree = "<group>"; };
FA0B7C801A95902C000E1D17 /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = "<group>"; };
FA0B7C811A95902C000E1D17 /* Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decoder.h; sourceTree = "<group>"; };
FA0B7C821A95902C000E1D17 /* FLACDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FLACDecoder.cpp; sourceTree = "<group>"; };
FA0B7C831A95902C000E1D17 /* FLACDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLACDecoder.h; sourceTree = "<group>"; };
FA0B7C841A95902C000E1D17 /* GmeDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GmeDecoder.cpp; sourceTree = "<group>"; };
@@ -2630,6 +2628,7 @@
FA0B7C7B1A95902C000E1D17 /* sound */ = {
isa = PBXGroup;
children = (
FA0B7C801A95902C000E1D17 /* Decoder.cpp */,
FA0B7C7C1A95902C000E1D17 /* Decoder.h */,
FA0B7C7D1A95902C000E1D17 /* lullaby */,
FA0B7C901A95902C000E1D17 /* Sound.cpp */,
@@ -2652,8 +2651,6 @@
children = (
FA0B7C7E1A95902C000E1D17 /* CoreAudioDecoder.cpp */,
FA0B7C7F1A95902C000E1D17 /* CoreAudioDecoder.h */,
FA0B7C801A95902C000E1D17 /* Decoder.cpp */,
FA0B7C811A95902C000E1D17 /* Decoder.h */,
FA0B7C821A95902C000E1D17 /* FLACDecoder.cpp */,
FA0B7C831A95902C000E1D17 /* FLACDecoder.h */,
FA0B7C841A95902C000E1D17 /* GmeDecoder.cpp */,
@@ -3200,7 +3197,6 @@
FA0B7DEA1A95902C000E1D17 /* Mouse.h in Headers */,
FA0B7E931A95902C000E1D17 /* ModPlugDecoder.h in Headers */,
FA0B7D111A95902C000E1D17 /* BMFontRasterizer.h in Headers */,
FA0B7E8A1A95902C000E1D17 /* Decoder.h in Headers */,
FA0B7E3E1A95902C000E1D17 /* wrap_Body.h in Headers */,
FA0B7A571A958EA3000E1D17 /* b2Settings.h in Headers */,
FA0B7B321A958EA3000E1D17 /* wuff.h in Headers */,
@@ -26,8 +26,6 @@ namespace love
{
namespace sound
{
namespace lullaby
{
Decoder::Decoder(Data *data, const std::string &ext, int bufferSize)
: data(data)
@@ -66,7 +64,5 @@ bool Decoder::isFinished()
return eof;
}
} // lullaby
} // sound
} // love
+32 -9
View File
@@ -23,6 +23,9 @@
// LOVE
#include "common/Object.h"
#include "filesystem/File.h"
#include <string>
namespace love
{
@@ -36,6 +39,9 @@ class Decoder : public Object
{
public:
Decoder(Data *data, const std::string &ext, int bufferSize);
virtual ~Decoder();
/**
* Indicates how many bytes of raw data should be generated at each
* call to Decode.
@@ -64,11 +70,6 @@ public:
**/
virtual Decoder *clone() = 0;
/**
* Destructor. Should free internal buffer.
**/
virtual ~Decoder() {}
/**
* Decodes the next chunk of the music stream, this will usually be
* bufferSize amount of bytes, unless EOF occurs. Zero or negative values
@@ -81,14 +82,14 @@ public:
* Gets the size of the buffer (NOT the size of the entire stream).
* @return The size of the buffer.
**/
virtual int getSize() const = 0;
virtual int getSize() const;
/**
* Gets a pointer to the actual data. The contents of this buffer will
* change with each call to decode, so the client must copy the data.
* @return A buffer to raw sound data.
**/
virtual void *getBuffer() const = 0;
virtual void *getBuffer() const;
/**
* Seeks to the specified position, if possible.
@@ -114,7 +115,7 @@ public:
* rewind to start the stream again.
* @return False if there is more data, true on EOF.
**/
virtual bool isFinished() = 0;
virtual bool isFinished();
/**
* Gets the number of channels in a stream. Supported values are 1 (mono) or 2 (stereo).
@@ -132,7 +133,7 @@ public:
* Gets the sample rate for the Decoder, that is, samples per second.
* @return The sample rate, eg. 44100.
**/
virtual int getSampleRate() const = 0;
virtual int getSampleRate() const;
/**
* Gets the estimated total duration of the stream. in seconds. May return
@@ -140,6 +141,28 @@ public:
**/
virtual double getDuration() = 0;
protected:
// The encoded data. This should be replaced with buffered file
// reads in the future.
StrongRef<Data> data;
// File extension.
std::string ext;
// When the decoder decodes data incrementally, it writes
// this many bytes at a time (at most).
int bufferSize;
// The desired frequency of the samples. 44100, 22050, or 11025.
int sampleRate;
// Holds internal memory.
void *buffer;
// Set this to true when eof has been reached.
bool eof;
}; // Decoder
} // sound
+1 -1
View File
@@ -27,7 +27,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
// Core Audio
#include <AudioToolbox/AudioFormat.h>
-79
View File
@@ -1,79 +0,0 @@
/**
* Copyright (c) 2006-2016 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_LULLABY_DECODER_H
#define LOVE_SOUND_LULLABY_DECODER_H
// LOVE
#include "sound/Decoder.h"
#include "filesystem/File.h"
#include <string>
namespace love
{
namespace sound
{
namespace lullaby
{
class Decoder : public love::sound::Decoder
{
public:
Decoder(Data *data, const std::string &ext, int bufferSize);
virtual ~Decoder();
// Implement some of love::sound::Decoder, but allow subclasses
// to override them.
virtual void *getBuffer() const;
virtual int getSize() const;
virtual int getSampleRate() const;
virtual bool isFinished();
protected:
// The encoded data. This should be replaced with buffered file
// reads in the future.
StrongRef<Data> data;
// File extension.
std::string ext;
// When the decoder decodes data incrementally, it writes
// this many bytes at a time (at most).
int bufferSize;
// The desired frequency of the samples. 44100, 22050, or 11025.
int sampleRate;
// Holds internal memory.
void *buffer;
// Set this to true when eof has been reached.
bool eof;
}; // Decoder
} // lullaby
} // sound
} // love
#endif // LOVE_SOUND_LULLABY_DECODER_H
+1 -1
View File
@@ -25,7 +25,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
#include <FLAC++/decoder.h>
#include <string.h>
+1 -1
View File
@@ -25,7 +25,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
#ifdef LOVE_APPLE_USE_FRAMEWORKS
#include <Game_Music_Emu/gme.h>
+1 -1
View File
@@ -27,7 +27,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
// libmodplug
#if defined(LOVE_ANDROID) || defined(LOVE_IOS)
+1 -1
View File
@@ -23,7 +23,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
#ifndef LOVE_NOMPG123
+1 -1
View File
@@ -24,7 +24,7 @@
// LOVE
#include "common/Data.h"
#include "common/int.h"
#include "Decoder.h"
#include "sound/Decoder.h"
// vorbis
#define OV_EXCLUDE_STATIC_CALLBACKS
+1 -1
View File
@@ -23,7 +23,7 @@
// LOVE
#include "common/Data.h"
#include "Decoder.h"
#include "sound/Decoder.h"
#include "libraries/Wuff/wuff.h"