46 static size_t read(
void *ptr,
size_t size,
size_t nmemb,
void *datasource) {
49 size_t len = (restlen<=size*nmemb)?restlen:size*nmemb;
51 rdp->
readInto(reinterpret_cast<uint8_t *>(ptr), len);
56 static int32_t
seek(
void *datasource, ogg_int64_t offset, int32_t whence) {
60 (*rdp).
setIndex(static_cast<uint32_t>(offset));
63 (*rdp).moveIndex(static_cast<uint32_t>(offset));
66 (*rdp).setIndex( (*rdp).getDataLength() -1 +
static_cast<uint32_t>(offset));
72 static int32_t
close(
void *datasource) {
return 0; }
74 static long tell(
void *datasource) {
86 if (0 > ov_open_callbacks(
m_file.get(), &
m_ovf, 0, 0, ocb)) {
87 throw InvalidFormat(
"Error opening OggVorbis file");
91 vorbis_info* vi = ov_info(&
m_ovf, -1);
93 throw InvalidFormat(
"Error fetching OggVorbis info");
96 if (!ov_seekable(&
m_ovf)) {
97 throw InvalidFormat(
"OggVorbis file has to be seekable");
119 m_data =
new char[length];
128 }
else if (ret == OV_HOLE) {
130 }
else if (ret == 0 || ret <= OV_EREAD) {
static long tell(void *datasource)
static int32_t seek(void *datasource, ogg_int64_t offset, int32_t whence)
static Logger _log(LM_AUDIO)
uint32_t getDataLength() const
get the complete datalength
void releaseBuffer()
Releases the buffer returned by getBuffer()
bool setCursor(uint64_t pos)
Sets the current position in the file (in bytes)
uint32_t getCurrentIndex() const
get the current index
std::unique_ptr< RawData > m_file
static int32_t close(void *datasource)
void readInto(uint8_t *buffer, size_t len)
read len bytes into buffer
SoundDecoderOgg(RawData *ptr)
void setIndex(uint32_t index)
set the current index
bool decode(uint64_t length)
Request the decoding of the next part of the stream.
Used to access diffrent kinds of data.
static size_t read(void *ptr, size_t size, size_t nmemb, void *datasource)