다음을 통해 공유


ISpAudio::SetState (Windows CE 5.0)

Send Feedback

This method sets the state of the audio device. In general, applications do not need to change the state of the audio device directly. With the shared recognizer in particular, this will often cause unexpected results. SAPI automatically manages the state of the audio device based on the state of all the grammars, recognition contexts, and recognizer instance.

HRESULT SetState(SPAUDIOSTATE NewState,ULONGLONG ullReserved);

Parameters

  • NewState
    [in] Flag of type SPAUDIOSTATE for the new state of the audio device.
  • ullReserved
    [in] Reserved. Do not use. This value must be zero.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
E_INVALIDARG ullReserved is not zero or NewState is not one of the allowed values.
SPERR_DEVICE_BUSY Hardware device is in use by another thread or process.
SPERR_UNINITIALIZED Current format set by ISpAudio::SetFormat is not supported by the hardware device.

Remarks

When transitioning from the SPAS_CLOSED state to any other state, the caller should be ready to handle various error conditions, specifically, SPERR_UNSUPPORTED_FORMAT and SPERR_DEVICE_BUSY. Many multi-media devices do not correctly report their capabilities for handling different audio formats and fail only when an attempt is made to open the device.

Also, in many older systems, audio output devices can only be opened by a single process. In all current versions of Windows, only a single process can open an audio input device. Therefore, SPERR_DEVICE_BUSY will return if an attempt is made to open a device that is being used by a different process or thread.

On some older sound cards, recording and playback are not possible simultaneously or only possible at the same frequency. An application making use of the input and output audio should be aware of this and in particular attempt to gracefully degrade from better quality frequencies to the same frequency for both if the sound card makes this necessary.

Requirements

OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.

See Also

ISpAudio | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.