gzdoom/src/sound/sndfile_decoder.h
Christoph Oelckers 7405f541e8 - allow dynamic loading of all sound related libraries without providing any SDK at all.
The needed headers are now included in the repo, which for these libraries is possible thanks to a stable ABI (at least on Windows, the other platforms still need to be checked but the headers only add, never remove or change existing content.)
The big advantage of this setup is that it allows building the project on Windows without any necessary setup - all that needs to be provided is the DLLs from the binary package.
This still requires some fixes for macOS and Linux. On MacOS the proper library names are missing and the ones for Linux are not verified. Both platforms should work, though, if the dynamic loading is disabled.
2017-04-17 17:05:09 +02:00

48 lines
1.2 KiB
C++

#ifndef SNDFILE_DECODER_H
#define SNDFILE_DECODER_H
#include "i_soundinternal.h"
#ifdef HAVE_SNDFILE
#ifndef DYN_SNDFILE
#include "sndfile.h"
#else
#include "thirdparty/sndfile.h"
#endif
struct SndFileDecoder : public SoundDecoder
{
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
virtual size_t read(char *buffer, size_t bytes);
virtual TArray<char> readAll();
virtual bool seek(size_t ms_offset, bool ms);
virtual size_t getSampleOffset();
virtual size_t getSampleLength();
SndFileDecoder() : SndFile(0) { }
virtual ~SndFileDecoder();
protected:
virtual bool open(FileReader *reader);
private:
SNDFILE *SndFile;
SF_INFO SndInfo;
FileReader *Reader;
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 */