]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_ogg.c
Added CL_Shutdown which took care of 14 memory leaks totaling over 30mb. (needs more...
[xonotic/darkplaces.git] / snd_ogg.c
index 17fc7dff64105615a3ec4f65c20a6940d866d5a1..ad74ff0c6520292d5ee5368646760d8beacadf45 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -23,6 +23,7 @@
 
 
 #include "quakedef.h"
+#include "snd_main.h"
 #include "snd_ogg.h"
 #include "snd_wav.h"
 
@@ -214,7 +215,8 @@ static dllfunction_t oggvorbisfuncs[] =
        {NULL, NULL}
 };
 
-// Handle for the Vorbisfile DLL
+// Handles for the Vorbis and Vorbisfile DLLs
+static dllhandle_t vo_dll = NULL;
 static dllhandle_t vf_dll = NULL;
 
 typedef struct
@@ -292,21 +294,34 @@ Try to load the VorbisFile DLL
 */
 qboolean OGG_OpenLibrary (void)
 {
-       const char* dllname;
+       const char *dllname_vo, *dllname_vf;
 
        // Already loaded?
        if (vf_dll)
                return true;
 
+// COMMANDLINEOPTION: Sound: -novorbis disables ogg vorbis sound support
+       if (COM_CheckParm("-novorbis"))
+               return false;
+
 #ifdef WIN32
-       dllname = "vorbisfile.dll";
+       dllname_vo = "vorbis.dll";
+       dllname_vf = "vorbisfile.dll";
+#elif defined(MACOSX)
+       dllname_vo = "libvorbis.dylib";
+       dllname_vf = "libvorbisfile.dylib";
 #else
-       dllname = "libvorbisfile.so";
+       dllname_vo = "libvorbis.so";
+       dllname_vf = "libvorbisfile.so";
 #endif
 
-       // Load the DLL
-       if (! Sys_LoadLibrary (dllname, &vf_dll, oggvorbisfuncs))
+       // Load the DLLs
+       // We need to load both by hand because some OSes seem to not load
+       // the vorbis DLL automatically when loading the VorbisFile DLL
+       if (! Sys_LoadLibrary (dllname_vo, &vo_dll, NULL) ||
+               ! Sys_LoadLibrary (dllname_vf, &vf_dll, oggvorbisfuncs))
        {
+               Sys_UnloadLibrary (&vo_dll);
                Con_Printf ("Ogg Vorbis support disabled\n");
                return false;
        }
@@ -326,6 +341,7 @@ Unload the VorbisFile DLL
 void OGG_CloseLibrary (void)
 {
        Sys_UnloadLibrary (&vf_dll);
+       Sys_UnloadLibrary (&vo_dll);
 }
 
 
@@ -515,7 +531,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
                return false;
 
        Mem_FreePool (&s->mempool);
-       s->mempool = Mem_AllocPool (s->name);
+       s->mempool = Mem_AllocPool (s->name, 0, NULL);
 
        // Load the file
        data = FS_LoadFile (filename, s->mempool, false);
@@ -583,7 +599,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
                long ret;
                sfxbuffer_t *sb;
 
-               Con_DPrintf ("\"%s\" will be streamed\n", filename);
+               Con_DPrintf ("\"%s\" will be cached\n", filename);
 
                // Decode it
                buff = Mem_Alloc (s->mempool, (int)len);