From d9f30a5d423c4f72b60b39a55dc6571f4d9dd475 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sat, 27 Nov 2004 04:14:34 +0000 Subject: [PATCH] Faster Ogg reading (~2.5x in extremely unoptimised builds) This was SVN commit r1408. --- source/lib/res/snd.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/source/lib/res/snd.cpp b/source/lib/res/snd.cpp index e168312ecf..6a56ead16b 100755 --- a/source/lib/res/snd.cpp +++ b/source/lib/res/snd.cpp @@ -968,23 +968,22 @@ std::vector data; data.reserve(500000); if(file_type == FT_OGG) { -sd->o = ogg_create(); -ogg_give_raw(sd->o, file, file_size); -ogg_open(sd->o, sd->al_fmt, sd->al_freq); -size_t datasize=0; -size_t bytes_read; -do -{ -const size_t bufsize = 32*KB; -char buf[bufsize]; -bytes_read = ogg_read(sd->o, buf, bufsize); -data.resize(data.size() + bytes_read); -for(size_t i = 0; i < bytes_read; i++) data[datasize+i] = buf[i]; -datasize += bytes_read; -} -while(bytes_read > 0); -al_data = &data[0]; -al_size = (ALsizei)datasize; + sd->o = ogg_create(); + ogg_give_raw(sd->o, file, file_size); + ogg_open(sd->o, sd->al_fmt, sd->al_freq); + size_t datasize=0; + size_t bytes_read; + do + { + const size_t bufsize = 32*KB; + char buf[bufsize]; + bytes_read = ogg_read(sd->o, buf, bufsize); + data.insert(data.end(), &buf[0], &buf[bytes_read]); + datasize += bytes_read; + } + while(bytes_read > 0); + al_data = &data[0]; + al_size = (ALsizei)datasize; } #endif