ISpMMSysAudio::SetDeviceId (SAPI 5.4)
Microsoft Speech API 5.4
ISpMMSysAudio::SetDeviceId
ISpMMSysAudio::SetDeviceId sets the multimedia device ID.
HRESULT SetDeviceId(
UINT uDeviceId
);
Parameters
- uDeviceId
[in] The device ID of the device to set.
Return values
Value |
S_OK |
SPERR_DEVICE_BUSY |
SPERR_ALREADY_INITIALIZED |
E_INVALIDARG |
Remarks
This method works only on audio objects that were not created using an object token, and only when the object is in the SPAS_CLOSED state. This method should not be used in normal application development. SAPI provides tokens for all the available sound devices in a computer and these can be used to create an initialized SpMMSysAudio object. This method is available for non-standard multimedia audio devices. See the Simple Telephony sample for an example of when this method is useful.
Example
The following code snippet illustrates the use of ISpMMSysAudio::SetDeviceId.
// Declare local identifiers:
HRESULT hr = S_OK;
CComPtr<ISpMMSysAudio> cpMMSysAudio;
UINT ALTERNATE_MM_DEVICE = 1;
// Create the multimedia output object.
hr = cpMMSysAudio.CoCreateInstance(CLSID_SpMMAudioOut);
if (SUCCEEDED (hr))
{
// Set the output device to an alternate multimedia
// device (for example, the modem).
hr = cpMMSysAudio->SetDeviceId(ALTERNATE_MM_DEVICE);
}
if (SUCCEEDED(hr))
{
// Do stuff here.
}