X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsound.cpp;h=fe2de5eb5c4b85faa6c05c25e64a0d30d44f775d;hb=17948408eafd48ea529acd0a70cc45fc5973cb10;hp=f43948e65030b9d5041881ec8966171ca9eb08d9;hpb=dfec8f9568d11c432038d55f3ceb35d59614777d;p=libs%2Fal.git diff --git a/source/sound.cpp b/source/sound.cpp index f43948e..fe2de5e 100644 --- a/source/sound.cpp +++ b/source/sound.cpp @@ -18,7 +18,7 @@ struct MemorySource size_t memory_read(void *ptr, size_t size, size_t nmemb, void *src) { MemorySource &memsrc = *reinterpret_cast(src); - unsigned len = min(size*nmemb, memsrc.length-memsrc.pos); + unsigned len = min(size*nmemb, memsrc.length-memsrc.pos); memcpy(ptr, reinterpret_cast(memsrc.data)+memsrc.pos, len); memsrc.pos += len; @@ -103,6 +103,21 @@ void Sound::open_memory(const void *d, unsigned len) open_common(); } +void Sound::open_common() +{ + delete data; + data = 0; + + vorbis_info *info = ov_info(&ovfile, -1); + freq = info->rate; + switch(info->channels) + { + case 1: format = MONO16; break; + case 2: format = STEREO16; break; + default: throw runtime_error("Unsupported number of channels"); + } +} + void Sound::load_data() { if(data) @@ -176,20 +191,5 @@ const char *Sound::get_data() const return data; } -void Sound::open_common() -{ - delete data; - data = 0; - - vorbis_info *info = ov_info(&ovfile, -1); - freq = info->rate; - switch(info->channels) - { - case 1: format = MONO16; break; - case 2: format = STEREO16; break; - default: throw runtime_error("Unsupported number of channels"); - } -} - } // namespace AL } // namespace Msp