IDirectSoundBuffer8::GetFormat 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 GetFormat method retrieves a description of the format of the sound data in the buffer, or the buffer size needed to retrieve the format description.
Syntax
HRESULT GetFormat(
LPWAVEFORMATEX pwfxFormat,
DWORD dwSizeAllocated,
LPDWORD pdwSizeWritten
)
Parameters
- pwfxFormat
Address of a WAVEFORMATEX or WAVEFORMATEXTENSIBLE structure that receives a description of the sound data in the buffer. To retrieve the buffer size needed to contain the format description, specify NULL. In this case the variable at pdwSizeWritten receives the size of the structure needed to receive the data. - dwSizeAllocated
Size, in bytes, of the structure at pwfxFormat. If pwfxFormat is not NULL, this value must be equal to or greater than the size of the expected data. - pdwSizeWritten
Address of a variable that receives the number of bytes written to the structure at pwfxFormat. This parameter can be NULL.
Return Value
If the method succeeds, the return value is DS_OK. If the method fails, the return value may be DSERR_INVALIDPARAM.
Remarks
The format structure can have a variable length that depends on the format. Before retrieving the format description, the application should query the buffer object for the size of the format by calling this method and specifying NULL for the pwfxFormat parameter. The necessary size of the structure is returned in the pdwSizeWritten parameter. The application can then allocate sufficient memory and call GetFormat again to retrieve the format description.
Requirements
Header: Declared in DSound.h.
Library: Use Dsound3d.dll.