void S_Update_() { guard(S_Update_); if (!sound_started) return; SNDDMA_BeginPainting(); if (!dma.buffer) return; // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { Com_DPrintf("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position unsigned endtime = soundtime + appRound(s_mixahead->value * dma.speed); // mix to an even submission block size endtime = Align(endtime, dma.submission_chunk); int samps = dma.samples >> (dma.channels-1); if (endtime - soundtime > samps) endtime = soundtime + samps; S_PaintChannels(endtime); SNDDMA_Submit(); unguard; }
static void S_Update_(void) { unsigned endtime; int samps; if (!sound_started || (snd_blocked > 0)) return; /* Updates DMA time */ GetSoundtime(); /* check to make sure that we haven't overshot */ if (paintedtime < soundtime) { /* FIXME - handle init & wrap properly and report actual overflow */ //Con_DPrintf("%s: overflow\n", __func__); paintedtime = soundtime; } /* mix ahead of current position */ endtime = soundtime + _snd_mixahead.value * shm->speed; samps = shm->samples >> (shm->channels - 1); if (endtime - soundtime > samps) endtime = soundtime + samps; S_PaintChannels(endtime); SNDDMA_Submit(); }
void S_Update_(void) { unsigned endtime; int samps; static float lastTime = 0.0f; float ma, op; float thisTime, sane; static int ot = -1; if ( !s_soundStarted || s_soundMuted ) { return; } thisTime = Com_Milliseconds(); // Updates s_soundtime S_GetSoundtime(); if (s_soundtime == ot) { return; } ot = s_soundtime; // clear any sound effects that end before the current time, // and start any new sounds S_ScanChannelStarts(); sane = thisTime - lastTime; if (sane<11) { sane = 11; // 85hz } ma = s_mixahead->value * dma.speed; op = s_mixPreStep->value + sane*dma.speed*0.01; if (op < ma) { ma = op; } // mix ahead of current position endtime = s_soundtime + ma; // mix to an even submission block size endtime = (endtime + dma.submission_chunk-1) & ~(dma.submission_chunk-1); // never mix more than the complete buffer samps = dma.samples >> (dma.channels-1); if (endtime - s_soundtime > samps) endtime = s_soundtime + samps; SNDDMA_BeginPainting (); S_PaintChannels (endtime); SNDDMA_Submit (); lastTime = thisTime; }
static void S_Update_ (void) { unsigned int endtime; int samps; if (!sound_started || (snd_blocked > 0)) return; SNDDMA_LockBuffer (); if (! shm->buffer) return; // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { // Con_Printf ("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position endtime = soundtime + (unsigned int)(_snd_mixahead.value * shm->speed); samps = shm->samples >> (shm->channels - 1); endtime = q_min(endtime, (unsigned int)(soundtime + samps)); S_PaintChannels (endtime); SNDDMA_Submit (); }
static void paint_audio (void *unused, Uint8 * stream, int len) { int streamsamples; int sampleposbytes; int samplesbytes; if (shm) { streamsamples = len / (shm->samplebits / 8); sampleposbytes = shm->samplepos * (shm->samplebits / 8); samplesbytes = shm->samples * (shm->samplebits / 8); shm->samplepos += streamsamples; while (shm->samplepos >= shm->samples) shm->samplepos -= shm->samples; S_PaintChannels (soundtime + streamsamples); if (shm->samplepos + streamsamples <= shm->samples) memcpy (stream, shm->buffer + sampleposbytes, len); else { memcpy (stream, shm->buffer + sampleposbytes, samplesbytes - sampleposbytes); memcpy (stream + samplesbytes - sampleposbytes, shm->buffer, len - (samplesbytes - sampleposbytes)); } soundtime += streamsamples; } }
static void S_Update_(void) { unsigned endtime; int samps; if (!sound_started || (snd_blocked > 0)) return; /* Updates DMA time */ GetSoundtime(); /* check to make sure that we haven't overshot */ if (paintedtime < soundtime) { /* Con_Printf ("S_Update_ : overflow\n"); */ paintedtime = soundtime; } /* mix ahead of current position */ endtime = soundtime + _snd_mixahead.value * shm->speed; samps = shm->samples >> (shm->channels - 1); if (endtime - soundtime > samps) endtime = soundtime + samps; S_PaintChannels(endtime); SNDDMA_Submit(); }
void S_Update_(void) { unsigned endtime; int samps; if (!sound_started || (snd_blocked > 0)) { return; } // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { //Con_Printf ("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position endtime = soundtime + _snd_mixahead.value #ifdef FLASH / 2.0f //For Flash we need to halve the mixahead amount, probably because we doubled the sampling rate. #endif * shm->speed; samps = shm->samples >> (shm->channels-1); if (endtime - soundtime > samps) { endtime = soundtime + samps; } #ifndef _arch_dreamcast // BlackAura #ifdef _WIN32 // if the buffer was lost or stopped, restore it and/or restart it { DWORD dwStatus; if (pDSBuf) { if (pDSBuf->lpVtbl->GetStatus(pDSBuf, &dwStatus) != DD_OK) { Con_Printf("Couldn't get sound buffer status\n"); } if (dwStatus & DSBSTATUS_BUFFERLOST) { pDSBuf->lpVtbl->Restore(pDSBuf); } if (!(dwStatus & DSBSTATUS_PLAYING)) { pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); } } } #endif #endif // BlackAura S_PaintChannels(endtime); #ifndef FLASH SNDDMA_Submit(); #endif }
static void paint_audio(void *unused, Uint8 *stream, int len) { if ( shm ) { shm->buffer = stream; shm->samplepos += len/(shm->samplebits/8)/2; // Check for samplepos overflow? S_PaintChannels (shm->samplepos); } }
int paint_audio (void *unused, void * stream, int len) { if (!snd_inited) return 0; if (shm) { shm->buffer = stream; shm->samplepos += len / (shm->samplebits / 4); // Check for samplepos overflow? S_PaintChannels (shm->samplepos); return len; } return 0; }
void S_Update_(void) { #ifndef SDL unsigned endtime; int samps; if (!sound_started || (snd_blocked > 0)) return; // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { //Con_Printf ("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position endtime = soundtime + _snd_mixahead.value * shm->speed; samps = shm->samples >> (shm->channels-1); if (endtime - soundtime > samps) endtime = soundtime + samps; #ifdef _WIN32 // if the buffer was lost or stopped, restore it and/or restart it { DWORD dwStatus; if (pDSBuf) { if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DD_OK) Con_Printf ("Couldn't get sound buffer status\n"); if (dwStatus & DSBSTATUS_BUFFERLOST) pDSBuf->lpVtbl->Restore (pDSBuf); if (!(dwStatus & DSBSTATUS_PLAYING)) pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); } } #endif S_PaintChannels (endtime); SNDDMA_Submit (); #endif /* ! SDL */ }
static void S_Update_ (void) { unsigned int endtime; #ifdef _WIN32 DWORD dwStatus; #endif if (!shm || (snd_blocked > 0)) return; // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { //Com_Printf ("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position endtime = soundtime + (unsigned int) (s_mixahead.value * shm->format.speed); endtime = min(endtime, (unsigned int)(soundtime + shm->sampleframes)); #ifdef _WIN32 // if the buffer was lost or stopped, restore it and/or restart it if (pDSBuf) { if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK) Com_Printf ("Couldn't get sound buffer status\n"); if (dwStatus & DSBSTATUS_BUFFERLOST) pDSBuf->lpVtbl->Restore (pDSBuf); if (!(dwStatus & DSBSTATUS_PLAYING)) pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); } #endif S_PaintChannels (endtime); SNDDMA_Submit (); }
void S_Update_(void) { unsigned endtime; int samps; if (!sound_started) return; SNDDMA_BeginPainting (); if (!dma.buffer) return; // Updates DMA time GetSoundtime(); // check to make sure that we haven't overshot if (paintedtime < soundtime) { Com_DPrintf ("S_Update_ : overflow\n"); paintedtime = soundtime; } // mix ahead of current position endtime = soundtime + s_mixahead->value * dma.speed; //endtime = (soundtime + 4096) & ~4095; // mix to an even submission block size endtime = (endtime + dma.submission_chunk-1) & ~(dma.submission_chunk-1); samps = dma.samples >> (dma.channels-1); if (endtime - soundtime > samps) endtime = soundtime + samps; S_PaintChannels (endtime); SNDDMA_Submit (); }
void S_Update_(void) { unsigned endtime; int samps; static float lastTime = 0.0f; float ma, op; float thisTime, sane; static int ot = -1; if (!s_soundStarted || s_soundMuted) { return; } thisTime = Sys_Milliseconds(); // Updates s_soundtime S_GetSoundtime(); if (s_soundtime == ot) { return; } ot = s_soundtime; // clear any sound effects that end before the current time, // and start any new sounds S_ScanChannelStarts(); sane = thisTime - lastTime; if (sane < 11) { sane = 11; // 85hz } ma = s_mixahead->value * dma.speed; op = s_mixPreStep->value + sane * dma.speed * 0.01; if (op < ma) { ma = op; } // mix ahead of current position endtime = s_soundtime + ma; // mix to an even submission block size endtime = (endtime + dma.submission_chunk - 1) & ~(dma.submission_chunk - 1); // never mix more than the complete buffer samps = dma.samples >> (dma.channels - 1); if (endtime - s_soundtime > samps) { endtime = s_soundtime + samps; } // global volume fading // endtime or s_paintedtime or s_soundtime... if (s_soundtime < s_volTime2) // still has fading to do { if (s_soundtime > s_volTime1) // has started fading { s_volFadeFrac = ((float)(s_soundtime - s_volTime1) / (float)(s_volTime2 - s_volTime1)); s_volCurrent = ((1.0f - s_volFadeFrac) * s_volStart + s_volFadeFrac * s_volTarget); } else { s_volCurrent = s_volStart; } } else { s_volCurrent = s_volTarget; if (s_stopSounds) { // stop playing any sounds if they are all faded out S_StopAllSounds(); s_stopSounds = qfalse; } } SNDDMA_BeginPainting(); S_PaintChannels(endtime); SNDDMA_Submit(); lastTime = thisTime; }
void SNDDMA_Callback(void* userdata, Uint8* data, int length) { dma.buffer = data; dma.samplepos += length / (dma.samplebits / 4); S_PaintChannels(dma.samplepos); }