mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-12 21:31:57 +00:00
Move the generic DecodeSample implementation to the base class
This commit is contained in:
parent
72ddc0d935
commit
9f493fca5f
3 changed files with 19 additions and 24 deletions
|
@ -48,6 +48,7 @@ extern HINSTANCE g_hInst;
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
|
||||
#include "doomtype.h"
|
||||
#include <math.h>
|
||||
|
@ -338,9 +339,25 @@ FString SoundRenderer::GatherStats ()
|
|||
return "No stats for this sound renderer.";
|
||||
}
|
||||
|
||||
short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type)
|
||||
short *SoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType ctype)
|
||||
{
|
||||
return NULL;
|
||||
short *samples = (short*)calloc(1, outlen);
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
|
||||
std::auto_ptr<SoundDecoder> decoder(CreateDecoder((const BYTE*)coded, sizebytes));
|
||||
if(!decoder.get()) return samples;
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
if(chans != ChannelConfig_Mono || type != SampleType_Int16)
|
||||
{
|
||||
DPrintf("Sample is not 16-bit mono\n");
|
||||
return samples;
|
||||
}
|
||||
|
||||
decoder->read((char*)samples, outlen);
|
||||
return samples;
|
||||
}
|
||||
|
||||
void SoundRenderer::DrawWaveDebug(int mode)
|
||||
|
|
|
@ -1053,26 +1053,6 @@ void OpenALSoundRenderer::UnloadSound(SoundHandle sfx)
|
|||
delete ((ALuint*)sfx.data);
|
||||
}
|
||||
|
||||
short *OpenALSoundRenderer::DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType ctype)
|
||||
{
|
||||
char *samples = (char*)calloc(1, outlen);
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
|
||||
std::auto_ptr<SoundDecoder> decoder(CreateDecoder((const BYTE*)coded, sizebytes));
|
||||
if(!decoder.get()) return (short*)samples;
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
if(chans != ChannelConfig_Mono || type != SampleType_Int16)
|
||||
{
|
||||
DPrintf("Sample is not 16-bit mono\n");
|
||||
return (short*)samples;
|
||||
}
|
||||
|
||||
decoder->read(samples, outlen);
|
||||
return (short*)samples;
|
||||
}
|
||||
|
||||
SoundStream *OpenALSoundRenderer::CreateStream(SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)
|
||||
{
|
||||
|
|
|
@ -112,8 +112,6 @@ public:
|
|||
virtual void UpdateListener(SoundListener *);
|
||||
virtual void UpdateSounds();
|
||||
|
||||
virtual short *DecodeSample(int outlen, const void *coded, int sizebytes, ECodecType type);
|
||||
|
||||
virtual void MarkStartTime(FISoundChannel*);
|
||||
virtual float GetAudibility(FISoundChannel*);
|
||||
|
||||
|
|
Loading…
Reference in a new issue