qzdoom/src/sound/mpg123_decoder.h

49 lines
1.2 KiB
C
Raw Normal View History

#ifndef MPG123_DECODER_H
#define MPG123_DECODER_H
#include "i_soundinternal.h"
#ifdef HAVE_MPG123
#include "mpg123.h"
struct MPG123Decoder : public SoundDecoder
{
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
virtual size_t read(char *buffer, size_t bytes);
virtual bool seek(size_t ms_offset);
virtual size_t getSampleOffset();
MPG123Decoder() : MPG123(0), File(0) { }
virtual ~MPG123Decoder();
protected:
virtual bool open(const char *data, size_t length);
virtual bool open(const char *fname, size_t offset, size_t length);
private:
mpg123_handle *MPG123;
bool Done;
FILE *File;
size_t FileLength;
size_t FileOffset;
static off_t file_lseek(void *handle, off_t offset, int whence);
static ssize_t file_read(void *handle, void *buffer, size_t bytes);
const char *MemData;
size_t MemLength;
size_t MemPos;
static off_t mem_lseek(void *handle, off_t offset, int whence);
static ssize_t mem_read(void *handle, void *buffer, size_t bytes);
// Make non-copyable
MPG123Decoder(const MPG123Decoder &rhs);
MPG123Decoder& operator=(const MPG123Decoder &rhs);
};
#endif
#endif /* MPG123_DECODER_H */