mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-13 13:50:59 +00:00
Add a SoundDecoder base class and a stub method to create one
This commit is contained in:
parent
b94a2949e5
commit
5370a1cb46
3 changed files with 64 additions and 0 deletions
|
@ -520,3 +520,26 @@ SoundHandle SoundRenderer::LoadSoundVoc(BYTE *sfxdata, int length)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SoundDecoder *SoundRenderer::CreateDecoder(BYTE *sfxdata, int length)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Default readAll implementation, for decoders that can't do anything better
|
||||||
|
std::vector<char> SoundDecoder::readAll()
|
||||||
|
{
|
||||||
|
std::vector<char> output;
|
||||||
|
size_t total = 0;
|
||||||
|
size_t got;
|
||||||
|
|
||||||
|
output.resize(total+32768);
|
||||||
|
while((got=read(&output[total], output.size()-total)) > 0)
|
||||||
|
{
|
||||||
|
total += got;
|
||||||
|
output.resize(total*2);
|
||||||
|
}
|
||||||
|
output.resize(total);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
|
|
||||||
typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata);
|
typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata);
|
||||||
|
|
||||||
|
struct SoundDecoder;
|
||||||
|
|
||||||
class SoundRenderer
|
class SoundRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -150,6 +152,9 @@ public:
|
||||||
virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
|
virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
|
||||||
|
|
||||||
virtual void DrawWaveDebug(int mode);
|
virtual void DrawWaveDebug(int mode);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual SoundDecoder *CreateDecoder(BYTE *sfxdata, int length);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SoundRenderer *GSnd;
|
extern SoundRenderer *GSnd;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef __SNDINT_H
|
#ifndef __SNDINT_H
|
||||||
#define __SNDINT_H
|
#define __SNDINT_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "basictypes.h"
|
#include "basictypes.h"
|
||||||
|
|
||||||
// For convenience, this structure matches FMOD_REVERB_PROPERTIES.
|
// For convenience, this structure matches FMOD_REVERB_PROPERTIES.
|
||||||
|
@ -101,5 +103,39 @@ struct FISoundChannel
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum SampleType
|
||||||
|
{
|
||||||
|
SampleType_UInt8,
|
||||||
|
SampleType_Int16,
|
||||||
|
SampleType_Float32
|
||||||
|
};
|
||||||
|
enum ChannelConfig
|
||||||
|
{
|
||||||
|
ChannelConfig_Mono,
|
||||||
|
ChannelConfig_Stereo,
|
||||||
|
ChannelConfig_Quad,
|
||||||
|
ChannelConfig_5point1,
|
||||||
|
ChannelConfig_7point1
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SoundDecoder
|
||||||
|
{
|
||||||
|
virtual bool open(const char *data, size_t length) = 0;
|
||||||
|
|
||||||
|
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
|
||||||
|
|
||||||
|
virtual size_t read(char *buffer, size_t bytes) = 0;
|
||||||
|
virtual std::vector<char> readAll();
|
||||||
|
virtual bool seek(size_t ms_offset) = 0;
|
||||||
|
virtual size_t getSampleOffset() = 0;
|
||||||
|
|
||||||
|
SoundDecoder() { }
|
||||||
|
virtual ~SoundDecoder() { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Make non-copyable
|
||||||
|
SoundDecoder(const SoundDecoder &rhs);
|
||||||
|
SoundDecoder& operator=(const SoundDecoder &rhs);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue