| 235 | } |
| 236 | |
| 237 | bool CDSoundChannel::ClearBuffer() |
| 238 | { |
| 239 | LPVOID pAudioPtr1, pAudioPtr2; |
| 240 | DWORD AudioBytes1, AudioBytes2; |
| 241 | |
| 242 | if (IsPlaying()) |
| 243 | if (!Stop()) |
| 244 | return false; |
| 245 | |
| 246 | if (FAILED(m_lpDirectSoundBuffer->Lock(0, m_iSoundBufferSize, &pAudioPtr1, &AudioBytes1, &pAudioPtr2, &AudioBytes2, 0))) |
| 247 | return false; |
| 248 | |
| 249 | if (m_iSampleSize == 8) { |
| 250 | std::memset(pAudioPtr1, 0x80, AudioBytes1); |
| 251 | if (pAudioPtr2) |
| 252 | std::memset(pAudioPtr2, 0x80, AudioBytes2); |
| 253 | } |
| 254 | else { |
| 255 | std::memset(pAudioPtr1, 0x00, AudioBytes1); |
| 256 | if (pAudioPtr2) |
| 257 | std::memset(pAudioPtr2, 0x00, AudioBytes2); |
| 258 | } |
| 259 | |
| 260 | if (FAILED(m_lpDirectSoundBuffer->Unlock((void*)pAudioPtr1, AudioBytes1, (void*)pAudioPtr2, AudioBytes2))) |
| 261 | return false; |
| 262 | |
| 263 | m_lpDirectSoundBuffer->SetCurrentPosition(0); |
| 264 | m_iCurrentWriteBlock = 0; |
| 265 | |
| 266 | return true; |
| 267 | } |
| 268 | |
| 269 | bool CDSoundChannel::WriteBuffer(array_view<char> Buffer) // // // |
| 270 | { |