다음을 통해 공유


MMDevice API

Previous Next

MMDevice API

The Windows Multimedia Device (MMDevice) API enables audio clients to discover audio endpoint devices, determine their capabilities, and create driver instances for those devices.

Header file Mmdeviceapi.h defines the interfaces in the MMDevice API.

The MMDevice API consists of several interfaces. The first of these is the IMMDeviceEnumerator interface. To access the interfaces in the MMDevice API, a client obtains a reference to the IMMDeviceEnumerator interface of a device-enumerator object by calling the CoCreateInstance function, as shown in the following code fragment:

  const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
  const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
  hr = CoCreateInstance(
         CLSID_MMDeviceEnumerator, NULL,
         CLSCTX_ALL, IID_IMMDeviceEnumerator,
         (void**)&pEnumerator);

In the preceding code fragment, CLSID_MMDeviceEnumerator and IID_IMMDeviceEnumerator are the GUID values that are attached as attributes to the MMDeviceEnumerator class object and to the IMMDeviceEnumerator interface. The CoCreateInstance call passes these values by reference. Variable hr is of type HRESULT, and variable pEnumerator is a pointer to the IMMDeviceEnumerator interface of a device-enumerator object. IMMDeviceEnumerator provides methods for enumerating audio endpoint devices. For information about the __uuidof operator, the CoCreateInstance function, and the CLSCTX_XXX constants, see the Windows SDK documentation.

Through the IMMDeviceEnumerator interface, the client can obtain references to the other interfaces in the MMDevice API. The MMDevice API implements the following interfaces.

Interface Description
IMMDevice Represents an audio device.
IMMDeviceCollection Represents a collection of audio devices.
IMMDeviceEnumerator Provides methods for enumerating audio devices.
IMMEndpoint Represents an audio endpoint device.

In addition, clients of the MMDevice API that require notification of status changes in audio endpoint devices should implement the following interface.

Interface Description
IMMNotificationClient Provides notifications when an audio endpoint device is added or removed, when the state or properties of a device change, or when there is a change in the default role assigned to a device.

See Also

Previous Next