Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft Speech Platform
ISpMMSysAudio::GetDeviceId
ISpMMSysAudio::GetDeviceId passes back the multimedia device ID being used by the audio object.
<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT GetDeviceId(</strong> <strong> UINT</strong> *<em>puDeviceId</em> <strong>);</strong> </pre>
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 WAV-in or WAV-out device ID.
Example
The following code snippet illustrates the use of ISpMMSysAudio::GetDeviceId using CoCreateInstance.
`
// Declare local identifiers: HRESULT hr = S_OK; CComPtr<ISpMMSysAudio> cpMMSysAudio; UINT uiDeviceId;`// Create the multimedia input object. hr = cpMMSysAudio.CoCreateInstance(CLSID_SpMMAudioIn);
if (SUCCEEDED(hr)) { // Get the default device Id (that // is, uiDeviceId == WAVE_MAPPER). hr = cpMMSysAudio->GetDeviceId(&uiDeviceId;); }
if (SUCCEEDED(hr)) { // Do something here. }
The following code snippet illustrates the use of ISpMMSysAudio::GetDeviceId using an ISpObjectToken
`
// Declare local identifiers: HRESULT hr = S_OK; CComPtr<ISpMMSysAudio> cpMMSysAudio; CComPtr<ISpObjectWithToken> cpObjectWithToken; CComPtr<ISpObjectToken> cpObjectToken; UINT uiDeviceId;`// Create the multimedia input object. hr = cpMMSysAudio.CoCreateInstance(CLSID_SpMMAudioIn);
if (SUCCEEDED(hr)) { // Get the current multimedia object's object token. hr = cpMMSysAudio.QueryInterface(&cpObjectWithToken;); }
if (SUCCEEDED(hr)) { // Find the preferred multimedia object token. hr = SpFindBestToken(SPCAT_AUDIOIN, L"Technology=MMSys", NULL, &cpObjectToken;); }
if (SUCCEEDED(hr)) { // Set the current multimedia object to the preferred multimedia object token. hr = cpObjectWithToken->SetObjectToken(cpObjectToken); }
if (SUCCEEDED(hr)) { // Get the device id for the object (that // is, uiDeviceId != WAVE_MAPPER). hr = cpMMSysAudio->GetDeviceId(&uiDeviceId;); }
if (SUCCEEDED(hr)) { // Do stuff here. }