|Microsoft DirectX 9.0|
DirectSound maintains two pointers into the buffer: the play cursor and the write cursor. These positions are byte offsets into the buffer, not absolute memory addresses.
The IDirectSoundBuffer8::Play method always starts playing at the position of the play cursor. When a buffer is created, the play cursor is set to 0. As the buffer is played, the cursor moves and always points to the next byte of data to be played. When the buffer is stopped, the cursor remains where it is.
The write cursor is the point after which it is safe to write data into the buffer. The block between the play cursor and the write cursor is already committed to be played, and cannot be changed safely.
You might visualize the buffer as a clock face, with data written to it in a clockwise direction. The play cursor and the write cursor are like two hands sweeping around the face at the same speed, the write cursor always keeping a little ahead of the play cursor. If the play cursor points to the 1 and the write cursor points to the 2, it is only safe to write data after the 2. Data between the 1 and the 2 may already have been queued for playback by DirectSound and should not be touched.
The write cursor moves with the play cursor, not with data written to the buffer. If you're streaming data, you are responsible for maintaining your own pointer into the buffer to indicate where the next block of data should be written.
An application can retrieve the play and write cursors by calling the IDirectSoundBuffer8::GetCurrentPosition method. The IDirectSoundBuffer8::SetCurrentPosition method lets you move the play cursor. Applications do not control the position of the write cursor.
To ensure that the play cursor is reported as accurately as possible, always specify the DSBCAPS_GETCURRENTPOSITION2 flag when creating a secondary buffer. For more information, see DSBUFFERDESC.