mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
- there's no need to let the XM Vorbis decoder run through the client - all related functionality is part of ZMusic itself.
This commit is contained in:
parent
47d70c839d
commit
527fb40a5f
8 changed files with 42 additions and 51 deletions
|
@ -802,9 +802,6 @@ DUH *make_duh(
|
|||
|
||||
void DUMBEXPORT duh_set_length(DUH *duh, int32 length);
|
||||
|
||||
extern short *(*dumb_decode_vorbis)(int outlen, const void *oggstream, int sizebytes);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
short * (*dumb_decode_vorbis)(int outlen, const void *oggstream, int sizebytes);
|
||||
short * dumb_decode_vorbis(int outlen, const void *oggstream, int sizebytes);
|
||||
|
||||
/** TODO:
|
||||
|
||||
|
@ -830,7 +830,7 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D
|
|||
sample->loop_start >>= 1;
|
||||
sample->loop_end >>= 1;
|
||||
}
|
||||
output = dumb_decode_vorbis? dumb_decode_vorbis(outlen, (char *)sample->data + 4, datasizebytes - 4) : NULL;
|
||||
output = dumb_decode_vorbis(outlen, (char *)sample->data + 4, datasizebytes - 4);
|
||||
if (output != NULL)
|
||||
{
|
||||
free(sample->data);
|
||||
|
|
|
@ -79,3 +79,39 @@ std::vector<uint8_t> SoundDecoder::readAll()
|
|||
output.resize(total);
|
||||
return output;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// other callbacks
|
||||
//
|
||||
//==========================================================================
|
||||
extern "C"
|
||||
short* dumb_decode_vorbis(int outlen, const void* oggstream, int sizebytes)
|
||||
{
|
||||
short* samples = (short*)calloc(1, outlen);
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
|
||||
// The decoder will take ownership of the reader if it succeeds so this may not be a local variable.
|
||||
MusicIO::MemoryReader* reader = new MusicIO::MemoryReader((const uint8_t*)oggstream, sizebytes);
|
||||
|
||||
SoundDecoder* decoder = SoundDecoder::CreateDecoder(reader);
|
||||
if (!decoder)
|
||||
{
|
||||
reader->close();
|
||||
return samples;
|
||||
}
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
if (chans != ChannelConfig_Mono || type != SampleType_Int16)
|
||||
{
|
||||
delete decoder;
|
||||
return samples;
|
||||
}
|
||||
|
||||
decoder->read((char*)samples, outlen);
|
||||
delete decoder;
|
||||
return samples;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ Callbacks musicCallbacks;
|
|||
|
||||
DLL_EXPORT void ZMusic_SetCallbacks(const Callbacks* cb)
|
||||
{
|
||||
dumb_decode_vorbis = cb->DumbVorbisDecode;
|
||||
musicCallbacks = *cb;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ const char *GME_CheckFormat(uint32_t header);
|
|||
MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader);
|
||||
MusInfo* CD_OpenSong(int track, int id);
|
||||
MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ungzip
|
||||
|
|
|
@ -92,7 +92,7 @@ CUSTOM_CVAR(Float, snd_mastervolume, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
else if (self > 1.f)
|
||||
self = 1.f;
|
||||
|
||||
ChangeMusicSetting(ZMusic::snd_mastervolume, nullptr, self);
|
||||
ChangeMusicSetting(zmusic_snd_mastervolume, nullptr, self);
|
||||
snd_sfxvolume.Callback();
|
||||
snd_musicvolume.Callback();
|
||||
}
|
||||
|
@ -325,36 +325,6 @@ FString SoundRenderer::GatherStats ()
|
|||
return "No stats for this sound renderer.";
|
||||
}
|
||||
|
||||
short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType ctype)
|
||||
{
|
||||
short *samples = (short*)calloc(1, outlen);
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
|
||||
// The decoder will take ownership of the reader if it succeeds so this may not be a local variable.
|
||||
MusicIO::MemoryReader *reader = new MusicIO::MemoryReader((const uint8_t*)coded, sizebytes);
|
||||
|
||||
SoundDecoder *decoder = SoundDecoder::CreateDecoder(reader);
|
||||
if (!decoder)
|
||||
{
|
||||
reader->close();
|
||||
return samples;
|
||||
}
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
if(chans != ChannelConfig_Mono || type != SampleType_Int16)
|
||||
{
|
||||
DPrintf(DMSG_WARNING, "Sample is not 16-bit mono\n");
|
||||
delete decoder;
|
||||
return samples;
|
||||
}
|
||||
|
||||
decoder->read((char*)samples, outlen);
|
||||
delete decoder;
|
||||
return samples;
|
||||
}
|
||||
|
||||
void SoundRenderer::DrawWaveDebug(int mode)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ public:
|
|||
virtual void PrintStatus () = 0;
|
||||
virtual void PrintDriversList () = 0;
|
||||
virtual FString GatherStats ();
|
||||
virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
|
||||
|
||||
virtual void DrawWaveDebug(int mode);
|
||||
};
|
||||
|
|
|
@ -123,7 +123,7 @@ CUSTOM_CVAR (Float, snd_musicvolume, 0.5f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
else
|
||||
{
|
||||
// Set general music volume.
|
||||
ChangeMusicSetting(ZMusic::snd_musicvolume, nullptr, self);
|
||||
ChangeMusicSetting(zmusic_snd_musicvolume, nullptr, self);
|
||||
if (GSnd != nullptr)
|
||||
{
|
||||
GSnd->SetMusicVolume(clamp<float>(self * relative_volume * snd_mastervolume, 0, 1));
|
||||
|
@ -179,16 +179,6 @@ static void wm_printfunc(const char* wmfmt, va_list args)
|
|||
VPrintf(PRINT_HIGH, wmfmt, args);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// other callbacks
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static short* dumb_decode_vorbis_(int outlen, const void* oggstream, int sizebytes)
|
||||
{
|
||||
return GSnd->DecodeSample(outlen, oggstream, sizebytes, CODEC_Vorbis);
|
||||
}
|
||||
|
||||
static std::string mus_NicePath(const char* str)
|
||||
{
|
||||
|
@ -283,7 +273,6 @@ void I_InitMusic (void)
|
|||
callbacks.NicePath = mus_NicePath;
|
||||
callbacks.PathForSoundfont = mus_pathToSoundFont;
|
||||
callbacks.OpenSoundFont = mus_openSoundFont;
|
||||
callbacks.DumbVorbisDecode = dumb_decode_vorbis_;
|
||||
|
||||
ZMusic_SetCallbacks(&callbacks);
|
||||
SetupGenMidi();
|
||||
|
@ -301,7 +290,7 @@ void I_InitMusic (void)
|
|||
void I_SetRelativeVolume(float vol)
|
||||
{
|
||||
relative_volume = (float)vol;
|
||||
ChangeMusicSetting(ZMusic::relative_volume, nullptr, (float)vol);
|
||||
ChangeMusicSetting(zmusic_relative_volume, nullptr, (float)vol);
|
||||
snd_musicvolume.Callback();
|
||||
}
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue