CXR-L(EN)
cxr-l-sdk · v1.0.3 · snapshot 2026-06-02· ↗ source

Audio

Android: Audio

Overview

On an established CXRLink session, start the glasses-side audio stream. The SDK delivers PCM chunks via IAudioStreamCbk.onAudioReceived. Typical format: 16 kHz, mono, 16 bit.

Prerequisites

  • Global CXRLink created and connect completed.
  • Scene building completed:
    • CustomView: customViewOpen succeeded and onCustomViewOpened received
    • CustomApp: target app started via appStart
  • GlassPermission.MICROPHONE recommended.

Do not call startAudioStream with link-only connectivity before scene building.

Core APIs

MethodDescription
setCXRAudioCbk(IAudioStreamCbk)Register audio callbacks
startAudioStream(codecType: Int)Start capture; use codecType = 1
stopAudioStream()Stop capture

IAudioStreamCbk callbacks

CallbackDescription
onAudioReceived(data, offset, length)PCM chunk; guard offset/length bounds
onAudioStreamStateChanged(started: Boolean)Stream state
onAudioError(code, info?)Error; stop stream and notify user

PCM parameters

ParameterValue
Sample rate16000 Hz
Channels1 (mono)
Bit depth16 bit

Duration estimate: pcmBytes / (16000 * 2) seconds.

Lifecycle

  • Call stopAudioStream() in sub-page onDestroy; do not disconnect().
  • Stop capture before page destruction.
  • Optional: use onGlassAiInterrupt to auto-start recording on AI interrupt.

Constraints

  • Do not stream when link is down.
  • Flush writes periodically for file persistence.
  • Both CustomView and CustomApp support audio after scene building.

Appendix: reference sample

RenewCXRLSample AudioUsageViewModel — PCM capture, WAV packaging, playback.

Marcin Miazga