0

The GetCurrentPosition method of IDirectSoundBuffer has two arguments:

HRESULT GetCurrentPosition( LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor );

The first argument "pdwCurrentPlayCursor" receives the play cursor, and the second argument "pdwCurrentWriteCursor" receives the write cursor, which indicates the position in the sound buffer after which it is safe to write data - the region starting at the play cursor and ending at the write cursor (possibly wrapped around the end of the buffer) may contain data which has been committed to the sound hardware but not yet played.

The closest equivalent method provided by FMOD appears to be the getPosition method of FMOD::Channel:

FMOD_RESULT F_API getPosition( unsigned int *position, FMOD_TIMEUNIT postype );

This method has an argument "position" for receiving the play cursor, but no argument for receiving the write cursor.

Does FMOD provide any function with an argument that serves the same purpose as the pdwCurrentWriteCursor argument of IDirectSoundBuffer::GetCurrentPosition? Or is adding a fixed offset (DirectSound documentation suggests that the interval between the play cursor and the write cursor is about 15 milliseconds) to the play cursor the only way to get the safe write cursor when using FMOD?

TheBeardyMan
  • 829
  • 10
  • 28

1 Answers1

0

DirectSound uses a 'ring buffer' submission model which is fairly old-school. XAudio2, FMOD, and other modern sound APIs use 'packet-based' submission instead. In this model, you submit buffers of audio to play which are kept in a queue, and then processed as each buffer before it finishes playout.

In packet-based submission, the 'play cursor' has meaning but a 'write cursor' does not.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81