MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / UpdateSoundBuffer

Method UpdateSoundBuffer

source/MockingboardCardManager.cpp:250–282  ·  view source on GitHub ↗

Called by: . MB_SyncEventCallback() on a TIMER1 (not TIMER2) underflow - when IsAnyTimer1Active() == true . Update() - when IsAnyTimer1Active() == false

Source from the content-addressed store, hash-verified

248// . MB_SyncEventCallback() on a TIMER1 (not TIMER2) underflow - when IsAnyTimer1Active() == true
249// . Update() - when IsAnyTimer1Active() == false
250void MockingboardCardManager::UpdateSoundBuffer(void)
251{
252#ifdef LOG_PERF_TIMINGS
253 extern UINT64 g_timeMB_NoTimer;
254 extern UINT64 g_timeMB_Timer;
255 PerfMarker perfMarker(!IsAnyTimer1Active() ? g_timeMB_NoTimer : g_timeMB_Timer);
256#endif
257
258 if (!m_mockingboardVoice.lpDSBvoice)
259 {
260 if (g_bDisableDirectSound || g_bDisableDirectSoundMockingboard)
261 return;
262
263 if (!Init())
264 return;
265 }
266
267 if (!m_mockingboardVoice.bActive)
268 {
269 // Sound buffer may have been stopped by MB_InitializeForLoadingSnapshot().
270 // NB. DSZeroVoiceBuffer() also zeros the sound buffer, so it's better than directly calling IDirectSoundBuffer::Play():
271 // - without zeroing, then the previous sound buffer can be heard for a fraction of a second
272 // - eg. when doing Mockingboard playback, then loading a save-state which is also doing Mockingboard playback
273 bool bRes = DSZeroVoiceBuffer(&m_mockingboardVoice, SOUNDBUFFER_SIZE); // ... and Play()
274 LogFileOutput("MBCardMgr: DSZeroVoiceBuffer(), res=%d\n", bRes ? 1 : 0);
275 if (!bRes)
276 return;
277 }
278
279 UINT numSamples = GenerateAllSoundData();
280 if (numSamples)
281 MixAllAndCopyToRingBuffer(numSamples);
282}
283
284bool MockingboardCardManager::Init(void)
285{

Callers 1

Calls 2

DSZeroVoiceBufferFunction · 0.85
LogFileOutputFunction · 0.85

Tested by

no test coverage detected