共用方式為


IDirectSoundCaptureBuffer8::Unlock 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 Unlock method unlocks the buffer.

Syntax

HRESULT Unlock(
         LPVOID pvAudioPtr1,
         DWORD dwAudioBytes1,
         LPVOID pvAudioPtr2,
         DWORD dwAudioBytes2
)

Parameters

  • pvAudioPtr1
    Address of the value retrieved in the ppvAudioPtr1 parameter of the Lock method.
  • dwAudioBytes1
    Number of bytes read from the pvAudioPtr1 parameter. See Remarks.
  • pvAudioPtr2
    Address of the value retrieved in the ppvAudioPtr2 parameter of the IDirectSoundCaptureBuffer8::Lock method.
  • dwAudioBytes2
    Number of bytes read from the pvAudioPtr2 parameter. See Remarks.

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 values:

Return code
DSERR_INVALIDPARAM
DSERR_INVALIDCALL

Remarks

An application must pass both pointers, pvAudioPtr1 and pvAudioPtr2, returned by the IDirectSoundCaptureBuffer8::Lock method to ensure the correct pairing of IDirectSoundCaptureBuffer8::Lock and IDirectSoundCaptureBuffer8::Unlock. The second pointer is needed even if zero bytes were written to the second pointer.

The values in dwAudioBytes1 and dwAudioBytes2 must specify the number of bytes actually read from each part of the buffer, which might be less than the size of the lock. DirectSound uses these values to determine how much data to transfer from the device.

Make sure that the capture buffer does not remain locked for long periods of time.

Requirements

Header: Declared in DSound.h.

Library: Use Dsound3d.dll.

See Also

IDirectSoundCaptureBuffer8