14 #include "../Format.h"
15 #include "../Exceptions.h"
20 #include <vorbis/vorbisfile.h>
28 using std::numeric_limits;
30 size_t OggData::read_func(
void *ptr,
size_t size,
size_t nmemb,
void *datasource)
35 int OggData::seek_func(
void *datasource, ogg_int64_t offset,
int whence)
43 file->
GoTo((
long)offset);
46 file->
GoTo(file->
Size() + (long)offset);
58 int OggData::close_func(
void *datasource)
64 long OggData::tell_func(
void *datasource)
69 int OggData::nativeIsLsb()
73 char c[
sizeof(short)];
81 callbacks.read_func = &read_func;
82 callbacks.seek_func = &seek_func;
83 callbacks.close_func = &close_func;
84 callbacks.tell_func = &tell_func;
86 streamIndex = streamIdx;
89 if (ov_test_callbacks(&file, &vorbisFile, NULL, 0, callbacks))
90 throw FileFormatException(
"File \"" + file.
GetFilename() +
"\"is not ogg vorbis");
92 if (ov_open_callbacks(&file, &vorbisFile, NULL, 0, callbacks))
93 throw FileFormatException(
"File \"" + file.
GetFilename() +
"\"is not ogg vorbis");
95 vorbis_info *info = ov_info(&vorbisFile, streamIndex);
96 fmt.sampleFrequency = info->rate;
97 fmt.channels = info->channels;
98 fmt.bitsPerSample = 16;
99 fmt.nativeOrder = nativeIsLsb();
100 fmt.signedSamples = 1;
106 ov_clear(&vorbisFile);