]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_ogg.c
fix a bug in AUTOSPRITE2 code caused by overzealous optimization, thanks to Elric...
[xonotic/darkplaces.git] / snd_ogg.c
index 0f23a222c94a320acc6255f0c010f9ac13bc4e56..b0073d263f6a9b9b5d9efe98379654b8c70fd203 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -300,6 +300,7 @@ qboolean OGG_OpenLibrary (void)
                "libvorbis64.dll",
 #elif defined(WIN32)
                "libvorbis.dll",
+               "vorbis.dll",
 #elif defined(MACOSX)
                "libvorbis.dylib",
 #else
@@ -314,6 +315,7 @@ qboolean OGG_OpenLibrary (void)
                "libvorbisfile64.dll",
 #elif defined(WIN32)
                "libvorbisfile.dll",
+               "vorbisfile.dll",
 #elif defined(MACOSX)
                "libvorbisfile.dylib",
 #else
@@ -370,7 +372,7 @@ void OGG_CloseLibrary (void)
 */
 
 #define STREAM_BUFFER_DURATION 1.5f    // 1.5 sec
-#define STREAM_BUFFER_SIZE(format_ptr) (ceil (STREAM_BUFFER_DURATION * ((format_ptr)->speed * (format_ptr)->width * (format_ptr)->channels)))
+#define STREAM_BUFFER_SIZE(format_ptr) ((int)(ceil (STREAM_BUFFER_DURATION * ((format_ptr)->speed * (format_ptr)->width * (format_ptr)->channels))))
 
 // We work with 1 sec sequences, so this buffer must be able to contain
 // 1 sec of sound of the highest quality (48 KHz, 16 bit samples, stereo)
@@ -616,7 +618,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
        len = qov_pcm_total (&vf, -1) * vi->channels * 2;  // 16 bits => "* 2"
 
        // Decide if we go for a stream or a simple PCM cache
-       buff_len = ceil (STREAM_BUFFER_DURATION * (shm->format.speed * 2 * vi->channels));
+       buff_len = (int)ceil (STREAM_BUFFER_DURATION * (shm->format.speed * 2 * vi->channels));
        if (snd_streaming.integer && len > (ogg_int64_t)filesize + 3 * buff_len)
        {
                ogg_stream_persfx_t* per_sfx;
@@ -639,7 +641,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
                s->fetcher = &ogg_fetcher;
                s->loopstart = -1;
                s->flags |= SFXFLAG_STREAMED;
-               s->total_length = (size_t)len / per_sfx->format.channels / 2 * ((float)s->format.speed / per_sfx->format.speed);
+               s->total_length = (int)((size_t)len / per_sfx->format.channels / 2 * ((float)s->format.speed / per_sfx->format.speed));
        }
        else
        {
@@ -665,7 +667,8 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
                        done += ret;
 
                // Calculate resampled length
-               len = (double)done * (double)shm->format.speed / (double)vi->rate;
+               // FIXME: is this using the correct rounding direction?  ceil may be better
+               len = (int)((double)done * (double)shm->format.speed / (double)vi->rate);
 
                // Resample it
                memsize = (size_t)len + sizeof (*sb) - sizeof (sb->data);