2014-06-20 06:03:13 +00:00
|
|
|
#ifndef MPG123_DECODER_H
|
|
|
|
#define MPG123_DECODER_H
|
|
|
|
|
2019-09-29 23:34:16 +00:00
|
|
|
#include "zmusic/sounddecoder.h"
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MPG123
|
|
|
|
|
2014-09-12 11:26:54 +00:00
|
|
|
#ifdef _MSC_VER
|
2017-03-06 16:05:06 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
typedef ptrdiff_t ssize_t;
|
2014-09-12 11:26:54 +00:00
|
|
|
#endif
|
2017-04-17 15:05:09 +00:00
|
|
|
|
|
|
|
#ifndef DYN_MPG123
|
2014-06-20 06:03:13 +00:00
|
|
|
#include "mpg123.h"
|
2017-04-17 15:05:09 +00:00
|
|
|
#else
|
|
|
|
#include "thirdparty/mpg123.h"
|
|
|
|
#endif
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
struct MPG123Decoder : public SoundDecoder
|
|
|
|
{
|
2019-09-29 10:48:12 +00:00
|
|
|
virtual void getInfo(int* samplerate, ChannelConfig* chans, SampleType* type) override;
|
2014-06-20 06:03:13 +00:00
|
|
|
|
2019-09-29 10:48:12 +00:00
|
|
|
virtual size_t read(char* buffer, size_t bytes) override;
|
|
|
|
virtual bool seek(size_t ms_offset, bool ms, bool mayrestart) override;
|
|
|
|
virtual size_t getSampleOffset() override;
|
|
|
|
virtual size_t getSampleLength() override;
|
2014-06-20 06:03:13 +00:00
|
|
|
|
2019-09-29 10:48:12 +00:00
|
|
|
MPG123Decoder() : MPG123(0) { }
|
|
|
|
virtual ~MPG123Decoder();
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
protected:
|
2019-09-29 10:48:12 +00:00
|
|
|
virtual bool open(MusicIO::FileInterface *reader) override;
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
mpg123_handle *MPG123;
|
|
|
|
bool Done;
|
|
|
|
|
2019-09-29 10:48:12 +00:00
|
|
|
MusicIO::FileInterface* Reader;
|
|
|
|
static off_t file_lseek(void *handle, off_t offset, int whence);
|
2014-06-20 06:03:13 +00:00
|
|
|
static ssize_t file_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 */
|