Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft Speech Platform
ISpMMSysAudio::SetDeviceId
ISpMMSysAudio::SetDeviceId sets the multimedia device ID.
<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT SetDeviceId(</strong> <strong> UINT</strong> <em>uDeviceId</em> <strong>);</strong> </pre>
Parameters
- uDeviceId
[in] The device ID of the device to set.
Return Values
Value | Description |
---|---|
S_OK | Function completed successfully. |
SPERR_DEVICE_BUSY | Object is not in the SPAS_CLOSED state. |
SPERR_ALREADY_INITIALIZED | Object was created using an object token. |
E_INVALIDARG | uDeviceId is invalid. It is not set to WAVE_MAPPER or device does not exist. |
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. The Speech Platform 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.
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. }