共用方式為


IDirectSoundBuffer8::GetCurrentPosition Method

[The feature associated with this page, DirectSound, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. Media Casting have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Media Casting instead of DirectSound, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The GetCurrentPosition method retrieves the position of the play and write cursors in the sound buffer.

Syntax

HRESULT GetCurrentPosition(
         LPDWORD pdwCurrentPlayCursor,
         LPDWORD pdwCurrentWriteCursor
)

Parameters

  • pdwCurrentPlayCursor
    Address of a variable that receives the offset, in bytes, of the play cursor. This parameter can be NULL if the value is not wanted.
  • pdwCurrentWriteCursor
    Address of a variable that receives the offset, in bytes, of the write cursor. This parameter can be NULL if the value is not wanted.

Return Value

If the method succeeds, the return value is DS_OK. If the method fails, the return value may be one of the following error values:

Return code
DSERR_INVALIDPARAM
DSERR_PRIOLEVELNEEDED

Remarks

The write cursor is the point in the buffer ahead of which it is safe to write data to the buffer. Data should not be written to the part of the buffer after the play cursor and before the write cursor.

Requirements

Header: Declared in DSound.h.

Library: Use Dsound3d.dll.

See Also

IDirectSoundBuffer8