2014-06-20 06:03:13 +00:00
|
|
|
#ifndef SNDFILE_DECODER_H
|
|
|
|
#define SNDFILE_DECODER_H
|
|
|
|
|
2019-09-29 23:34:16 +00:00
|
|
|
#include "zmusic/sounddecoder.h"
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SNDFILE
|
|
|
|
|
2017-04-17 15:05:09 +00:00
|
|
|
#ifndef DYN_SNDFILE
|
2014-06-20 06:03:13 +00:00
|
|
|
#include "sndfile.h"
|
2017-04-17 15:05:09 +00:00
|
|
|
#else
|
|
|
|
#include "thirdparty/sndfile.h"
|
|
|
|
#endif
|
2014-06-20 06:03:13 +00:00
|
|
|
|
|
|
|
struct SndFileDecoder : 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 std::vector<uint8_t> readAll() 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
|
|
|
|
2014-06-25 11:25:36 +00:00
|
|
|
SndFileDecoder() : SndFile(0) { }
|
2014-06-20 06:03:13 +00:00
|
|
|
virtual ~SndFileDecoder();
|
|
|
|
|
|
|
|
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:
|
|
|
|
SNDFILE *SndFile;
|
|
|
|
SF_INFO SndInfo;
|
|
|
|
|
2019-09-29 10:48:12 +00:00
|
|
|
MusicIO::FileInterface* Reader;
|
2014-06-20 06:03:13 +00:00
|
|
|
static sf_count_t file_get_filelen(void *user_data);
|
|
|
|
static sf_count_t file_seek(sf_count_t offset, int whence, void *user_data);
|
|
|
|
static sf_count_t file_read(void *ptr, sf_count_t count, void *user_data);
|
|
|
|
static sf_count_t file_write(const void *ptr, sf_count_t count, void *user_data);
|
|
|
|
static sf_count_t file_tell(void *user_data);
|
|
|
|
|
|
|
|
// Make non-copyable
|
|
|
|
SndFileDecoder(const SndFileDecoder &rhs);
|
|
|
|
SndFileDecoder& operator=(const SndFileDecoder &rhs);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* SNDFILE_DECODER_H */
|