audiolib:

consolidate all multivoc invalid file errors into MV_InvalidFile
renamed FX_PlayLooped to FX_Play and removed original FX_Play
removed device type parameter from FX_Init
moved several FX_ multivoc wrapper functions to the header and made them FORCE_INLINE

git-svn-id: https://svn.eduke32.com/eduke32@5814 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-08-27 01:39:38 +00:00
parent 1305d32e84
commit a58e1ff580
13 changed files with 98 additions and 184 deletions

View file

@ -189,6 +189,7 @@
<ClInclude Include="source\input.h" />
<ClInclude Include="source\inv.h" />
<ClInclude Include="source\jaudiolib\include\drivers.h" />
<ClInclude Include="source\jaudiolib\include\multivoc.h" />
<ClInclude Include="source\lunatic\lunatic_game.h" />
<ClInclude Include="source\lunatic\lunatic_m32.h" />
<ClInclude Include="source\m32def.h" />
@ -232,7 +233,6 @@
<ClInclude Include="source\jaudiolib\src\driver_sdl.h" />
<ClInclude Include="source\jaudiolib\include\fx_man.h" />
<ClInclude Include="source\jaudiolib\src\linklist.h" />
<ClInclude Include="source\jaudiolib\src\multivoc.h" />
<ClInclude Include="source\jaudiolib\include\music.h" />
<ClInclude Include="source\jaudiolib\src\pitch.h" />
<ClInclude Include="source\jmact\_control.h" />

View file

@ -249,9 +249,6 @@
<ClInclude Include="source\jaudiolib\src\linklist.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
<ClInclude Include="source\jaudiolib\src\multivoc.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
<ClInclude Include="source\jaudiolib\include\music.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
@ -540,6 +537,9 @@
<ClInclude Include="build\include\clip.h">
<Filter>build\headers</Filter>
</ClInclude>
<ClInclude Include="source\jaudiolib\include\multivoc.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="build\src\a-c.c">

View file

@ -32,7 +32,6 @@ typedef enum
ASS_SDL,
#endif
ASS_NumSoundCards,
ASS_AutoDetect = -2
} soundcardnames;
extern int32_t ASS_SoundDriver;

View file

@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "inttypes.h"
#include "limits.h"
#include "drivers.h"
#include "multivoc.h"
#ifdef __cplusplus
extern "C" {
@ -57,43 +58,61 @@ enum FX_LOOP_HOW
#define FX_MUSIC_PRIORITY INT_MAX
const char *FX_ErrorString(int32_t ErrorNumber);
int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata);
int32_t FX_Init(int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata);
int32_t FX_Shutdown(void);
void FX_SetCallBack(void(*function)(uint32_t));
void FX_SetVolume(int32_t volume);
int32_t FX_GetVolume(void);
void FX_SetReverseStereo(int32_t setting);
int32_t FX_GetReverseStereo(void);
void FX_SetReverb(int32_t reverb);
int32_t FX_GetMaxReverbDelay(void);
int32_t FX_GetReverbDelay(void);
void FX_SetReverbDelay(int32_t delay);
int32_t FX_PauseVoice(int32_t handle, int32_t pause);
int32_t FX_VoiceAvailable(int32_t priority);
int32_t FX_EndLooping(int32_t handle);
int32_t FX_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right);
int32_t FX_SetPitch(int32_t handle, int32_t pitchoffset);
int32_t FX_SetFrequency(int32_t handle, int32_t frequency);
int32_t FX_Play(char *ptr, uint32_t ptrlength, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
int32_t priority, uint32_t callbackval);
int32_t FX_PlayLooped(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t FX_Play(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval);
int32_t FX_Play3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle,
int32_t distance, int32_t priority, uint32_t callbackval);
int32_t FX_Pan3D(int32_t handle, int32_t angle, int32_t distance);
int32_t FX_SoundActive(int32_t handle);
int32_t FX_SoundsPlaying(void);
int32_t FX_StopSound(int32_t handle);
int32_t FX_StopAllSounds(void);
int32_t FX_SetPrintf(void(*function)(const char *, ...));
int32_t FX_GetPosition(int32_t handle, int32_t *position);
int32_t FX_SetPosition(int32_t handle, int32_t position);
extern int32_t FX_ErrorCode;
#define FX_SetErrorCode(status) FX_ErrorCode = (status);
FORCE_INLINE int FX_CheckMVErr(int32_t status)
{
if (status != MV_Ok)
{
FX_SetErrorCode(FX_MultiVocError);
status = FX_Warning;
}
return status;
}
FORCE_INLINE void FX_SetCallBack(void(*function)(uint32_t)) { MV_SetCallBack(function); }
FORCE_INLINE void FX_SetVolume(int32_t volume) { MV_SetVolume(volume); }
FORCE_INLINE int32_t FX_GetVolume(void) { return MV_GetVolume(); }
FORCE_INLINE void FX_SetReverseStereo(int32_t setting) { MV_SetReverseStereo(setting); }
FORCE_INLINE int32_t FX_GetReverseStereo(void) { return MV_GetReverseStereo(); }
FORCE_INLINE void FX_SetReverb(int32_t reverb) { MV_SetReverb(reverb); }
FORCE_INLINE int32_t FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); }
FORCE_INLINE int32_t FX_GetReverbDelay(void) { return MV_GetReverbDelay(); }
FORCE_INLINE void FX_SetReverbDelay(int32_t delay) { MV_SetReverbDelay(delay); }
FORCE_INLINE int32_t FX_VoiceAvailable(int32_t priority) { return MV_VoiceAvailable(priority); }
FORCE_INLINE int32_t FX_PauseVoice(int32_t handle, int32_t pause) { return FX_CheckMVErr(MV_PauseVoice(handle, pause)); }
FORCE_INLINE int32_t FX_GetPosition(int32_t handle, int32_t *position) { return FX_CheckMVErr(MV_GetPosition(handle, position)); }
FORCE_INLINE int32_t FX_SetPosition(int32_t handle, int32_t position) { return FX_CheckMVErr(MV_SetPosition(handle, position)); }
FORCE_INLINE int32_t FX_EndLooping(int32_t handle) { return FX_CheckMVErr(MV_EndLooping(handle)); }
FORCE_INLINE int32_t FX_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
{
return FX_CheckMVErr(MV_SetPan(handle, vol, left, right));
}
FORCE_INLINE int32_t FX_SetPitch(int32_t handle, int32_t pitchoffset) { return FX_CheckMVErr(MV_SetPitch(handle, pitchoffset)); }
FORCE_INLINE int32_t FX_SetFrequency(int32_t handle, int32_t frequency) { return FX_CheckMVErr(MV_SetFrequency(handle, frequency)); }
FORCE_INLINE int32_t FX_Pan3D(int32_t handle, int32_t angle, int32_t distance)
{
return FX_CheckMVErr(MV_Pan3D(handle, angle, distance));
}
FORCE_INLINE int32_t FX_SoundActive(int32_t handle) { return MV_VoicePlaying(handle); }
FORCE_INLINE int32_t FX_SoundsPlaying(void) { return MV_VoicesPlaying(); }
FORCE_INLINE int32_t FX_StopSound(int32_t handle) { return FX_CheckMVErr(MV_Kill(handle)); }
FORCE_INLINE int32_t FX_StopAllSounds(void) { return FX_CheckMVErr(MV_KillAllVoices()); }
#ifdef __cplusplus
}

View file

@ -96,17 +96,14 @@ extern int32_t MV_ErrorCode;
enum MV_Errors
{
MV_Error = -1,
MV_Ok = 0,
MV_NotInstalled,
MV_DriverError,
MV_NoVoices,
MV_NoMem,
MV_VoiceNotFound,
MV_InvalidVOCFile,
MV_InvalidWAVFile,
MV_InvalidVorbisFile,
MV_InvalidFLACFile,
MV_InvalidXAFile,
MV_InvalidFile,
};
extern void (*MV_Printf)(const char *fmt, ...);

View file

@ -446,7 +446,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
fd = (flac_data *)calloc(1, sizeof(flac_data));
if (!fd)
{
MV_SetErrorCode(MV_InvalidFLACFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -468,7 +468,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
(void *)fd) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
{
MV_Printf("MV_PlayFLAC: %s\n", FLAC__stream_decoder_get_resolved_state_string(fd->stream));
MV_SetErrorCode(MV_InvalidFLACFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -540,7 +540,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
FLAC__stream_decoder_finish(fd->stream);
FLAC__stream_decoder_delete(fd->stream);
free(fd);
MV_SetErrorCode(MV_InvalidFLACFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}

View file

@ -347,7 +347,7 @@ int32_t MV_PlayWAV(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
if ((memcmp(riff.RIFF, "RIFF", 4) != 0) || (memcmp(riff.WAVE, "WAVE", 4) != 0) || (memcmp(riff.fmt, "fmt ", 4) != 0))
{
MV_SetErrorCode(MV_InvalidWAVFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -368,7 +368,7 @@ int32_t MV_PlayWAV(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
if (format.wFormatTag != 1 || (format.nChannels != 1 && format.nChannels != 2) ||
((format.nBitsPerSample != 8) && (format.nBitsPerSample != 16)) || memcmp(data.DATA, "data", 4) != 0)
{
MV_SetErrorCode(MV_InvalidWAVFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -455,7 +455,7 @@ int32_t MV_PlayVOC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
// Make sure it looks like a valid VOC file.
if (memcmp(ptr, "Creative Voice File", 19) != 0)
{
MV_SetErrorCode(MV_InvalidVOCFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}

View file

@ -41,8 +41,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
int32_t FX_ErrorCode = FX_Ok;
int32_t FX_Installed = FALSE;
#define FX_SetErrorCode(status) FX_ErrorCode = (status);
const char *FX_ErrorString(int32_t ErrorNumber)
{
const char *ErrorString;
@ -54,8 +52,6 @@ const char *FX_ErrorString(int32_t ErrorNumber)
case FX_Ok: ErrorString = "Fx ok."; break;
case FX_InvalidCard: ErrorString = "Invalid Sound Fx device."; break;
case FX_MultiVocError: ErrorString = MV_ErrorString(MV_Error); break;
default: ErrorString = "Unknown Fx error code."; break;
@ -64,39 +60,19 @@ const char *FX_ErrorString(int32_t ErrorNumber)
return ErrorString;
}
static inline int32_t FX_CheckMVErr(int32_t status)
{
if (status != MV_Ok)
{
FX_SetErrorCode(FX_MultiVocError);
status = FX_Warning;
}
return status;
}
int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata)
int32_t FX_Init(int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata)
{
if (FX_Installed)
FX_Shutdown();
if (SoundCard == ASS_AutoDetect)
{
#if defined MIXERTYPEWIN
SoundCard = ASS_DirectSound;
int SoundCard = ASS_DirectSound;
#elif defined MIXERTYPESDL
SoundCard = ASS_SDL;
int SoundCard = ASS_SDL;
#else
#warning No sound driver selected!
SoundCard = ASS_NoSound;
int SoundCard = ASS_NoSound;
#endif
}
if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards)
{
FX_SetErrorCode(FX_InvalidCard);
return FX_Error;
}
if (SoundDriver_IsSupported(SoundCard) == 0)
{
@ -136,62 +112,12 @@ int32_t FX_Shutdown(void)
return status;
}
void FX_SetCallBack(void (*function)(uint32_t)) { MV_SetCallBack(function); }
void FX_SetVolume(int32_t volume) { MV_SetVolume(volume); }
int32_t FX_GetVolume(void) { return MV_GetVolume(); }
void FX_SetReverseStereo(int32_t setting) { MV_SetReverseStereo(setting); }
int32_t FX_GetReverseStereo(void) { return MV_GetReverseStereo(); }
void FX_SetReverb(int32_t reverb) { MV_SetReverb(reverb); }
int32_t FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); }
int32_t FX_GetReverbDelay(void) { return MV_GetReverbDelay(); }
void FX_SetReverbDelay(int32_t delay) { MV_SetReverbDelay(delay); }
int32_t FX_VoiceAvailable(int32_t priority) { return MV_VoiceAvailable(priority); }
int32_t FX_PauseVoice(int32_t handle, int32_t pause) { return FX_CheckMVErr(MV_PauseVoice(handle, pause)); }
int32_t FX_GetPosition(int32_t handle, int32_t *position) { return FX_CheckMVErr(MV_GetPosition(handle, position)); }
int32_t FX_SetPosition(int32_t handle, int32_t position) { return FX_CheckMVErr(MV_SetPosition(handle, position)); }
int32_t FX_EndLooping(int32_t handle) { return FX_CheckMVErr(MV_EndLooping(handle)); }
int32_t FX_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
{
return FX_CheckMVErr(MV_SetPan(handle, vol, left, right));
}
int32_t FX_SetPitch(int32_t handle, int32_t pitchoffset) { return FX_CheckMVErr(MV_SetPitch(handle, pitchoffset)); }
int32_t FX_SetFrequency(int32_t handle, int32_t frequency) { return FX_CheckMVErr(MV_SetFrequency(handle, frequency)); }
int32_t FX_Pan3D(int32_t handle, int32_t angle, int32_t distance)
{
return FX_CheckMVErr(MV_Pan3D(handle, angle, distance));
}
int32_t FX_SoundActive(int32_t handle) { return MV_VoicePlaying(handle); }
int32_t FX_SoundsPlaying(void) { return MV_VoicesPlaying(); }
int32_t FX_StopSound(int32_t handle) { return FX_CheckMVErr(MV_Kill(handle)); }
int32_t FX_StopAllSounds(void) { return FX_CheckMVErr(MV_KillAllVoices()); }
static wavefmt_t FX_AutoDetectFormat(const char *ptr, uint32_t length)
{
wavefmt_t fmt = FMT_UNKNOWN;
if (length < 12)
return fmt;
return FMT_UNKNOWN;
wavefmt_t fmt = FMT_UNKNOWN;
switch (LITTLE32(*(int32_t const *)ptr))
{
@ -226,26 +152,18 @@ static wavefmt_t FX_AutoDetectFormat(const char *ptr, uint32_t length)
return fmt;
}
int32_t FX_Play(char *ptr, uint32_t length, int32_t pitchoffset, int32_t vol,
int32_t left, int32_t right, int32_t priority, uint32_t callbackval)
{
return FX_PlayLooped(ptr, length, -1, -1, pitchoffset, vol, left, right, priority, callbackval);
}
int32_t FX_PlayLooped(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t FX_Play(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval)
{
int32_t handle = -1;
EDUKE32_STATIC_ASSERT(FMT_MAX == 7);
static int32_t(*const func[FMT_MAX])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint32_t) =
{ NULL, NULL, MV_PlayVOC, MV_PlayWAV, MV_PlayVorbis, MV_PlayFLAC, MV_PlayXA };
wavefmt_t const fmt = FX_AutoDetectFormat(ptr, length);
wavefmt_t const fmt = FX_DetectFormat(ptr, length);
if (func[fmt])
handle = func[fmt](ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
int handle =
(func[fmt]) ? func[fmt](ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval) : -1;
if (handle <= MV_Ok)
{
@ -259,17 +177,15 @@ int32_t FX_PlayLooped(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
int32_t FX_Play3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance,
int32_t priority, uint32_t callbackval)
{
int32_t handle = -1;
EDUKE32_STATIC_ASSERT(FMT_MAX == 7);
static int32_t (*const func[FMT_MAX])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint32_t) =
{ NULL, NULL, MV_PlayVOC3D, MV_PlayWAV3D, MV_PlayVorbis3D, MV_PlayFLAC3D, MV_PlayXA3D };
wavefmt_t const fmt = FX_AutoDetectFormat(ptr, length);
wavefmt_t const fmt = FX_DetectFormat(ptr, length);
if (func[fmt])
handle = func[fmt](ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval);
int handle =
(func[fmt]) ? func[fmt](ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval) : -1;
if (handle <= MV_Ok)
{

View file

@ -43,8 +43,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "pitch.h"
#include "multivoc.h"
#include "_multivc.h"
#include "fx_man.h"
static void MV_Mix(VoiceNode *voice, int32_t buffer);
static void MV_StopVoice(VoiceNode *voice);
static void MV_ServiceVoc(void);
@ -52,8 +52,6 @@ static VoiceNode *MV_GetVoice(int32_t handle);
static const int16_t *MV_GetVolumeTable(int32_t vol);
static void MV_CalcPanTable(void);
#define IS_QUIET(ptr) ((void const *)(ptr) == (void *)&MV_VolumeTable[0])
static int32_t MV_ReverbLevel;
@ -103,13 +101,13 @@ int32_t MV_ErrorCode = MV_NotInstalled;
static int32_t lockdepth = 0;
static inline void DisableInterrupts(void)
FORCE_INLINE void DisableInterrupts(void)
{
if (lockdepth++ <= 0)
SoundDriver_Lock();
}
static inline void RestoreInterrupts(void)
FORCE_INLINE void RestoreInterrupts(void)
{
if (--lockdepth <= 0)
SoundDriver_Unlock();
@ -133,22 +131,14 @@ const char *MV_ErrorString(int32_t ErrorNumber)
return "Out of memory in Multivoc.";
case MV_VoiceNotFound:
return "No voice with matching handle found.";
case MV_InvalidVOCFile:
return "Invalid VOC file passed in to Multivoc.";
case MV_InvalidWAVFile:
return "Invalid WAV file passed in to Multivoc.";
case MV_InvalidVorbisFile:
return "Invalid OggVorbis file passed in to Multivoc.";
case MV_InvalidFLACFile:
return "Invalid FLAC file passed in to Multivoc.";
case MV_InvalidXAFile:
return "Invalid XA file passed in to Multivoc.";
case MV_InvalidFile:
return "Invalid file passed in to Multivoc.";
default:
return "Unknown Multivoc error code.";
}
}
static void MV_Mix(VoiceNode *voice, int32_t buffer)
static void MV_Mix(VoiceNode *voice, int const buffer)
{
/* cheap fix for a crash under 64-bit linux */
/* v v v v */
@ -169,11 +159,11 @@ static void MV_Mix(VoiceNode *voice, int32_t buffer)
}
// Add this voice to the mix
while (length > 0)
do
{
const char *start = voice->sound;
uint32_t rate = voice->RateScale;
uint32_t position = voice->position;
uint32_t const rate = voice->RateScale;
uint32_t const position = voice->position;
int32_t voclength;
// Check if the last sample in this buffer would be
@ -210,7 +200,7 @@ static void MV_Mix(VoiceNode *voice, int32_t buffer)
FixedPointBufferSize = voice->RateScale * (length - voice->channels);
}
}
}
} while (length > 0);
}
void MV_PlayVoice(VoiceNode *voice)
@ -297,11 +287,12 @@ static void MV_ServiceVoc(void)
// Play any waiting voices
//DisableInterrupts();
VoiceNode *voice;
if (!VoiceList.next || (voice = VoiceList.next) == &VoiceList)
if (!VoiceList.next || VoiceList.next == &VoiceList)
return;
VoiceNode *voice = VoiceList.next;
int iter = 0;
VoiceNode *next;
@ -835,9 +826,7 @@ static void MV_StopPlayback(void)
// Make sure all callbacks are done.
DisableInterrupts();
VoiceNode *voice, *next;
for (voice = VoiceList.next; voice != &VoiceList; voice = next)
for (VoiceNode *voice = VoiceList.next, *next; voice != &VoiceList; voice = next)
{
next = voice->next;
@ -929,16 +918,13 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
MV_Voices = (VoiceNode *)ptr;
ptr += Voices * sizeof(VoiceNode);
// Set number of voices before calculating volume table
MV_MaxVoices = Voices;
LL_Reset((VoiceNode*) &VoiceList, next, prev);
LL_Reset((VoiceNode*) &VoicePool, next, prev);
for (int index = 0; index < Voices; index++)
{
LL_Add((VoiceNode*) &VoicePool, &MV_Voices[ index ], next, prev);
}
MV_SetReverseStereo(FALSE);

View file

@ -381,7 +381,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t
if (!vd)
{
MV_SetErrorCode(MV_InvalidVorbisFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -395,7 +395,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t
if (status < 0)
{
MV_Printf("MV_PlayVorbis: err %d\n", status);
MV_SetErrorCode(MV_InvalidVorbisFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -405,7 +405,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t
{
ov_clear(&vd->vf);
free(vd);
MV_SetErrorCode(MV_InvalidVorbisFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}
@ -413,7 +413,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t
{
ov_clear(&vd->vf);
free(vd);
MV_SetErrorCode(MV_InvalidVorbisFile);
MV_SetErrorCode(MV_InvalidFile);
return MV_Error;
}

View file

@ -460,7 +460,7 @@ int32_t MV_PlayXA
xad = (xa_data *) calloc( 1, sizeof(xa_data) );
if (!xad) {
MV_SetErrorCode( MV_InvalidXAFile );
MV_SetErrorCode( MV_InvalidFile );
return MV_Error;
}

View file

@ -53,7 +53,7 @@ void S_SoundStartup(void)
initprintf("Initializing sound... ");
if (FX_Init(ASS_AutoDetect, ud.config.NumVoices, ud.config.NumChannels, ud.config.MixRate, initdata) != FX_Ok)
if (FX_Init(ud.config.NumVoices, ud.config.NumChannels, ud.config.MixRate, initdata) != FX_Ok)
{
initprintf("failed! %s\n", FX_ErrorString(FX_Error));
return;
@ -235,7 +235,7 @@ int32_t S_PlayMusic(const char *fn)
else
{
int32_t const mvol = MASTER_VOLUME(ud.config.MusicVolume);
MusicVoice = FX_PlayLooped(MusicPtr, MusicLen, 0, 0,
MusicVoice = FX_Play(MusicPtr, MusicLen, 0, 0,
0, mvol, mvol, mvol,
FX_MUSIC_PRIORITY, MUSIC_ID);
if (MusicVoice > FX_Ok)
@ -630,7 +630,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
if (repeatp && !ambsfxp)
{
voice = FX_PlayLooped(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
voice = FX_Play(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch, FX_VOLUME(sndist>>6), FX_VOLUME(sndist>>6), 0, // XXX: why is 'right' 0?
g_sounds[num].pr, (num * MAXSOUNDINSTANCES) + j);
}
@ -703,7 +703,7 @@ int32_t S_PlaySound(int32_t num)
}
if (g_sounds[num].m & SF_LOOP)
voice = FX_PlayLooped(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
voice = FX_Play(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,FX_VOLUME(LOUDESTVOLUME), FX_VOLUME(LOUDESTVOLUME), FX_VOLUME(LOUDESTVOLUME),
g_sounds[num].soundsiz, (num * MAXSOUNDINSTANCES) + j);
else

View file

@ -73,19 +73,16 @@ void S_Callback(uint32_t);
int32_t S_SoundStartup(void)
{
int32_t status;
int32_t fxdevicetype;
void *initdata = 0;
// TODO: read config
int32_t FXVolume=220, /*NumVoices=32,*/ NumChannels=2, ReverseStereo=0;
fxdevicetype = ASS_AutoDetect;
#ifdef MIXERTYPEWIN
initdata = (void *) win_gethwnd(); // used for DirectSound
#endif
status = FX_Init(fxdevicetype, NumVoices, NumChannels, MixRate, initdata);
status = FX_Init(NumVoices, NumChannels, MixRate, initdata);
if (status == FX_Ok)
{
FX_SetVolume(FXVolume);
@ -260,7 +257,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
if (g_sounds[num].num > 0)
return -1;
voice = FX_PlayLooped(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
voice = FX_Play(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch, sndist>>6, sndist>>6, 0, g_sounds[num].pr, num);
}
else
@ -319,7 +316,7 @@ void S_PlaySound(int32_t num)
if (g_sounds[num].m & SF_LOOP)
{
voice = FX_PlayLooped(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
voice = FX_Play(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz,num);
}
else