gzdoom/libraries/zmusic/zmusic/sounddecoder.h
Christoph Oelckers cdf2a17c5a - moved the sound decoding code to the zmusic project.
Since this gets used by both the sound backend and the music code it needs to be in a place accessible to both.
2019-09-29 12:48:12 +02:00

40 lines
956 B
C++

#pragma once
#include "../../music_common/fileio.h"
#include <vector>
enum SampleType
{
SampleType_UInt8,
SampleType_Int16
};
enum ChannelConfig
{
ChannelConfig_Mono,
ChannelConfig_Stereo
};
struct SoundDecoder
{
static SoundDecoder* CreateDecoder(MusicIO::FileInterface* reader);
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
virtual size_t read(char *buffer, size_t bytes) = 0;
virtual std::vector<uint8_t> readAll();
virtual bool seek(size_t ms_offset, bool ms, bool mayrestart) = 0;
virtual size_t getSampleOffset() = 0;
virtual size_t getSampleLength() { return 0; }
virtual bool open(MusicIO::FileInterface* reader) = 0;
SoundDecoder() { }
virtual ~SoundDecoder() { }
protected:
friend class SoundRenderer;
// Make non-copyable
SoundDecoder(const SoundDecoder &rhs) = delete;
SoundDecoder& operator=(const SoundDecoder &rhs) = delete;
};