dquakeplus' snd_mix.c

This commit is contained in:
cypress 2024-09-05 18:10:13 -07:00
parent 7d66725bab
commit 142407d4af

View file

@ -34,8 +34,7 @@ void Snd_WriteLinearBlastStereo16 (void);
#if !id386
void Snd_WriteLinearBlastStereo16 (void)
{
int i;
int val;
int i, val;
for (i=0 ; i<snd_linear_count ; i+=2)
{
@ -60,48 +59,14 @@ void Snd_WriteLinearBlastStereo16 (void)
void S_TransferStereo16 (int endtime)
{
int lpos;
int lpaintedtime;
int lpos, lpaintedtime;
DWORD *pbuf;
#ifdef _WIN32
int reps;
DWORD dwSize,dwSize2;
DWORD *pbuf2;
HRESULT hresult;
#endif
snd_vol = volume.value*256;
snd_p = (int *) paintbuffer;
lpaintedtime = paintedtime;
#ifdef _WIN32
if (pDSBuf)
{
reps = 0;
while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &dwSize,
&pbuf2, &dwSize2, 0)) != DS_OK)
{
if (hresult != DSERR_BUFFERLOST)
{
Con_Printf ("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");
S_Shutdown ();
S_Startup ();
return;
}
if (++reps > 10000)
{
Con_Printf ("S_TransferStereo16: DS: couldn't restore buffer\n");
S_Shutdown ();
S_Startup ();
return;
}
}
}
else
#endif
{
pbuf = (DWORD *)shm->buffer;
}
@ -125,29 +90,12 @@ void S_TransferStereo16 (int endtime)
snd_p += snd_linear_count;
lpaintedtime += (snd_linear_count>>1);
}
#ifdef _WIN32
if (pDSBuf)
pDSBuf->lpVtbl->Unlock(pDSBuf, pbuf, dwSize, NULL, 0);
#endif
}
void S_TransferPaintBuffer(int endtime)
{
int out_idx;
int count;
int out_mask;
int *p;
int step;
int val;
int snd_vol;
int out_idx, count, out_mask, *p, step, val, snd_vol;
DWORD *pbuf;
#ifdef _WIN32
int reps;
DWORD dwSize,dwSize2;
DWORD *pbuf2;
HRESULT hresult;
#endif
if (shm->samplebits == 16 && shm->channels == 2)
{
@ -162,33 +110,7 @@ void S_TransferPaintBuffer(int endtime)
step = 3 - shm->channels;
snd_vol = volume.value*256;
#ifdef _WIN32
if (pDSBuf)
{
reps = 0;
while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &dwSize,
&pbuf2,&dwSize2, 0)) != DS_OK)
{
if (hresult != DSERR_BUFFERLOST)
{
Con_Printf ("S_TransferPaintBuffer: DS::Lock Sound Buffer Failed\n");
S_Shutdown ();
S_Startup ();
return;
}
if (++reps > 10000)
{
Con_Printf ("S_TransferPaintBuffer: DS: couldn't restore buffer\n");
S_Shutdown ();
S_Startup ();
return;
}
}
}
else
#endif
{
pbuf = (DWORD *)shm->buffer;
}
@ -224,22 +146,6 @@ void S_TransferPaintBuffer(int endtime)
}
}
#ifdef _WIN32
if (pDSBuf) {
DWORD dwNewpos, dwWrite;
int il = paintedtime;
int ir = endtime - paintedtime;
ir += il;
pDSBuf->lpVtbl->Unlock(pDSBuf, pbuf, dwSize, NULL, 0);
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &dwNewpos, &dwWrite);
// if ((dwNewpos >= il) && (dwNewpos <= ir))
// Con_Printf("%d-%d p %d c\n", il, ir, dwNewpos);
}
#endif
}
@ -256,11 +162,9 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
void S_PaintChannels(int endtime)
{
int i;
int end;
int i, end, ltime, count;
channel_t *ch;
sfxcache_t *sc;
int ltime, count;
while (paintedtime < endtime)
{
@ -270,7 +174,7 @@ void S_PaintChannels(int endtime)
end = paintedtime + PAINTBUFFER_SIZE;
// clear the paint buffer
Q_memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
// paint in the channels.
ch = channels;
@ -280,8 +184,7 @@ void S_PaintChannels(int endtime)
continue;
if (!ch->leftvol && !ch->rightvol)
continue;
sc = S_LoadSound (ch->sfx);
if (!sc)
if (!(sc = S_LoadSound (ch->sfx)))
continue;
ltime = paintedtime;
@ -341,10 +244,8 @@ void SND_InitScaletable (void)
void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
{
int data;
int *lscale, *rscale;
int i, data, *lscale, *rscale;
unsigned char *sfx;
int i;
if (ch->leftvol > 255)
ch->leftvol = 255;
@ -353,7 +254,7 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
lscale = snd_scaletable[ch->leftvol >> 3];
rscale = snd_scaletable[ch->rightvol >> 3];
sfx = (signed char *)sc->data + ch->pos;
sfx = (unsigned char *)sc->data + ch->pos;
for (i=0 ; i<count ; i++)
{
@ -370,9 +271,7 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
{
int data;
int left, right;
int leftvol, rightvol;
int data, left, right, leftvol, rightvol;
signed short *sfx;
int i;