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

Function DSZeroVoiceBuffer

source/SoundCore.cpp:211–250  ·  view source on GitHub ↗

Use this to Play()

Source from the content-addressed store, hash-verified

209
210// Use this to Play()
211bool DSZeroVoiceBuffer(PVOICE Voice, uint32_t dwBufferSize)
212{
213#ifdef NO_DIRECT_X
214 return false;
215#else
216
217 DWORD dwDSLockedBufferSize = 0; // Size of the locked DirectSound buffer
218 SHORT* pDSLockedBuffer;
219
220 if (!DSVoiceStop(Voice))
221 return false;
222
223 HRESULT hr = DSGetLock(Voice->lpDSBvoice, 0, 0, &pDSLockedBuffer, &dwDSLockedBufferSize, NULL, 0);
224 if(FAILED(hr))
225 {
226 if(g_fh) fprintf(g_fh, "%s: DSGetLock failed (%08X)\n", Voice->name.c_str(), (uint32_t)hr);
227 return false;
228 }
229
230 _ASSERT(dwDSLockedBufferSize == dwBufferSize);
231 memset(pDSLockedBuffer, 0x00, dwDSLockedBufferSize);
232
233 hr = Voice->lpDSBvoice->Unlock((void*)pDSLockedBuffer, dwDSLockedBufferSize, NULL, 0);
234 if(FAILED(hr))
235 {
236 if(g_fh) fprintf(g_fh, "%s: DSUnlock failed (%08X)\n", Voice->name.c_str(), (uint32_t)hr);
237 return false;
238 }
239
240 hr = Voice->lpDSBvoice->Play(0,0,DSBPLAY_LOOPING);
241 if(FAILED(hr))
242 {
243 if(g_fh) fprintf(g_fh, "%s: DSPlay failed (%08X)\n", Voice->name.c_str(), (uint32_t)hr);
244 return false;
245 }
246
247 Voice->bActive = true;
248 return true;
249#endif // NO_DIRECT_X
250}
251
252//-----------------------------------------------------------------------------
253

Callers 4

DSInitMethod · 0.85
Spkr_DSInitFunction · 0.85
UpdateSoundBufferMethod · 0.85
InitMethod · 0.85

Calls 4

DSVoiceStopFunction · 0.85
DSGetLockFunction · 0.85
UnlockMethod · 0.80
PlayMethod · 0.45

Tested by

no test coverage detected