AEHardwareInfo.fromNative constructor
AEHardwareInfo.fromNative(
- AEHardwareInfoNative native
Implementation
factory AEHardwareInfo.fromNative(AEHardwareInfoNative native) {
final bBytes = <int>[];
for (int i = 0; i < 32; i++) {
final b = native.backend_name[i];
if (b == 0) break;
bBytes.add(b);
}
final dBytes = <int>[];
for (int i = 0; i < 256; i++) {
final b = native.device_name[i];
if (b == 0) break;
dBytes.add(b);
}
AudioFormat fmt = AudioFormat.f32;
if (native.output_format >= 0 && native.output_format < AudioFormat.values.length) {
fmt = AudioFormat.values[native.output_format];
}
return AEHardwareInfo(
backendName: String.fromCharCodes(bBytes).trim(),
deviceName: String.fromCharCodes(dBytes).trim(),
outputFormat: fmt,
bitDepth: native.bit_depth,
isFloat: native.is_float != 0,
sampleRate: native.sample_rate,
channels: native.channels,
periodSizeFrames: native.period_size_frames,
periodCount: native.period_count,
latencyMs: native.latency_ms,
isExclusiveMode: native.is_exclusive_mode != 0,
);
}