ISpMMSysAudio::GetDeviceId

Microsoft Speech SDK

The Microsoft.com Speech website Microsoft Speech SDK SAPI 5.1

ISpMMSysAudio::GetDeviceId

ISpMMSysAudio::GetDeviceId passes back the multimedia device ID being used by the audio object.

HRESULT GetDeviceId(
   UINT  *puDeviceId
);

Parameters

puDeviceId
[out] Pointer receiving the device ID.

Return values

Value Description
S_OK Function completed successfully.
E_POINTER puDeviceId is a bad pointer.

Remarks

The default device ID for SpMMSysAudio objects that are created using CoCreateInstance is the WAVE_MAPPER. For audio objects created using an object token, the ID will always be a specific wave in or wave out device ID.

Example

The following code snippet illustrates the use of ISpMMSysAudio::GetDeviceId using CoCreateInstance.

    HRESULT hr = S_OK;

    // create the multimedia input object
    hr = cpMMSysAudio.CoCreateInstance(CLSID_SpMMAudioIn);
    // Check hr

    // get the default device id
    UINT uiDeviceId;
    hr = cpMMSysAudio->GetDeviceId(&uiDeviceId);
    // Check hr

    // uiDeviceId == WAVE_MAPPER

The following code snippet illustrates the use of ISpMMSysAudio::GetDeviceId using an ISpObjectToken

    HRESULT hr = S_OK;

    // get the current multimedia object's object token
    hr = cpMMSysAudio.QueryInterface(&cpObjectWithToken);
    // Check hr

    // Find the preferred multimedia object token
    hr = SpFindBestToken(SPCAT_AUDIOIN, L"Technology=MMSys", NULL, &cpObjectToken);
    // Check hr

    // set the current multimedia object to the preferred multimedia object token
    hr = cpObjectWithToken->SetObjectToken(cpObjectToken);
    // Check hr

    // get the device id for the object 
    UINT uiDeviceId;
    hr = cpMMSysAudio->GetDeviceId(&uiDeviceId);
    // Check hr

    // uiDeviceId != WAVE_MAPPER