void CFMODEx::ProcessSound() { EnterCriticalSection(&GUI.SoundCritSect); S9xFinalizeSamples(); LeaveCriticalSection(&GUI.SoundCritSect); }
static void S9xAudioCallback(void*) { S9xFinalizeSamples(); size_t avail = S9xGetSampleCount(); S9xMixSamples((uint8*)audio_buf, avail); for (size_t i = 0; i < avail; i+=2) s9x_audio_cb((uint16_t)audio_buf[i], (uint16_t)audio_buf[i + 1]); }
static void S9xAudioCallback() { size_t avail; /* Just pick a big buffer. We won't use it all. */ static int16_t audio_buf[0x10000]; S9xFinalizeSamples(); avail = S9xGetSampleCount(); S9xMixSamples(audio_buf, avail); audio_batch_cb(audio_buf, avail >> 1); }
static void S9xAudioCallback() { // Just pick a big buffer. We won't use it all. static int16_t audio_buf[0x10000]; S9xFinalizeSamples(); size_t avail = S9xGetSampleCount(); S9xMixSamples(audio_buf, avail); for (size_t i = 0; i < avail; i+=2) s9x_audio_cb((uint16_t)audio_buf[i], (uint16_t)audio_buf[i + 1]); }
static void S9xAudioCallback(void*) { const int BUFFER_SIZE = 256; // This is called every time 128 to 132 samples are generated, which happens about 8 times per frame. A buffer size of 256 samples is enough here. static int16_t audio_buf[BUFFER_SIZE]; S9xFinalizeSamples(); size_t avail = S9xGetSampleCount(); while (avail >= BUFFER_SIZE) { //this loop will never be entered, but handle oversized sample counts just in case S9xMixSamples((uint8*)audio_buf, BUFFER_SIZE); audio_batch_cb(audio_buf, BUFFER_SIZE >> 1); avail -= BUFFER_SIZE; } if (avail > 0) { S9xMixSamples((uint8*)audio_buf, avail); audio_batch_cb(audio_buf, avail >> 1); }
/* CXAudio2::ProcessSound The mixing function called by the sound core when new samples are available. SoundBuffer is divided into blockCount blocks. If there are enought available samples and a free block, the block is filled and queued to the source voice. bufferCount is increased by pushbuffer and decreased by the OnBufferComplete callback. */ void CXAudio2::ProcessSound() { S9xFinalizeSamples(); if(!initDone) return; BYTE * curBuffer; UINT32 availableSamples; UINT32 availableBytes; availableSamples = S9xGetSampleCount(); availableBytes = availableSamples * (Settings.SixteenBitSound ? 2 : 1); while(availableSamples > singleBufferSamples && bufferCount < blockCount) { curBuffer = soundBuffer + writeOffset; S9xMixSamples(curBuffer,singleBufferSamples); PushBuffer(singleBufferBytes,curBuffer,NULL); writeOffset+=singleBufferBytes; writeOffset%=sum_bufferSize; } }