State Enum & Callbacks - Sanas Developer Hub
ProcessorState
Tracks the lifecycle of an IAudioProcessor: kUnknown → kInitializing → kReady, or kFailed / kDisconnected on error.
| Value | Meaning |
|---|---|
kUnknown |
Initial state before connection begins. |
kInitializing |
Connecting to the server — do not send audio yet. |
kReady |
Connected and ready — safe to call ProcessSamples. |
kFailed |
Connection or processing error. Destroy and recreate the processor. |
kDisconnected |
Was connected; the connection dropped. Destroy and recreate if needed. |
ProcessorStateChange
Returned by GetNextStateChange and WaitForStateChange when polling.
| Field | Type | Description |
|---|---|---|
state |
ProcessorState |
The new processor state. |
reason |
string | Human-readable reason for the transition. |
Callbacks
Both callbacks run on background threads managed by the SDK. Keep them fast, non-blocking, and thread-safe.
ProcessorStateCallback
Invoked whenever the processor’s state changes.
auto onState = {
// handle state transition
};
TranscriptCallback
Invoked each time a transcript JSON event is received from the server. See Transcripts for the payload schema.
auto onTranscript = {
// parse and handle the JSON event
};
Both are passed to CreateAudioProcessor:
auto p = sdk->CreateAudioProcessor(params, rc, onState, onTranscript);