mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
This commit is contained in:
commit
9fc2f805de
25 changed files with 214 additions and 89 deletions
|
@ -1809,7 +1809,6 @@ static const char bar2[] = TEXTCOLOR_RED "\n\35\36\36\36\36\36\36\36\36\36\36\36
|
|||
"\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_GREEN "\n";
|
||||
static const char bar3[] = TEXTCOLOR_RED "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
||||
"\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_NORMAL "\n";
|
||||
static const char logbar[] = "\n<------------------------------->\n";
|
||||
|
||||
void C_MidPrint (FFont *font, const char *msg)
|
||||
{
|
||||
|
|
|
@ -239,7 +239,6 @@ static const char bar2[] = TEXTCOLOR_RED "\35\36\36\36\36\36\36\36\36\36\36\36\3
|
|||
"\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_GREEN "\n";
|
||||
static const char bar3[] = TEXTCOLOR_RED "\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
||||
"\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_NORMAL "\n";
|
||||
static const char logbar[] = "\n<------------------------------->\n";
|
||||
|
||||
void FConsoleBuffer::AddMidText(const char *string, bool bold, FILE *Logfile)
|
||||
{
|
||||
|
|
|
@ -220,6 +220,14 @@ void PClass::StaticInit ()
|
|||
{
|
||||
((ClassReg *)*probe)->RegisterClass ();
|
||||
}
|
||||
probe.Reset();
|
||||
for(auto cls : AllClasses)
|
||||
{
|
||||
if (cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
PClassActor::AllActorClasses.Push(static_cast<PClassActor*>(cls));
|
||||
}
|
||||
}
|
||||
|
||||
// Keep built-in classes in consistant order. I did this before, though
|
||||
// I'm not sure if this is really necessary to maintain any sort of sync.
|
||||
|
@ -344,7 +352,7 @@ PClass *ClassReg::RegisterClass()
|
|||
PClass *cls = new PClass;
|
||||
|
||||
SetupClass(cls);
|
||||
cls->InsertIntoHash();
|
||||
cls->InsertIntoHash(true);
|
||||
if (ParentType != nullptr)
|
||||
{
|
||||
cls->ParentClass = ParentType->RegisterClass();
|
||||
|
@ -379,7 +387,7 @@ void ClassReg::SetupClass(PClass *cls)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClass::InsertIntoHash ()
|
||||
void PClass::InsertIntoHash (bool native)
|
||||
{
|
||||
auto k = ClassMap.CheckKey(TypeName);
|
||||
if (k != nullptr)
|
||||
|
@ -390,7 +398,7 @@ void PClass::InsertIntoHash ()
|
|||
{
|
||||
ClassMap[TypeName] = this;
|
||||
}
|
||||
if (IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
if (!native && IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||
{
|
||||
PClassActor::AllActorClasses.Push(static_cast<PClassActor*>(this));
|
||||
}
|
||||
|
@ -690,7 +698,7 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size)
|
|||
|
||||
if (!notnew)
|
||||
{
|
||||
type->InsertIntoHash();
|
||||
type->InsertIntoHash(false);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
@ -759,7 +767,7 @@ PClass *PClass::FindClassTentative(FName name)
|
|||
Derive(type, name);
|
||||
type->Size = TentativeClass;
|
||||
|
||||
type->InsertIntoHash();
|
||||
type->InsertIntoHash(false);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
// The rest are all functions and static data ----------------
|
||||
PClass();
|
||||
~PClass();
|
||||
void InsertIntoHash();
|
||||
void InsertIntoHash(bool native);
|
||||
DObject *CreateNew();
|
||||
PClass *CreateDerivedClass(FName name, unsigned int size);
|
||||
|
||||
|
|
|
@ -130,8 +130,6 @@ void gl_PatchMenu()
|
|||
|
||||
void gl_SetTextureMode(int type)
|
||||
{
|
||||
static float white[] = {1.f,1.f,1.f,1.f};
|
||||
|
||||
if (type == TM_MASK)
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
|
|
@ -66,7 +66,7 @@ CVAR(Int, gl_breaksec, -1, 0)
|
|||
// information
|
||||
//
|
||||
//==========================================================================
|
||||
static float tics;
|
||||
|
||||
void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture)
|
||||
{
|
||||
// only manipulate the texture matrix if needed.
|
||||
|
|
|
@ -310,8 +310,6 @@ inline void GLPortal::ClearClipper()
|
|||
|
||||
drawer->clipper.Clear();
|
||||
|
||||
static int call=0;
|
||||
|
||||
// Set the clipper to the minimal visible area
|
||||
drawer->clipper.SafeAddClipRange(0,0xffffffff);
|
||||
for (unsigned int i = 0; i < lines.Size(); i++)
|
||||
|
|
|
@ -8869,7 +8869,6 @@ scriptwait:
|
|||
{
|
||||
static const char bar[] = TEXTCOLOR_ORANGE "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
||||
"\36\36\36\36\36\36\36\36\36\36\36\36\37" TEXTCOLOR_NORMAL "\n";
|
||||
static const char logbar[] = "\n<------------------------------->\n";
|
||||
char consolecolor[3];
|
||||
|
||||
consolecolor[0] = '\x1c';
|
||||
|
|
|
@ -126,7 +126,7 @@ extern float S_GetMusicVolume (const char *music);
|
|||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
static void S_LoadSound3D(sfxinfo_t *sfx);
|
||||
static void S_LoadSound3D(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer);
|
||||
static bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range, AActor *actor, int channel);
|
||||
static bool S_IsChannelUsed(AActor *actor, int channel, int *seen);
|
||||
static void S_ActivatePlayList(bool goBack);
|
||||
|
@ -577,7 +577,10 @@ void S_CacheSound (sfxinfo_t *sfx)
|
|||
}
|
||||
else
|
||||
{
|
||||
S_LoadSound(sfx);
|
||||
// Since we do not know in what format the sound will be used, we have to cache both.
|
||||
FSoundLoadBuffer SoundBuffer;
|
||||
S_LoadSound(sfx, &SoundBuffer);
|
||||
S_LoadSound3D(sfx, &SoundBuffer);
|
||||
sfx->bUsed = true;
|
||||
}
|
||||
}
|
||||
|
@ -906,6 +909,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
|
|||
FSoundChan *chan;
|
||||
FVector3 pos, vel;
|
||||
FRolloffInfo *rolloff;
|
||||
FSoundLoadBuffer SoundBuffer;
|
||||
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || nosound )
|
||||
return NULL;
|
||||
|
@ -1050,7 +1054,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
|
|||
}
|
||||
|
||||
// Make sure the sound is loaded.
|
||||
sfx = S_LoadSound(sfx);
|
||||
sfx = S_LoadSound(sfx, &SoundBuffer);
|
||||
|
||||
// The empty sound never plays.
|
||||
if (sfx->lumpnum == sfx_empty)
|
||||
|
@ -1150,7 +1154,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
|
|||
|
||||
if (attenuation > 0)
|
||||
{
|
||||
S_LoadSound3D(sfx);
|
||||
S_LoadSound3D(sfx, &SoundBuffer);
|
||||
SoundListener listener;
|
||||
S_SetListener(listener, players[consoleplayer].camera);
|
||||
chan = (FSoundChan*)GSnd->StartSound3D (sfx->data3d, &listener, float(volume), rolloff, float(attenuation), pitch, basepriority, pos, vel, channel, startflags, NULL);
|
||||
|
@ -1213,12 +1217,13 @@ void S_RestartSound(FSoundChan *chan)
|
|||
|
||||
FSoundChan *ochan;
|
||||
sfxinfo_t *sfx = &S_sfx[chan->SoundID];
|
||||
FSoundLoadBuffer SoundBuffer;
|
||||
|
||||
// If this is a singular sound, don't play it if it's already playing.
|
||||
if (sfx->bSingular && S_CheckSingular(chan->SoundID))
|
||||
return;
|
||||
|
||||
sfx = S_LoadSound(sfx);
|
||||
sfx = S_LoadSound(sfx, &SoundBuffer);
|
||||
|
||||
// The empty sound never plays.
|
||||
if (sfx->lumpnum == sfx_empty)
|
||||
|
@ -1247,7 +1252,7 @@ void S_RestartSound(FSoundChan *chan)
|
|||
return;
|
||||
}
|
||||
|
||||
S_LoadSound3D(sfx);
|
||||
S_LoadSound3D(sfx, &SoundBuffer);
|
||||
SoundListener listener;
|
||||
S_SetListener(listener, players[consoleplayer].camera);
|
||||
|
||||
|
@ -1392,7 +1397,7 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
|
||||
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer)
|
||||
{
|
||||
if (GSnd->IsNull()) return sfx;
|
||||
|
||||
|
@ -1452,7 +1457,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
|
|||
// If that fails, let the sound system try and figure it out.
|
||||
else
|
||||
{
|
||||
snd = GSnd->LoadSound(sfxdata, size);
|
||||
snd = GSnd->LoadSound(sfxdata, size, false, pBuffer);
|
||||
}
|
||||
delete[] sfxdata;
|
||||
|
||||
|
@ -1474,7 +1479,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx)
|
|||
return sfx;
|
||||
}
|
||||
|
||||
static void S_LoadSound3D(sfxinfo_t *sfx)
|
||||
static void S_LoadSound3D(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer)
|
||||
{
|
||||
if (GSnd->IsNull()) return;
|
||||
|
||||
|
@ -1483,40 +1488,47 @@ static void S_LoadSound3D(sfxinfo_t *sfx)
|
|||
|
||||
DPrintf(DMSG_NOTIFY, "Loading monoized sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
|
||||
|
||||
int size = Wads.LumpLength(sfx->lumpnum);
|
||||
if(size <= 0) return;
|
||||
if (pBuffer->mBuffer.Size() > 0)
|
||||
{
|
||||
GSnd->LoadSoundBuffered(pBuffer, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int size = Wads.LumpLength(sfx->lumpnum);
|
||||
if (size <= 0) return;
|
||||
|
||||
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
|
||||
uint8_t *sfxdata = new uint8_t[size];
|
||||
wlump.Read(sfxdata, size);
|
||||
int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
|
||||
std::pair<SoundHandle,bool> snd;
|
||||
FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum);
|
||||
uint8_t *sfxdata = new uint8_t[size];
|
||||
wlump.Read(sfxdata, size);
|
||||
int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]);
|
||||
std::pair<SoundHandle, bool> snd;
|
||||
|
||||
// If the sound is voc, use the custom loader.
|
||||
if (strncmp ((const char *)sfxdata, "Creative Voice File", 19) == 0)
|
||||
{
|
||||
snd = GSnd->LoadSoundVoc(sfxdata, size, true);
|
||||
}
|
||||
// If the sound is raw, just load it as such.
|
||||
else if (sfx->bLoadRAW)
|
||||
{
|
||||
snd = GSnd->LoadSoundRaw(sfxdata, size, sfx->RawRate, 1, 8, sfx->LoopStart, true);
|
||||
}
|
||||
// Otherwise, try the sound as DMX format.
|
||||
else if (((uint8_t *)sfxdata)[0] == 3 && ((uint8_t *)sfxdata)[1] == 0 && dmxlen <= size - 8)
|
||||
{
|
||||
int frequency = LittleShort(((uint16_t *)sfxdata)[1]);
|
||||
if (frequency == 0) frequency = 11025;
|
||||
snd = GSnd->LoadSoundRaw(sfxdata+8, dmxlen, frequency, 1, 8, sfx->LoopStart, -1, true);
|
||||
}
|
||||
// If that fails, let the sound system try and figure it out.
|
||||
else
|
||||
{
|
||||
snd = GSnd->LoadSound(sfxdata, size, true);
|
||||
}
|
||||
delete[] sfxdata;
|
||||
// If the sound is voc, use the custom loader.
|
||||
if (strncmp((const char *)sfxdata, "Creative Voice File", 19) == 0)
|
||||
{
|
||||
snd = GSnd->LoadSoundVoc(sfxdata, size, true);
|
||||
}
|
||||
// If the sound is raw, just load it as such.
|
||||
else if (sfx->bLoadRAW)
|
||||
{
|
||||
snd = GSnd->LoadSoundRaw(sfxdata, size, sfx->RawRate, 1, 8, sfx->LoopStart, true);
|
||||
}
|
||||
// Otherwise, try the sound as DMX format.
|
||||
else if (((uint8_t *)sfxdata)[0] == 3 && ((uint8_t *)sfxdata)[1] == 0 && dmxlen <= size - 8)
|
||||
{
|
||||
int frequency = LittleShort(((uint16_t *)sfxdata)[1]);
|
||||
if (frequency == 0) frequency = 11025;
|
||||
snd = GSnd->LoadSoundRaw(sfxdata + 8, dmxlen, frequency, 1, 8, sfx->LoopStart, -1, true);
|
||||
}
|
||||
// If that fails, let the sound system try and figure it out.
|
||||
else
|
||||
{
|
||||
snd = GSnd->LoadSound(sfxdata, size, true, pBuffer);
|
||||
}
|
||||
delete[] sfxdata;
|
||||
|
||||
sfx->data3d = snd.first;
|
||||
sfx->data3d = snd.first;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -212,6 +212,7 @@ struct FSoundChan : public FISoundChannel
|
|||
float Point[3]; // Sound is not attached to any source.
|
||||
};
|
||||
};
|
||||
|
||||
extern FSoundChan *Channels;
|
||||
|
||||
void S_ReturnChannel(FSoundChan *chan);
|
||||
|
@ -299,6 +300,7 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool
|
|||
#define ATTN_IDLE 1.001f
|
||||
#define ATTN_STATIC 3.f // diminish very rapidly with distance
|
||||
|
||||
struct FSoundLoadBuffer;
|
||||
int S_PickReplacement (int refid);
|
||||
void S_CacheRandomSound (sfxinfo_t *sfx);
|
||||
|
||||
|
@ -384,7 +386,7 @@ int S_AddPlayerSoundExisting (const char *playerclass, const int gender, int ref
|
|||
void S_MarkPlayerSounds (const char *playerclass);
|
||||
void S_ShrinkPlayerSoundLists ();
|
||||
void S_UnloadSound (sfxinfo_t *sfx);
|
||||
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx);
|
||||
sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer = nullptr);
|
||||
unsigned int S_GetMSLength(FSoundID sound);
|
||||
void S_ParseMusInfo();
|
||||
bool S_ParseTimeTag(const char *tag, bool *as_samples, unsigned int *time);
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
void SetMusicVolume (float volume)
|
||||
{
|
||||
}
|
||||
std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize)
|
||||
std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize, FSoundLoadBuffer *pBuffer)
|
||||
{
|
||||
SoundHandle retval = { NULL };
|
||||
return std::make_pair(retval, true);
|
||||
|
@ -576,6 +576,12 @@ std::pair<SoundHandle,bool> SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int le
|
|||
return retval;
|
||||
}
|
||||
|
||||
std::pair<SoundHandle, bool> SoundRenderer::LoadSoundBuffered(FSoundLoadBuffer *buffer, bool monoize)
|
||||
{
|
||||
SoundHandle retval = { NULL };
|
||||
return std::make_pair(retval, true);
|
||||
}
|
||||
|
||||
SoundDecoder *SoundRenderer::CreateDecoder(FileReader *reader)
|
||||
{
|
||||
SoundDecoder *decoder = NULL;
|
||||
|
@ -604,14 +610,14 @@ SoundDecoder *SoundRenderer::CreateDecoder(FileReader *reader)
|
|||
|
||||
|
||||
// Default readAll implementation, for decoders that can't do anything better
|
||||
TArray<char> SoundDecoder::readAll()
|
||||
TArray<uint8_t> SoundDecoder::readAll()
|
||||
{
|
||||
TArray<char> output;
|
||||
TArray<uint8_t> output;
|
||||
unsigned total = 0;
|
||||
unsigned got;
|
||||
|
||||
output.Resize(total+32768);
|
||||
while((got=(unsigned)read(&output[total], output.Size()-total)) > 0)
|
||||
while((got=(unsigned)read((char*)&output[total], output.Size()-total)) > 0)
|
||||
{
|
||||
total += got;
|
||||
output.Resize(total*2);
|
||||
|
|
|
@ -87,6 +87,16 @@ typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, vo
|
|||
struct SoundDecoder;
|
||||
class MIDIDevice;
|
||||
|
||||
struct FSoundLoadBuffer
|
||||
{
|
||||
TArray<uint8_t> mBuffer;
|
||||
uint32_t loop_start;
|
||||
uint32_t loop_end;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
int srate;
|
||||
};
|
||||
|
||||
class SoundRenderer
|
||||
{
|
||||
public:
|
||||
|
@ -97,9 +107,10 @@ public:
|
|||
virtual void SetSfxVolume (float volume) = 0;
|
||||
virtual void SetMusicVolume (float volume) = 0;
|
||||
// Returns a pair containing a sound handle and a boolean indicating the sound can be used in 3D.
|
||||
virtual std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize=false) = 0;
|
||||
virtual std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize=false, FSoundLoadBuffer *pBuffer = nullptr) = 0;
|
||||
std::pair<SoundHandle,bool> LoadSoundVoc(uint8_t *sfxdata, int length, bool monoize=false);
|
||||
virtual std::pair<SoundHandle,bool> LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1, bool monoize = false) = 0;
|
||||
virtual std::pair<SoundHandle, bool> LoadSoundBuffered(FSoundLoadBuffer *buffer, bool monoize);
|
||||
virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory
|
||||
virtual unsigned int GetMSLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
|
||||
virtual unsigned int GetSampleLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency
|
||||
|
|
|
@ -131,7 +131,7 @@ struct SoundDecoder
|
|||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes) = 0;
|
||||
virtual TArray<char> readAll();
|
||||
virtual TArray<uint8_t> readAll();
|
||||
virtual bool seek(size_t ms_offset, bool ms, bool mayrestart) = 0;
|
||||
virtual size_t getSampleOffset() = 0;
|
||||
virtual size_t getSampleLength() { return 0; }
|
||||
|
|
|
@ -333,8 +333,8 @@ bool SndFileSong::Read(SoundStream *stream, void *vbuff, int ilen, void *userdat
|
|||
size_t endlen = song->Decoder->read(buff, endblock);
|
||||
if (endlen != 0)
|
||||
{
|
||||
buff = buff + endblock;
|
||||
len -= endblock;
|
||||
buff = buff + endlen;
|
||||
len -= endlen;
|
||||
song->Decoder->seek(song->Loop_Start, false, true);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1205,7 +1205,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata,
|
|||
|
||||
void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass);
|
||||
|
||||
std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length, bool monoize)
|
||||
std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int length, bool monoize, FSoundLoadBuffer *pBuffer)
|
||||
{
|
||||
SoundHandle retval = { NULL };
|
||||
MemoryReader reader((const char*)sfxdata, length);
|
||||
|
@ -1223,29 +1223,30 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
|||
}
|
||||
|
||||
std::unique_ptr<SoundDecoder> decoder(CreateDecoder(&reader));
|
||||
if(!decoder) return std::make_pair(retval, true);
|
||||
if (!decoder) return std::make_pair(retval, true);
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
int samplesize = 1;
|
||||
if(chans == ChannelConfig_Mono || monoize)
|
||||
if (chans == ChannelConfig_Mono || monoize)
|
||||
{
|
||||
if(type == SampleType_UInt8) format = AL_FORMAT_MONO8, samplesize = 1;
|
||||
if(type == SampleType_Int16) format = AL_FORMAT_MONO16, samplesize = 2;
|
||||
if (type == SampleType_UInt8) format = AL_FORMAT_MONO8, samplesize = 1;
|
||||
if (type == SampleType_Int16) format = AL_FORMAT_MONO16, samplesize = 2;
|
||||
}
|
||||
else if(chans == ChannelConfig_Stereo)
|
||||
else if (chans == ChannelConfig_Stereo)
|
||||
{
|
||||
if(type == SampleType_UInt8) format = AL_FORMAT_STEREO8, samplesize = 2;
|
||||
if(type == SampleType_Int16) format = AL_FORMAT_STEREO16, samplesize = 4;
|
||||
if (type == SampleType_UInt8) format = AL_FORMAT_STEREO8, samplesize = 2;
|
||||
if (type == SampleType_Int16) format = AL_FORMAT_STEREO16, samplesize = 4;
|
||||
}
|
||||
|
||||
if(format == AL_NONE)
|
||||
if (format == AL_NONE)
|
||||
{
|
||||
Printf("Unsupported audio format: %s, %s\n", GetChannelConfigName(chans),
|
||||
GetSampleTypeName(type));
|
||||
GetSampleTypeName(type));
|
||||
return std::make_pair(retval, true);
|
||||
}
|
||||
|
||||
TArray<char> data = decoder->readAll();
|
||||
TArray<uint8_t> data = decoder->readAll();
|
||||
|
||||
if(chans != ChannelConfig_Mono && monoize)
|
||||
{
|
||||
size_t chancount = GetChannelCount(chans);
|
||||
|
@ -1289,7 +1290,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
|||
}
|
||||
|
||||
if (!startass) loop_start = Scale(loop_start, srate, 1000);
|
||||
if (!endass) loop_end = Scale(loop_end, srate, 1000);
|
||||
if (!endass && loop_end != ~0u) loop_end = Scale(loop_end, srate, 1000);
|
||||
const uint32_t samples = data.Size() / samplesize;
|
||||
if (loop_start > samples) loop_start = 0;
|
||||
if (loop_end > samples) loop_end = samples;
|
||||
|
@ -1302,6 +1303,98 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
|||
// no console messages here, please!
|
||||
}
|
||||
|
||||
retval.data = MAKE_PTRID(buffer);
|
||||
if (pBuffer != nullptr)
|
||||
{
|
||||
pBuffer->mBuffer = std::move(data);
|
||||
pBuffer->loop_start = loop_start;
|
||||
pBuffer->loop_end = loop_end;
|
||||
pBuffer->chans = chans;
|
||||
pBuffer->type = type;
|
||||
pBuffer->srate = srate;
|
||||
}
|
||||
return std::make_pair(retval, (chans == ChannelConfig_Mono || monoize));
|
||||
}
|
||||
|
||||
std::pair<SoundHandle, bool> OpenALSoundRenderer::LoadSoundBuffered(FSoundLoadBuffer *pBuffer, bool monoize)
|
||||
{
|
||||
SoundHandle retval = { NULL };
|
||||
ALenum format = AL_NONE;
|
||||
int srate = pBuffer->srate;
|
||||
auto type = pBuffer->type;
|
||||
auto chans = pBuffer->chans;
|
||||
uint32_t loop_start = pBuffer->loop_start, loop_end = pBuffer->loop_end;
|
||||
|
||||
if (chans == ChannelConfig_Mono || monoize)
|
||||
{
|
||||
if (type == SampleType_UInt8) format = AL_FORMAT_MONO8;
|
||||
if (type == SampleType_Int16) format = AL_FORMAT_MONO16;
|
||||
}
|
||||
else if (chans == ChannelConfig_Stereo)
|
||||
{
|
||||
if (type == SampleType_UInt8) format = AL_FORMAT_STEREO8;
|
||||
if (type == SampleType_Int16) format = AL_FORMAT_STEREO16;
|
||||
}
|
||||
|
||||
if (format == AL_NONE)
|
||||
{
|
||||
Printf("Unsupported audio format: %s, %s\n", GetChannelConfigName(chans),
|
||||
GetSampleTypeName(type));
|
||||
return std::make_pair(retval, true);
|
||||
}
|
||||
|
||||
TArray<uint8_t> &data = pBuffer->mBuffer;
|
||||
|
||||
if (pBuffer->chans == ChannelConfig_Stereo && monoize)
|
||||
{
|
||||
size_t chancount = GetChannelCount(chans);
|
||||
size_t frames = data.Size() / chancount /
|
||||
(type == SampleType_Int16 ? 2 : 1);
|
||||
if (type == SampleType_Int16)
|
||||
{
|
||||
short *sfxdata = (short*)&data[0];
|
||||
for (size_t i = 0; i < frames; i++)
|
||||
{
|
||||
int sum = 0;
|
||||
for (size_t c = 0; c < chancount; c++)
|
||||
sum += sfxdata[i*chancount + c];
|
||||
sfxdata[i] = short(sum / chancount);
|
||||
}
|
||||
}
|
||||
else if (type == SampleType_UInt8)
|
||||
{
|
||||
uint8_t *sfxdata = (uint8_t*)&data[0];
|
||||
for (size_t i = 0; i < frames; i++)
|
||||
{
|
||||
int sum = 0;
|
||||
for (size_t c = 0; c < chancount; c++)
|
||||
sum += sfxdata[i*chancount + c] - 128;
|
||||
sfxdata[i] = uint8_t((sum / chancount) + 128);
|
||||
}
|
||||
}
|
||||
data.Resize(unsigned(data.Size() / chancount));
|
||||
}
|
||||
|
||||
ALenum err;
|
||||
ALuint buffer = 0;
|
||||
alGenBuffers(1, &buffer);
|
||||
alBufferData(buffer, format, &data[0], data.Size(), srate);
|
||||
if ((err = getALError()) != AL_NO_ERROR)
|
||||
{
|
||||
Printf("Failed to buffer data: %s\n", alGetString(err));
|
||||
alDeleteBuffers(1, &buffer);
|
||||
getALError();
|
||||
return std::make_pair(retval, true);
|
||||
}
|
||||
|
||||
// the loop points were already validated by the previous load.
|
||||
if ((loop_start > 0 || loop_end > 0) && loop_end > loop_start && AL.SOFT_loop_points)
|
||||
{
|
||||
ALint loops[2] = { static_cast<ALint>(loop_start), static_cast<ALint>(loop_end) };
|
||||
DPrintf(DMSG_NOTIFY, "Setting loop points %d -> %d\n", loops[0], loops[1]);
|
||||
alBufferiv(buffer, AL_LOOP_POINTS_SOFT, loops);
|
||||
// no console messages here, please!
|
||||
}
|
||||
|
||||
retval.data = MAKE_PTRID(buffer);
|
||||
return std::make_pair(retval, (chans == ChannelConfig_Mono || monoize));
|
||||
|
|
|
@ -87,7 +87,8 @@ public:
|
|||
|
||||
virtual void SetSfxVolume(float volume);
|
||||
virtual void SetMusicVolume(float volume);
|
||||
virtual std::pair<SoundHandle,bool> LoadSound(uint8_t *sfxdata, int length, bool monoize);
|
||||
virtual std::pair<SoundHandle, bool> LoadSound(uint8_t *sfxdata, int length, bool monoize, FSoundLoadBuffer *buffer);
|
||||
virtual std::pair<SoundHandle,bool> LoadSoundBuffered(FSoundLoadBuffer *buffer, bool monoize);
|
||||
virtual std::pair<SoundHandle,bool> LoadSoundRaw(uint8_t *sfxdata, int length, int frequency, int channels, int bits, int loopstart, int loopend = -1, bool monoize = false);
|
||||
virtual void UnloadSound(SoundHandle sfx);
|
||||
virtual unsigned int GetMSLength(SoundHandle sfx);
|
||||
|
|
|
@ -175,16 +175,16 @@ size_t SndFileDecoder::read(char *buffer, size_t bytes)
|
|||
return total * SndInfo.channels * 2;
|
||||
}
|
||||
|
||||
TArray<char> SndFileDecoder::readAll()
|
||||
TArray<uint8_t> SndFileDecoder::readAll()
|
||||
{
|
||||
if(SndInfo.frames <= 0)
|
||||
return SoundDecoder::readAll();
|
||||
|
||||
int framesize = 2 * SndInfo.channels;
|
||||
TArray<char> output;
|
||||
TArray<uint8_t> output;
|
||||
|
||||
output.Resize((unsigned)(SndInfo.frames * framesize));
|
||||
size_t got = read(&output[0], output.Size());
|
||||
size_t got = read((char*)&output[0], output.Size());
|
||||
output.Resize((unsigned)got);
|
||||
|
||||
return output;
|
||||
|
|
|
@ -16,7 +16,7 @@ struct SndFileDecoder : public SoundDecoder
|
|||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes);
|
||||
virtual TArray<char> readAll();
|
||||
virtual TArray<uint8_t> readAll();
|
||||
virtual bool seek(size_t ms_offset, bool ms, bool mayrestart);
|
||||
virtual size_t getSampleOffset();
|
||||
virtual size_t getSampleLength();
|
||||
|
|
|
@ -113,7 +113,6 @@ static const char hexits[16] = {'0','1','2','3','4','5','6','7','8','9','a','b',
|
|||
static const char HEXits[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
static const char spaces[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
|
||||
static const char zeroes[17] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','.'};
|
||||
static const char dotchar = '.';
|
||||
|
||||
namespace StringFormat
|
||||
{
|
||||
|
|
|
@ -1244,7 +1244,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
|
|||
{
|
||||
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
|
||||
|
||||
int Selection = GetSliderValue();
|
||||
int Selection = int(GetSliderValue());
|
||||
if ((Selection == 0 || Selection == -1) && mClickVal <= 0)
|
||||
{
|
||||
String text = Selection == 0? TextZero : Selection == -1? TextNegOne : "";
|
||||
|
@ -1260,7 +1260,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
|
|||
|
||||
override bool MouseEvent(int type, int x, int y)
|
||||
{
|
||||
int value = GetSliderValue();
|
||||
int value = int(GetSliderValue());
|
||||
switch (type)
|
||||
{
|
||||
case Menu.MOUSE_Click:
|
||||
|
|
|
@ -192,7 +192,7 @@ class StatusScreen abstract play version("2.5")
|
|||
{
|
||||
let size = TexMan.GetScaledSize(pinfo.mPatch);
|
||||
screen.DrawTexture(pinfo.mPatch, true, midx - size.X * CleanXfac/2, y, DTA_CleanNoMove, true);
|
||||
return y + (size.Y * CleanYfac);
|
||||
return y + int(size.Y * CleanYfac);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -221,7 +221,7 @@ class CoopStatusScreen : StatusScreen
|
|||
// Use the readyico height if it's bigger.
|
||||
Vector2 readysize = TexMan.GetScaledSize(readyico);
|
||||
Vector2 readyoffset = TexMan.GetScaledOffset(readyico);
|
||||
height = readysize.Y - readyoffset.Y;
|
||||
height = int(readysize.Y - readyoffset.Y);
|
||||
maxiconheight = MAX(height, maxiconheight);
|
||||
height = SmallFont.GetHeight() * CleanYfac;
|
||||
lineheight = MAX(height, maxiconheight * CleanYfac);
|
||||
|
|
|
@ -158,7 +158,7 @@ class DeathmatchStatusScreen : StatusScreen
|
|||
// Use the readyico height if it's bigger.
|
||||
Vector2 readysize = TexMan.GetScaledSize(readyico);
|
||||
Vector2 readyoffset = TexMan.GetScaledOffset(readyico);
|
||||
height = readysize.Y - readyoffset.Y;
|
||||
height = int(readysize.Y - readyoffset.Y);
|
||||
maxiconheight = MAX(height, maxiconheight);
|
||||
height = SmallFont.GetHeight() * CleanYfac;
|
||||
lineheight = MAX(height, maxiconheight * CleanYfac);
|
||||
|
|
|
@ -774,9 +774,9 @@ class BaseStatusBar native ui
|
|||
}
|
||||
|
||||
String mapname = level.FormatMapName(crdefault);
|
||||
BrokenLines lines = SmallFont.BreakLines(mapname, SCREENWIDTH / scale.X);
|
||||
BrokenLines lines = SmallFont.BreakLines(mapname, int(SCREENWIDTH / scale.X));
|
||||
int numlines = lines.Count();
|
||||
int finalwidth = SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X;
|
||||
int finalwidth = int(SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X);
|
||||
|
||||
// calculate the top of the statusbar including any protrusion and transform it from status bar to screen space.
|
||||
double tmp, hres;
|
||||
|
|
|
@ -266,7 +266,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
{
|
||||
double tmp, h;
|
||||
[tmp, tmp, h] = StatusbarToRealCoords(0, 0, 8);
|
||||
DrawPopScreen (GetTopOfStatusBar() - h, TicFrac);
|
||||
DrawPopScreen (int(GetTopOfStatusBar() - h), TicFrac);
|
||||
}
|
||||
|
||||
DrawImage("INVBACK", (0, 168), DI_ITEM_OFFSETS);
|
||||
|
|
Loading…
Reference in a new issue