Waveform Capture: (2) Create a capture device object

Source: Internet
Author: User

You can create a capture device object by calling the DirectSoundCaptureCreate8 or DirectSoundFullDuplexCreate8 function. Both of these functions get a pointer to the IDirectSoundCapture8 interface.

The Lpcguid parameter of the directsoundcapturecreate or the Pcguidrenderdevice parameter of the DirectSoundFullDuplexCreate8 can be a GUID obtained by the enumeration, Or one of the following predefined GUIDs:

Guid Description
Dsdevid_defaultcapture The system's default sound capture device. You can also specify a device by passing a null pointer instead of a device GUID.
Dsdevid_defaultvoicecapture The default sound communication device. Typically, this is a secondary device such as a USB headset with a microphone.

If there is currently no device driver, the call fails.

You can also use the CoCreateInstance function to create an object. This process is similar to creating a device object. The steps are as follows:

1. Initializing COM objects by calling the CoInitializeEx function at application startup

Code

HRESULT hr = CoInitializeEx(NULL, 0);
  if (FAILED(hr))
  {
   ErrorHandler(hr); // Add error-handling here.
  }

2. Create device objects by calling the CoCreateInstance method and the Idirectsound8::initialize method instead of using the DirectSoundCreate8 function

Code

LPDIRECTSOUND8 lpds;
  hr = CoCreateInstance(&CLSID_DirectSound8,
       NULL,
       CLSCTX_INPROC_SERVER,
       IID_IDirectSound8,
       (LPVOID*) &lpds);
  if (FAILED(hr))
  {
   ErrorHandler(hr); // Add error-handling here.
  }

Clsid_directsound8 is the class identifier of the DirectSound driver object class, Iid_idirectsound8 is the interface identifier. The LPDS parameter receives a pointer to this interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.