Use this to Play()
| 209 | |
| 210 | // Use this to Play() |
| 211 | bool 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 |
no test coverage detected