mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- some progress with sound. Still glitchy.
This commit is contained in:
parent
928a16983d
commit
75e8a71905
4 changed files with 10 additions and 7 deletions
|
@ -97,7 +97,7 @@ static std::unique_ptr<SoundStream> musicStream;
|
|||
|
||||
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata)
|
||||
{
|
||||
int flags = SoundStream::Float;
|
||||
int flags = 0;
|
||||
if (numchannels < 2) flags |= SoundStream::Mono;
|
||||
auto stream = GSnd->CreateStream(cb, size, flags, samplerate, userdata);
|
||||
if (stream) stream->Play(true, 1);
|
||||
|
|
|
@ -103,21 +103,24 @@ static int ClipRange(int val, int min, int max)
|
|||
static bool StreamCallbackFunc(SoundStream* stream, void* buff, int len, void* userdata)
|
||||
{
|
||||
InterplayDecoder* pId = (InterplayDecoder*)userdata;
|
||||
uint8_t* buf = (uint8_t*)buff;
|
||||
int16_t* buf = (int16_t*)buff;
|
||||
len /= 2; // we're copying 16 bit values.
|
||||
while (len > 0)
|
||||
{
|
||||
uint32_t nSize = pId->audio.block[pId->audio.nRead].size;
|
||||
auto ptr = (uint8_t*)pId->audio.block[pId->audio.nRead].buf;
|
||||
auto ptr = pId->audio.block[pId->audio.nRead].buf;
|
||||
auto copyofs = pId->audio.nSubIndex;
|
||||
auto copylen = std::min<unsigned>(len, nSize - copyofs);
|
||||
memcpy(buf, ptr, copylen);
|
||||
for(int i=0;i<copylen;i++) *buf++ = *ptr++;
|
||||
// memcpy(buf, ptr, copylen*2);
|
||||
pId->audio.nSubIndex += copylen;
|
||||
buf += copylen;
|
||||
len -= copylen;
|
||||
if (pId->audio.nSubIndex == nSize)
|
||||
{
|
||||
pId->audio.nSubIndex = 0;
|
||||
pId->audio.nRead++;
|
||||
if (pId->audio.nRead >= InterplayDecoder::kAudioBlocks) pId->audio.nRead = 0;
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
class InterplayDecoder
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CHUNK_PREAMBLE_SIZE = 4,
|
||||
|
@ -97,7 +98,6 @@ class InterplayDecoder
|
|||
kAudioBlocks = 20 // alloc a lot of blocks - need to store lots of audio data before video frames start.
|
||||
};
|
||||
|
||||
public:
|
||||
InterplayDecoder();
|
||||
~InterplayDecoder();
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ public:
|
|||
twod->ClearScreen();
|
||||
DrawTexture(twod, decoder.animTex().GetFrame(), 0, 0, DTA_FullscreenEx, 3, TAG_DONE);
|
||||
|
||||
return skiprequest ? -1 : playon ? 1 : 0;
|
||||
return /* skiprequest ? -1 :*/ playon ? 1 : 0;
|
||||
}
|
||||
|
||||
void OnDestroy() override
|
||||
|
|
Loading…
Reference in a new issue