]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_modplug.c
snd_alsa: MIDI input support! MIDI events get mapped to MIDINOTE<n> events (n = 0...
[xonotic/darkplaces.git] / snd_modplug.c
index 35b255c91e7f57e2ac2c79bcb2a439b32219c757..54a07909437e40bbbf3c2ad90d1ddde7fac4a186 100644 (file)
@@ -96,7 +96,8 @@ static int (*ModPlug_Read) (ModPlugFile* file, void* buffer, int size);
 static void (*ModPlug_Seek) (ModPlugFile* file, int millisecond);
 static void (*ModPlug_GetSettings) (ModPlug_Settings* settings);
 static void (*ModPlug_SetSettings) (const ModPlug_Settings* settings);
-static void (*ModPlug_SetMasterVolume) (ModPlugFile* file,unsigned int cvol) ;
+typedef void (ModPlug_SetMasterVolume_t) (ModPlugFile* file,unsigned int cvol) ;
+ModPlug_SetMasterVolume_t *ModPlug_SetMasterVolume;
 
 
 static dllfunction_t modplugfuncs[] =
@@ -159,7 +160,7 @@ qboolean ModPlug_OpenLibrary (void)
        // the modplug DLL automatically when loading the modplugFile DLL
        if(Sys_LoadLibrary (dllnames_modplug, &modplug_dll, modplugfuncs))
        {
-               ModPlug_SetMasterVolume = Sys_GetProcAddress(modplug_dll, "ModPlug_SetMasterVolume");
+               ModPlug_SetMasterVolume = (ModPlug_SetMasterVolume_t *) Sys_GetProcAddress(modplug_dll, "ModPlug_SetMasterVolume");
                if(!ModPlug_SetMasterVolume)
                        Con_Print("Warning: modplug volume control not supported. Try getting a newer version of libmodplug.\n");
                return true;
@@ -256,7 +257,9 @@ static const snd_buffer_t* ModPlug_FetchSound (void *sfxfetcher, void **chfetche
                        return NULL;
                }
 
+#ifndef SND_MODPLUG_STATIC
                if(ModPlug_SetMasterVolume)
+#endif
                        ModPlug_SetMasterVolume(per_ch->mf, 512); // max volume, DP scales down!
 
                per_ch->bs = 0;
@@ -315,7 +318,7 @@ static const snd_buffer_t* ModPlug_FetchSound (void *sfxfetcher, void **chfetche
                ModPlug_Seek(per_ch->mf, modplug_start);
                sb->nbframes = 0;
 
-               real_start = (float)modplug_start / 1000 * snd_renderbuffer->format.speed;
+               real_start = (unsigned int) ((float)modplug_start / 1000 * snd_renderbuffer->format.speed);
                if (*start - real_start + nbsampleframes > sb->maxframes)
                {
                        Con_Printf ("ModPlug_FetchSound: stream buffer too small after seek (%u sample frames required)\n",
@@ -466,7 +469,9 @@ qboolean ModPlug_LoadModPlugFile (const char *filename, sfx_t *sfx)
                return false;
        }
 
+#ifndef SND_MODPLUG_STATIC
        if(ModPlug_SetMasterVolume)
+#endif
                ModPlug_SetMasterVolume(mf, 512); // max volume, DP scales down!
 
        if (developer_loading.integer >= 2)