#include "snd_main.h"
#include "snd_modplug.h"
+#ifdef SND_MODPLUG_STATIC
+
+#include <libmodplug/modplug.h>
+qboolean ModPlug_OpenLibrary (void)
+{
+ return true; // statically linked
+}
+void ModPlug_CloseLibrary (void)
+{
+}
+#define modplug_dll 1
+
+#else
// BEGIN SECTION FROM modplug.h
/*
static void (*ModPlug_Seek) (ModPlugFile* file, int millisecond);
static void (*ModPlug_GetSettings) (ModPlug_Settings* settings);
static void (*ModPlug_SetSettings) (const ModPlug_Settings* settings);
+typedef void (ModPlug_SetMasterVolume_t) (ModPlugFile* file,unsigned int cvol) ;
+ModPlug_SetMasterVolume_t *ModPlug_SetMasterVolume;
+
static dllfunction_t modplugfuncs[] =
{
// Load the DLLs
// We need to load both by hand because some OSes seem to not load
// the modplug DLL automatically when loading the modplugFile DLL
- if (! Sys_LoadLibrary (dllnames_modplug, &modplug_dll, modplugfuncs))
+ if(Sys_LoadLibrary (dllnames_modplug, &modplug_dll, modplugfuncs))
{
- Sys_UnloadLibrary (&modplug_dll);
- Con_Printf ("ModPlug support disabled\n");
- return false;
+ 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;
}
-
- Con_Printf ("ModPlug support enabled\n");
- return true;
+ else
+ return false;
}
{
Sys_UnloadLibrary (&modplug_dll);
}
+#endif
/*
modplug_stream_perchannel_t* per_ch = (modplug_stream_perchannel_t *)*chfetcherpointer;
modplug_stream_persfx_t* per_sfx = (modplug_stream_persfx_t *)sfxfetcher;
snd_buffer_t* sb;
- int newlength, done, ret, bigendian;
+ int newlength, done, ret;
unsigned int real_start;
unsigned int factor;
Mem_Free (per_ch);
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;
per_ch->sb_offset = 0;
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",
newlength = sizeof(resampling_buffer);
// Decompress in the resampling_buffer
-#if BYTE_ORDER == BIG_ENDIAN
- bigendian = 1;
-#else
- bigendian = 0;
-#endif
done = 0;
while ((ret = ModPlug_Read (per_ch->mf, (char *)&resampling_buffer[done], (int)(newlength - done))) > 0)
done += ret;
if (data == NULL)
return false;
- Con_DPrintf ("Loading ModPlug file \"%s\"\n", filename);
+ if (developer_loading.integer >= 2)
+ Con_Printf ("Loading ModPlug file \"%s\"\n", filename);
ModPlug_GetSettings(&s);
s.mFlags = MODPLUG_ENABLE_OVERSAMPLING | MODPLUG_ENABLE_NOISE_REDUCTION | MODPLUG_ENABLE_REVERB;
return false;
}
- Con_DPrintf ("\"%s\" will be streamed\n", filename);
+#ifndef SND_MODPLUG_STATIC
+ if(ModPlug_SetMasterVolume)
+#endif
+ ModPlug_SetMasterVolume(mf, 512); // max volume, DP scales down!
+
+ if (developer_loading.integer >= 2)
+ Con_Printf ("\"%s\" will be streamed\n", filename);
per_sfx = (modplug_stream_persfx_t *)Mem_Alloc (snd_mempool, sizeof (*per_sfx));
strlcpy(per_sfx->name, sfx->name, sizeof(per_sfx->name));
sfx->memsize += sizeof (*per_sfx);