Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IAudioCaptureClient::GetNextPacketSize method

The GetNextPacketSize method retrieves the number of frames in the next data packet in the capture endpoint buffer.


HRESULT GetNextPacketSize(
  [out] UINT32 *pNumFramesInNextPacket


pNumFramesInNextPacket [out]

Pointer to a UINT32 variable into which the method writes the frame count (the number of audio frames in the next capture packet).

Return value

If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values shown in the following table.

Return codeDescription

The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.


The Windows audio service is not running.


Parameter pNumFramesInNextPacket is NULL.



Use this method only with shared-mode streams. It does not work with exclusive-mode streams.

Before calling the IAudioCaptureClient::GetBuffer method to retrieve the next data packet, the client can call GetNextPacketSize to retrieve the number of audio frames in the next packet. The count reported by GetNextPacketSize matches the count retrieved in the GetBuffer call (through the pNumFramesToRead output parameter) that follows the GetNextPacketSize call.

A packet always consists of an integral number of audio frames.

GetNextPacketSize must be called in the same thread as the GetBuffer and IAudioCaptureClient::ReleaseBuffer method calls that get and release the packets in the capture endpoint buffer.

For a code example that uses the GetNextPacketSize method, see Capturing a Stream.


Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8



See also

IAudioCaptureClient Interface



© 2016 Microsoft