]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_ogg.c
- Got rid of all the FILE* stuff in the FS code, relying on low-level
[xonotic/darkplaces.git] / snd_ogg.c
index 74a2e193f708082f2b11762c34117946db69cafb..6139019832269a53babbb1087d8e012cde2b4b3d 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -215,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
@@ -293,7 +294,30 @@ Try to load the VorbisFile DLL
 */
 qboolean OGG_OpenLibrary (void)
 {
-       const char* dllname;
+       const char* dllnames_vo [] =
+       {
+#ifdef WIN32
+               "vorbis.dll",
+#elif defined(MACOSX)
+               "libvorbis.dylib",
+#else
+               "libvorbis.so.0",
+               "libvorbis.so",
+#endif
+               NULL
+       };
+       const char* dllnames_vf [] =
+       {
+#ifdef WIN32
+               "vorbisfile.dll",
+#elif defined(MACOSX)
+               "libvorbisfile.dylib",
+#else
+               "libvorbisfile.so.3",
+               "libvorbisfile.so",
+#endif
+               NULL
+       };
 
        // Already loaded?
        if (vf_dll)
@@ -303,15 +327,13 @@ qboolean OGG_OpenLibrary (void)
        if (COM_CheckParm("-novorbis"))
                return false;
 
-#ifdef WIN32
-       dllname = "vorbisfile.dll";
-#else
-       dllname = "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 (dllnames_vo, &vo_dll, NULL) ||
+               ! Sys_LoadLibrary (dllnames_vf, &vf_dll, oggvorbisfuncs))
        {
+               Sys_UnloadLibrary (&vo_dll);
                Con_Printf ("Ogg Vorbis support disabled\n");
                return false;
        }
@@ -331,6 +353,7 @@ Unload the VorbisFile DLL
 void OGG_CloseLibrary (void)
 {
        Sys_UnloadLibrary (&vf_dll);
+       Sys_UnloadLibrary (&vo_dll);
 }