Skip to main content
State callbacks let you react to audio processor state changes in real time, without polling GetState(). You pass a callback function when creating a processor, and the SDK calls it whenever the processor transitions between states (for example, from INITIALIZING to READY, or to DISCONNECTED if the connection drops).
Without callbacks, you will not receive processor status updates automatically and will need to poll GetState() manually. Callbacks are the recommended approach for handling state changes.

Callback Signature

def state_callback(state: int, reason: str) -> None
ParameterTypeDescription
stateintA ProcessorState enum value
reasonstringA human-readable reason for the state change

Example

Define a callback function and pass it when creating a processor. The SDK will call it whenever the processor state changes:
import sanas_remote_sdk

def on_state_change(state, reason):
    if state == sanas_remote_sdk.ProcessorState.READY:
        print("Processor ready for audio processing")
    elif state == sanas_remote_sdk.ProcessorState.FAILED:
        print(f"Processor failed: {reason}")
    elif state == sanas_remote_sdk.ProcessorState.DISCONNECTED:
        print(f"Processor disconnected: {reason}")

# Pass the callback when creating a processor
processor, result = sdk.CreateAudioProcessor(audio_params, on_state_change)

See Also

ProcessorState

All possible state values your callback can receive

RemoteSDK

The CreateAudioProcessor() method accepts the callback parameter