AccessorySensorUpdates
Subscribes to a stream of raw sensor data packets from a connected accessory.
Declaration
struct AccessorySensorUpdatesOverview
An Audio Rendering Extension launched by AudioToolbox uses this type to receive sensor data from a 3P accessory that has registered .headTracking via AccessoryControlDevice. Data is brokered through audioaccessoryd over XPC.
No XPC resources are acquired until iteration begins. Cancel the owning Task to stop receiving updates and release the connection.
Usage
guard AccessorySensorUpdates.isSupported else { return }
let updates = AccessorySensorUpdates(for: accessoryIdentifier)
sensorTask = Task { [weak self] in
do {
for try await data in updates {
self?.processSensorData(data)
}
} catch AccessorySensorUpdates.StreamError.connectionLost {
// Terminal; stream is over
}
}