   Clicks while streaming WAV files using DirectSound
  Hi,I wrote a small player using this article: http://www.gamedev.net/reference/articles/article710.aspIt plays the file, but every time I update the secondary buffer (ServiceBuffer function), I hear strange clicks which sound like clipping or something like that.Here is the simplified version of the code without error checking and end of file checking:bool ServiceBuffer(void){  // Get write and read cursors  p_DSB->GetCurrentPosition(&PlayCursor, &WriteCursor);  // Maximum number of bytes we can write to the buffer  MaxWriteSize = (BufferLockCursor <= PlayCursor) ? PlayCursor BufferLockCursor : PlayCursor - BufferLockCursor + BufferSize;  // Write data to the buffer  WriteWaveData(MaxWriteSize);  return true;}function WriteWaveData looks like this:bool WriteWaveData(UINT size){  LPVOID p_buffer1 = NULL;  LPVOID p_buffer2 = NULL;  size1 = 0;  size2 = 0;  p_DSB->Lock(BufferLockCursor, size, &p_buffer1, &size1, &p_buffer2, &size2, DSBLOCK_FROMWRITECURSOR);  // p_audio is a pointer to the audio data extracted from the WAV file  memcpy(p_buffer1, p_audio+TrackLockCursor, size1);  if (size2!=0)    memcpy(p_buffer2, p_audio+TrackLockCursor+size1, size2);    // TrackLockCursor is a pointer to the next part of the p_audio array that must be written to the buffer   TrackLockCursor += (size1+size2);   BufferLockCursor = TrackLockCursor % BufferSize;  p_DSB->Unlock(p_buffer1, size1, p_buffer2, size2);  return true;}I use standard Timer component from C++ Builder for maintaining the ServiceBuffer function. Timer1.Interval=400, and the length of the buffer is 1000 ms.Does anyone have any ideas?Can it be because of using Timer component instead of some low-level functions?Thanks.   
  Why are you using DSBLOCK_FROMWRITECURSOR when the article doesn't? It means your offset into the buffer is ignored, which is probably a bad thing.   ;  That's it. You saved me)I just didn't get into the meaning of DSBLOCK_FROMWRITECURSOR, I thought it's the same as 0.   