#include <C4SoundLoaders.h>
|
static size_t | mem_read_func (void *ptr, size_t byte_size, size_t size_to_read, void *datasource) |
|
static int | mem_seek_func (void *datasource, ogg_int64_t offset, int whence) |
|
static int | mem_close_func (void *datasource) |
|
static long | mem_tell_func (void *datasource) |
|
static size_t | file_read_func (void *ptr, size_t byte_size, size_t size_to_read, void *datasource) |
|
static int | file_seek_func (void *datasource, ogg_int64_t offset, int whence) |
|
static int | file_close_func (void *datasource) |
|
static long | file_tell_func (void *datasource) |
|
Definition at line 66 of file C4SoundLoaders.h.
◆ file_close_func()
int VorbisLoader::file_close_func |
( |
void * |
datasource | ) |
|
|
static |
Definition at line 172 of file C4SoundLoaders.cpp.
174 C4MusicFileOgg *ogg =
static_cast<C4MusicFileOgg *
>(datasource);
175 ogg->source_file.Close();
◆ file_read_func()
size_t VorbisLoader::file_read_func |
( |
void * |
ptr, |
|
|
size_t |
byte_size, |
|
|
size_t |
size_to_read, |
|
|
void * |
datasource |
|
) |
| |
|
static |
Definition at line 157 of file C4SoundLoaders.cpp.
159 C4MusicFileOgg *ogg =
static_cast<C4MusicFileOgg *
>(datasource);
160 size_t bytes_to_read = size_to_read*byte_size;
161 size_t bytes_read = 0u;
162 ogg->source_file.Read(ptr, bytes_to_read, &bytes_read);
163 return bytes_read / byte_size;
◆ file_seek_func()
int VorbisLoader::file_seek_func |
( |
void * |
datasource, |
|
|
ogg_int64_t |
offset, |
|
|
int |
whence |
|
) |
| |
|
static |
Definition at line 166 of file C4SoundLoaders.cpp.
168 C4MusicFileOgg *ogg =
static_cast<C4MusicFileOgg *
>(datasource);
169 return ogg->source_file.Seek(
static_cast<long int>(offset), whence);
◆ file_tell_func()
long VorbisLoader::file_tell_func |
( |
void * |
datasource | ) |
|
|
static |
Definition at line 179 of file C4SoundLoaders.cpp.
181 C4MusicFileOgg *ogg =
static_cast<C4MusicFileOgg *
>(datasource);
182 return ogg->source_file.Tell();
◆ mem_close_func()
int VorbisLoader::mem_close_func |
( |
void * |
datasource | ) |
|
|
static |
◆ mem_read_func()
size_t VorbisLoader::mem_read_func |
( |
void * |
ptr, |
|
|
size_t |
byte_size, |
|
|
size_t |
size_to_read, |
|
|
void * |
datasource |
|
) |
| |
|
static |
◆ mem_seek_func()
int VorbisLoader::mem_seek_func |
( |
void * |
datasource, |
|
|
ogg_int64_t |
offset, |
|
|
int |
whence |
|
) |
| |
|
static |
◆ mem_tell_func()
long VorbisLoader::mem_tell_func |
( |
void * |
datasource | ) |
|
|
static |
◆ ReadInfo()
bool VorbisLoader::ReadInfo |
( |
SoundInfo * |
result, |
|
|
BYTE * |
data, |
|
|
size_t |
data_length, |
|
|
uint32_t |
|
|
) |
| |
|
overridevirtual |
Implements C4SoundLoaders::SoundLoader.
Definition at line 185 of file C4SoundLoaders.cpp.
187 CompressedData compressed(data, data_length);
192 OggVorbis_File ogg_file;
193 memset(&ogg_file, 0,
sizeof(ogg_file));
194 ov_callbacks callbacks;
201 if (ov_open_callbacks(&compressed, &ogg_file,
nullptr, 0, callbacks) != 0)
208 info = ov_info(&ogg_file, -1);
209 if (info->channels == 1)
210 result->
format = AL_FORMAT_MONO16;
212 result->
format = AL_FORMAT_STEREO16;
217 const unsigned long total_size =
static_cast<unsigned int>(result->
sample_rate * result->
sample_length * 1000.0 * info->channels * 2 + 0.5);
218 const unsigned long extra_size = 1024 * 8;
222 unsigned long buffer_size = 0;
225 const int chunk_size = total_size + extra_size - std::min(total_size, buffer_size);
227 if (buffer_size+chunk_size > result->
sound_data.size())
228 result->
sound_data.resize(buffer_size+chunk_size);
229 bytes_read = ov_read(&ogg_file, (
char*)&result->
sound_data[buffer_size], chunk_size*
sizeof(
BYTE), endian, 2, 1, &bitStream);
230 buffer_size += bytes_read;
231 }
while (bytes_read > 0);
static long mem_tell_func(void *datasource)
static int mem_close_func(void *datasource)
static int mem_seek_func(void *datasource, ogg_int64_t offset, int whence)
static size_t mem_read_func(void *ptr, size_t byte_size, size_t size_to_read, void *datasource)
std::vector< BYTE > sound_data
References C4SoundLoaders::SoundInfo::format, mem_close_func(), mem_read_func(), mem_seek_func(), mem_tell_func(), C4SoundLoaders::SoundInfo::sample_length, C4SoundLoaders::SoundInfo::sample_rate, and C4SoundLoaders::SoundInfo::sound_data.
◆ first_loader
◆ next
◆ OPTION_Raw
const int C4SoundLoaders::SoundLoader::OPTION_Raw = 1 |
|
staticinherited |
◆ singleton
The documentation for this class was generated from the following files: