feat: stabilize voice activity and audio routing

This commit is contained in:
Edison Jwa
2026-05-25 01:19:09 +09:00
parent eb9014cd81
commit 5515ff6643
34 changed files with 3054 additions and 1751 deletions
+68 -16
View File
@@ -270,23 +270,19 @@ Future<BridgeAudioProcessingStats> audioProcessingStats() =>
Future<BridgeAudioDeviceList> listAudioDevices() =>
RustLib.instance.api.crateApiListAudioDevices();
/// Set the preferred input device by name. Takes effect on next
/// Set the preferred input device by id. Takes effect on next
/// `start_audio`.
Future<void> setInputDevice({String? name}) =>
RustLib.instance.api.crateApiSetInputDevice(name: name);
Future<void> setInputDevice({String? id}) =>
RustLib.instance.api.crateApiSetInputDevice(id: id);
/// Set the preferred output device by name.
Future<void> setOutputDevice({String? name}) =>
RustLib.instance.api.crateApiSetOutputDevice(name: name);
/// Set the preferred output device by id.
Future<void> setOutputDevice({String? id}) =>
RustLib.instance.api.crateApiSetOutputDevice(id: id);
/// Configure the VAD model path.
Future<void> setVadModelPath({required String path}) =>
RustLib.instance.api.crateApiSetVadModelPath(path: path);
/// Configure the TEN VAD ONNX model path.
Future<void> setTenVadModelPath({required String path}) =>
RustLib.instance.api.crateApiSetTenVadModelPath(path: path);
/// Enable or disable audio debug WAV dumping.
Future<void> enableAudioDebugWavDump({required bool enabled}) =>
RustLib.instance.api.crateApiEnableAudioDebugWavDump(enabled: enabled);
@@ -321,24 +317,47 @@ enum BridgeAudioBackend {
/// Audio device info from the platform.
class BridgeAudioDevice {
/// Stable platform-reported device identifier.
final String id;
/// Human-readable device name.
final String name;
/// Additional device details useful for disambiguation.
final String details;
/// True if the OS reports this as the default device.
final bool isDefault;
const BridgeAudioDevice({required this.name, required this.isDefault});
/// True if Chanora currently has this device pinned.
final bool isSelected;
const BridgeAudioDevice({
required this.id,
required this.name,
required this.details,
required this.isDefault,
required this.isSelected,
});
@override
int get hashCode => name.hashCode ^ isDefault.hashCode;
int get hashCode =>
id.hashCode ^
name.hashCode ^
details.hashCode ^
isDefault.hashCode ^
isSelected.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BridgeAudioDevice &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
isDefault == other.isDefault;
details == other.details &&
isDefault == other.isDefault &&
isSelected == other.isSelected;
}
/// List of available audio devices.
@@ -512,6 +531,21 @@ class BridgeAudioProcessingStats {
/// Clipped samples.
final BigInt clippedSamples;
/// Number of effectively silent processed capture frames.
final BigInt zeroFrames;
/// Number of processed capture frames.
final BigInt captureFrames;
/// Input callbacks carrying 10 ms of audio.
final BigInt callbacks10Ms;
/// Input callbacks carrying 20 ms of audio.
final BigInt callbacks20Ms;
/// Input callbacks carrying other sizes.
final BigInt callbacksOther;
/// Sonora enabled.
final bool sonoraEnabled;
@@ -536,6 +570,11 @@ class BridgeAudioProcessingStats {
required this.outputUnderruns,
required this.callbackXruns,
required this.clippedSamples,
required this.zeroFrames,
required this.captureFrames,
required this.callbacks10Ms,
required this.callbacks20Ms,
required this.callbacksOther,
required this.sonoraEnabled,
required this.platformVoiceProcessingEnabled,
});
@@ -559,6 +598,11 @@ class BridgeAudioProcessingStats {
outputUnderruns.hashCode ^
callbackXruns.hashCode ^
clippedSamples.hashCode ^
zeroFrames.hashCode ^
captureFrames.hashCode ^
callbacks10Ms.hashCode ^
callbacks20Ms.hashCode ^
callbacksOther.hashCode ^
sonoraEnabled.hashCode ^
platformVoiceProcessingEnabled.hashCode;
@@ -584,6 +628,11 @@ class BridgeAudioProcessingStats {
outputUnderruns == other.outputUnderruns &&
callbackXruns == other.callbackXruns &&
clippedSamples == other.clippedSamples &&
zeroFrames == other.zeroFrames &&
captureFrames == other.captureFrames &&
callbacks10Ms == other.callbacks10Ms &&
callbacks20Ms == other.callbacks20Ms &&
callbacksOther == other.callbacksOther &&
sonoraEnabled == other.sonoraEnabled &&
platformVoiceProcessingEnabled ==
other.platformVoiceProcessingEnabled;
@@ -976,6 +1025,12 @@ sealed class BridgeEvent with _$BridgeEvent {
required BridgeMessageTarget target,
}) = BridgeEvent_ChatMessage;
/// Human-readable server activity surfaced from protocol bookkeeping events.
const factory BridgeEvent.serverActivity({
/// TeamSpeak-style activity line.
required String message,
}) = BridgeEvent_ServerActivity;
/// Audio route changed (speaker/earpiece/BT/wired).
const factory BridgeEvent.audioRouteChanged({
/// The new audio route.
@@ -1169,9 +1224,6 @@ enum BridgeVadBackend {
/// Silero ONNX VAD.
sileroOnnx,
/// TEN VAD.
tenVad,
/// WebRTC fallback VAD.
webrtcVad,
@@ -55,7 +55,7 @@ extension BridgeEventPatterns on BridgeEvent {
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( BridgeEvent_Connected value)? connected,TResult Function( BridgeEvent_Lost value)? lost,TResult Function( BridgeEvent_Reconnecting value)? reconnecting,TResult Function( BridgeEvent_Disconnected value)? disconnected,TResult Function( BridgeEvent_AudioStarted value)? audioStarted,TResult Function( BridgeEvent_AudioStopped value)? audioStopped,TResult Function( BridgeEvent_SnapshotChanged value)? snapshotChanged,TResult Function( BridgeEvent_PttCapability value)? pttCapability,TResult Function( BridgeEvent_VoiceState value)? voiceState,TResult Function( BridgeEvent_InterruptionState value)? interruptionState,TResult Function( BridgeEvent_PermissionState value)? permissionState,TResult Function( BridgeEvent_ChatMessage value)? chatMessage,TResult Function( BridgeEvent_AudioRouteChanged value)? audioRouteChanged,required TResult orElse(),}){
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( BridgeEvent_Connected value)? connected,TResult Function( BridgeEvent_Lost value)? lost,TResult Function( BridgeEvent_Reconnecting value)? reconnecting,TResult Function( BridgeEvent_Disconnected value)? disconnected,TResult Function( BridgeEvent_AudioStarted value)? audioStarted,TResult Function( BridgeEvent_AudioStopped value)? audioStopped,TResult Function( BridgeEvent_SnapshotChanged value)? snapshotChanged,TResult Function( BridgeEvent_PttCapability value)? pttCapability,TResult Function( BridgeEvent_VoiceState value)? voiceState,TResult Function( BridgeEvent_InterruptionState value)? interruptionState,TResult Function( BridgeEvent_PermissionState value)? permissionState,TResult Function( BridgeEvent_ChatMessage value)? chatMessage,TResult Function( BridgeEvent_ServerActivity value)? serverActivity,TResult Function( BridgeEvent_AudioRouteChanged value)? audioRouteChanged,required TResult orElse(),}){
final _that = this;
switch (_that) {
case BridgeEvent_Connected() when connected != null:
@@ -70,7 +70,8 @@ return pttCapability(_that);case BridgeEvent_VoiceState() when voiceState != nul
return voiceState(_that);case BridgeEvent_InterruptionState() when interruptionState != null:
return interruptionState(_that);case BridgeEvent_PermissionState() when permissionState != null:
return permissionState(_that);case BridgeEvent_ChatMessage() when chatMessage != null:
return chatMessage(_that);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return chatMessage(_that);case BridgeEvent_ServerActivity() when serverActivity != null:
return serverActivity(_that);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return audioRouteChanged(_that);case _:
return orElse();
@@ -89,7 +90,7 @@ return audioRouteChanged(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( BridgeEvent_Connected value) connected,required TResult Function( BridgeEvent_Lost value) lost,required TResult Function( BridgeEvent_Reconnecting value) reconnecting,required TResult Function( BridgeEvent_Disconnected value) disconnected,required TResult Function( BridgeEvent_AudioStarted value) audioStarted,required TResult Function( BridgeEvent_AudioStopped value) audioStopped,required TResult Function( BridgeEvent_SnapshotChanged value) snapshotChanged,required TResult Function( BridgeEvent_PttCapability value) pttCapability,required TResult Function( BridgeEvent_VoiceState value) voiceState,required TResult Function( BridgeEvent_InterruptionState value) interruptionState,required TResult Function( BridgeEvent_PermissionState value) permissionState,required TResult Function( BridgeEvent_ChatMessage value) chatMessage,required TResult Function( BridgeEvent_AudioRouteChanged value) audioRouteChanged,}){
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( BridgeEvent_Connected value) connected,required TResult Function( BridgeEvent_Lost value) lost,required TResult Function( BridgeEvent_Reconnecting value) reconnecting,required TResult Function( BridgeEvent_Disconnected value) disconnected,required TResult Function( BridgeEvent_AudioStarted value) audioStarted,required TResult Function( BridgeEvent_AudioStopped value) audioStopped,required TResult Function( BridgeEvent_SnapshotChanged value) snapshotChanged,required TResult Function( BridgeEvent_PttCapability value) pttCapability,required TResult Function( BridgeEvent_VoiceState value) voiceState,required TResult Function( BridgeEvent_InterruptionState value) interruptionState,required TResult Function( BridgeEvent_PermissionState value) permissionState,required TResult Function( BridgeEvent_ChatMessage value) chatMessage,required TResult Function( BridgeEvent_ServerActivity value) serverActivity,required TResult Function( BridgeEvent_AudioRouteChanged value) audioRouteChanged,}){
final _that = this;
switch (_that) {
case BridgeEvent_Connected():
@@ -104,7 +105,8 @@ return pttCapability(_that);case BridgeEvent_VoiceState():
return voiceState(_that);case BridgeEvent_InterruptionState():
return interruptionState(_that);case BridgeEvent_PermissionState():
return permissionState(_that);case BridgeEvent_ChatMessage():
return chatMessage(_that);case BridgeEvent_AudioRouteChanged():
return chatMessage(_that);case BridgeEvent_ServerActivity():
return serverActivity(_that);case BridgeEvent_AudioRouteChanged():
return audioRouteChanged(_that);}
}
/// A variant of `map` that fallback to returning `null`.
@@ -119,7 +121,7 @@ return audioRouteChanged(_that);}
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( BridgeEvent_Connected value)? connected,TResult? Function( BridgeEvent_Lost value)? lost,TResult? Function( BridgeEvent_Reconnecting value)? reconnecting,TResult? Function( BridgeEvent_Disconnected value)? disconnected,TResult? Function( BridgeEvent_AudioStarted value)? audioStarted,TResult? Function( BridgeEvent_AudioStopped value)? audioStopped,TResult? Function( BridgeEvent_SnapshotChanged value)? snapshotChanged,TResult? Function( BridgeEvent_PttCapability value)? pttCapability,TResult? Function( BridgeEvent_VoiceState value)? voiceState,TResult? Function( BridgeEvent_InterruptionState value)? interruptionState,TResult? Function( BridgeEvent_PermissionState value)? permissionState,TResult? Function( BridgeEvent_ChatMessage value)? chatMessage,TResult? Function( BridgeEvent_AudioRouteChanged value)? audioRouteChanged,}){
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( BridgeEvent_Connected value)? connected,TResult? Function( BridgeEvent_Lost value)? lost,TResult? Function( BridgeEvent_Reconnecting value)? reconnecting,TResult? Function( BridgeEvent_Disconnected value)? disconnected,TResult? Function( BridgeEvent_AudioStarted value)? audioStarted,TResult? Function( BridgeEvent_AudioStopped value)? audioStopped,TResult? Function( BridgeEvent_SnapshotChanged value)? snapshotChanged,TResult? Function( BridgeEvent_PttCapability value)? pttCapability,TResult? Function( BridgeEvent_VoiceState value)? voiceState,TResult? Function( BridgeEvent_InterruptionState value)? interruptionState,TResult? Function( BridgeEvent_PermissionState value)? permissionState,TResult? Function( BridgeEvent_ChatMessage value)? chatMessage,TResult? Function( BridgeEvent_ServerActivity value)? serverActivity,TResult? Function( BridgeEvent_AudioRouteChanged value)? audioRouteChanged,}){
final _that = this;
switch (_that) {
case BridgeEvent_Connected() when connected != null:
@@ -134,7 +136,8 @@ return pttCapability(_that);case BridgeEvent_VoiceState() when voiceState != nul
return voiceState(_that);case BridgeEvent_InterruptionState() when interruptionState != null:
return interruptionState(_that);case BridgeEvent_PermissionState() when permissionState != null:
return permissionState(_that);case BridgeEvent_ChatMessage() when chatMessage != null:
return chatMessage(_that);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return chatMessage(_that);case BridgeEvent_ServerActivity() when serverActivity != null:
return serverActivity(_that);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return audioRouteChanged(_that);case _:
return null;
@@ -152,7 +155,7 @@ return audioRouteChanged(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( String serverName)? connected,TResult Function( String reason)? lost,TResult Function( int attempt, int delaySecs)? reconnecting,TResult Function( String reason)? disconnected,TResult Function()? audioStarted,TResult Function()? audioStopped,TResult Function( int channels, int clients)? snapshotChanged,TResult Function( String level, String backendId, String boundInputClass)? pttCapability,TResult Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode)? voiceState,TResult Function( bool began, bool shouldResume)? interruptionState,TResult Function( String permission, PermissionStateKind state)? permissionState,TResult Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target)? chatMessage,TResult Function( BridgeAudioRoute route)? audioRouteChanged,required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( String serverName)? connected,TResult Function( String reason)? lost,TResult Function( int attempt, int delaySecs)? reconnecting,TResult Function( String reason)? disconnected,TResult Function()? audioStarted,TResult Function()? audioStopped,TResult Function( int channels, int clients)? snapshotChanged,TResult Function( String level, String backendId, String boundInputClass)? pttCapability,TResult Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode)? voiceState,TResult Function( bool began, bool shouldResume)? interruptionState,TResult Function( String permission, PermissionStateKind state)? permissionState,TResult Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target)? chatMessage,TResult Function( String message)? serverActivity,TResult Function( BridgeAudioRoute route)? audioRouteChanged,required TResult orElse(),}) {final _that = this;
switch (_that) {
case BridgeEvent_Connected() when connected != null:
return connected(_that.serverName);case BridgeEvent_Lost() when lost != null:
@@ -166,7 +169,8 @@ return pttCapability(_that.level,_that.backendId,_that.boundInputClass);case Bri
return voiceState(_that.inChannel,_that.transmitMode,_that.mute,_that.releaseTailMs,_that.currentChannelId,_that.pendingTargetChannelId,_that.canJoin,_that.canLeave,_that.joinSyncState,_that.joinErrorCode);case BridgeEvent_InterruptionState() when interruptionState != null:
return interruptionState(_that.began,_that.shouldResume);case BridgeEvent_PermissionState() when permissionState != null:
return permissionState(_that.permission,_that.state);case BridgeEvent_ChatMessage() when chatMessage != null:
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_ServerActivity() when serverActivity != null:
return serverActivity(_that.message);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return audioRouteChanged(_that.route);case _:
return orElse();
@@ -185,7 +189,7 @@ return audioRouteChanged(_that.route);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( String serverName) connected,required TResult Function( String reason) lost,required TResult Function( int attempt, int delaySecs) reconnecting,required TResult Function( String reason) disconnected,required TResult Function() audioStarted,required TResult Function() audioStopped,required TResult Function( int channels, int clients) snapshotChanged,required TResult Function( String level, String backendId, String boundInputClass) pttCapability,required TResult Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode) voiceState,required TResult Function( bool began, bool shouldResume) interruptionState,required TResult Function( String permission, PermissionStateKind state) permissionState,required TResult Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target) chatMessage,required TResult Function( BridgeAudioRoute route) audioRouteChanged,}) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( String serverName) connected,required TResult Function( String reason) lost,required TResult Function( int attempt, int delaySecs) reconnecting,required TResult Function( String reason) disconnected,required TResult Function() audioStarted,required TResult Function() audioStopped,required TResult Function( int channels, int clients) snapshotChanged,required TResult Function( String level, String backendId, String boundInputClass) pttCapability,required TResult Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode) voiceState,required TResult Function( bool began, bool shouldResume) interruptionState,required TResult Function( String permission, PermissionStateKind state) permissionState,required TResult Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target) chatMessage,required TResult Function( String message) serverActivity,required TResult Function( BridgeAudioRoute route) audioRouteChanged,}) {final _that = this;
switch (_that) {
case BridgeEvent_Connected():
return connected(_that.serverName);case BridgeEvent_Lost():
@@ -199,7 +203,8 @@ return pttCapability(_that.level,_that.backendId,_that.boundInputClass);case Bri
return voiceState(_that.inChannel,_that.transmitMode,_that.mute,_that.releaseTailMs,_that.currentChannelId,_that.pendingTargetChannelId,_that.canJoin,_that.canLeave,_that.joinSyncState,_that.joinErrorCode);case BridgeEvent_InterruptionState():
return interruptionState(_that.began,_that.shouldResume);case BridgeEvent_PermissionState():
return permissionState(_that.permission,_that.state);case BridgeEvent_ChatMessage():
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_AudioRouteChanged():
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_ServerActivity():
return serverActivity(_that.message);case BridgeEvent_AudioRouteChanged():
return audioRouteChanged(_that.route);}
}
/// A variant of `when` that fallback to returning `null`
@@ -214,7 +219,7 @@ return audioRouteChanged(_that.route);}
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function( String serverName)? connected,TResult? Function( String reason)? lost,TResult? Function( int attempt, int delaySecs)? reconnecting,TResult? Function( String reason)? disconnected,TResult? Function()? audioStarted,TResult? Function()? audioStopped,TResult? Function( int channels, int clients)? snapshotChanged,TResult? Function( String level, String backendId, String boundInputClass)? pttCapability,TResult? Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode)? voiceState,TResult? Function( bool began, bool shouldResume)? interruptionState,TResult? Function( String permission, PermissionStateKind state)? permissionState,TResult? Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target)? chatMessage,TResult? Function( BridgeAudioRoute route)? audioRouteChanged,}) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function( String serverName)? connected,TResult? Function( String reason)? lost,TResult? Function( int attempt, int delaySecs)? reconnecting,TResult? Function( String reason)? disconnected,TResult? Function()? audioStarted,TResult? Function()? audioStopped,TResult? Function( int channels, int clients)? snapshotChanged,TResult? Function( String level, String backendId, String boundInputClass)? pttCapability,TResult? Function( bool inChannel, BridgeTransmitMode transmitMode, bool mute, int releaseTailMs, BigInt? currentChannelId, BigInt? pendingTargetChannelId, bool canJoin, bool canLeave, BridgeVoiceJoinSyncState joinSyncState, BridgeVoiceJoinErrorCode? joinErrorCode)? voiceState,TResult? Function( bool began, bool shouldResume)? interruptionState,TResult? Function( String permission, PermissionStateKind state)? permissionState,TResult? Function( BigInt senderId, String senderName, String message, BridgeMessageTarget target)? chatMessage,TResult? Function( String message)? serverActivity,TResult? Function( BridgeAudioRoute route)? audioRouteChanged,}) {final _that = this;
switch (_that) {
case BridgeEvent_Connected() when connected != null:
return connected(_that.serverName);case BridgeEvent_Lost() when lost != null:
@@ -228,7 +233,8 @@ return pttCapability(_that.level,_that.backendId,_that.boundInputClass);case Bri
return voiceState(_that.inChannel,_that.transmitMode,_that.mute,_that.releaseTailMs,_that.currentChannelId,_that.pendingTargetChannelId,_that.canJoin,_that.canLeave,_that.joinSyncState,_that.joinErrorCode);case BridgeEvent_InterruptionState() when interruptionState != null:
return interruptionState(_that.began,_that.shouldResume);case BridgeEvent_PermissionState() when permissionState != null:
return permissionState(_that.permission,_that.state);case BridgeEvent_ChatMessage() when chatMessage != null:
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return chatMessage(_that.senderId,_that.senderName,_that.message,_that.target);case BridgeEvent_ServerActivity() when serverActivity != null:
return serverActivity(_that.message);case BridgeEvent_AudioRouteChanged() when audioRouteChanged != null:
return audioRouteChanged(_that.route);case _:
return null;
@@ -1041,6 +1047,73 @@ $BridgeMessageTargetCopyWith<$Res> get target {
/// @nodoc
class BridgeEvent_ServerActivity extends BridgeEvent {
const BridgeEvent_ServerActivity({required this.message}): super._();
/// TeamSpeak-style activity line.
final String message;
/// Create a copy of BridgeEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BridgeEvent_ServerActivityCopyWith<BridgeEvent_ServerActivity> get copyWith => _$BridgeEvent_ServerActivityCopyWithImpl<BridgeEvent_ServerActivity>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BridgeEvent_ServerActivity&&(identical(other.message, message) || other.message == message));
}
@override
int get hashCode => Object.hash(runtimeType,message);
@override
String toString() {
return 'BridgeEvent.serverActivity(message: $message)';
}
}
/// @nodoc
abstract mixin class $BridgeEvent_ServerActivityCopyWith<$Res> implements $BridgeEventCopyWith<$Res> {
factory $BridgeEvent_ServerActivityCopyWith(BridgeEvent_ServerActivity value, $Res Function(BridgeEvent_ServerActivity) _then) = _$BridgeEvent_ServerActivityCopyWithImpl;
@useResult
$Res call({
String message
});
}
/// @nodoc
class _$BridgeEvent_ServerActivityCopyWithImpl<$Res>
implements $BridgeEvent_ServerActivityCopyWith<$Res> {
_$BridgeEvent_ServerActivityCopyWithImpl(this._self, this._then);
final BridgeEvent_ServerActivity _self;
final $Res Function(BridgeEvent_ServerActivity) _then;
/// Create a copy of BridgeEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? message = null,}) {
return _then(BridgeEvent_ServerActivity(
message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class BridgeEvent_AudioRouteChanged extends BridgeEvent {
const BridgeEvent_AudioRouteChanged({required this.route}): super._();
@@ -67,7 +67,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
String get codegenVersion => '2.12.0';
@override
int get rustContentHash => 1433826599;
int get rustContentHash => -560177922;
static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
@@ -156,7 +156,7 @@ abstract class RustLibApi extends BaseApi {
Future<void> crateApiSetHardMute({required bool muted});
Future<void> crateApiSetInputDevice({String? name});
Future<void> crateApiSetInputDevice({String? id});
Future<void> crateApiSetInputMuted({required bool muted});
@@ -166,7 +166,7 @@ abstract class RustLibApi extends BaseApi {
void crateApiSetNetworkState({required BridgeNetworkState state});
Future<void> crateApiSetOutputDevice({String? name});
Future<void> crateApiSetOutputDevice({String? id});
Future<void> crateApiSetOutputGain({required double gain});
@@ -181,8 +181,6 @@ abstract class RustLibApi extends BaseApi {
Future<void> crateApiSetReleaseTailMs({required int ms});
Future<void> crateApiSetTenVadModelPath({required String path});
Future<void> crateApiSetTransmitMode({required BridgeTransmitMode mode});
Future<void> crateApiSetVadModelPath({required String path});
@@ -772,7 +770,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
},
codec: SseCodec(
decodeSuccessData: sse_decode_bridge_audio_device_list,
decodeErrorData: null,
decodeErrorData: sse_decode_bridge_error,
),
constMeta: kCrateApiListAudioDevicesConstMeta,
argValues: [],
@@ -1079,12 +1077,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
const TaskConstMeta(debugName: "set_hard_mute", argNames: ["muted"]);
@override
Future<void> crateApiSetInputDevice({String? name}) {
Future<void> crateApiSetInputDevice({String? id}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_opt_String(name, serializer);
sse_encode_opt_String(id, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
@@ -1097,14 +1095,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
decodeErrorData: sse_decode_bridge_error,
),
constMeta: kCrateApiSetInputDeviceConstMeta,
argValues: [name],
argValues: [id],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiSetInputDeviceConstMeta =>
const TaskConstMeta(debugName: "set_input_device", argNames: ["name"]);
const TaskConstMeta(debugName: "set_input_device", argNames: ["id"]);
@override
Future<void> crateApiSetInputMuted({required bool muted}) {
@@ -1191,12 +1189,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
const TaskConstMeta(debugName: "set_network_state", argNames: ["state"]);
@override
Future<void> crateApiSetOutputDevice({String? name}) {
Future<void> crateApiSetOutputDevice({String? id}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_opt_String(name, serializer);
sse_encode_opt_String(id, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
@@ -1209,14 +1207,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
decodeErrorData: sse_decode_bridge_error,
),
constMeta: kCrateApiSetOutputDeviceConstMeta,
argValues: [name],
argValues: [id],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiSetOutputDeviceConstMeta =>
const TaskConstMeta(debugName: "set_output_device", argNames: ["name"]);
const TaskConstMeta(debugName: "set_output_device", argNames: ["id"]);
@override
Future<void> crateApiSetOutputGain({required double gain}) {
@@ -1364,36 +1362,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
TaskConstMeta get kCrateApiSetReleaseTailMsConstMeta =>
const TaskConstMeta(debugName: "set_release_tail_ms", argNames: ["ms"]);
@override
Future<void> crateApiSetTenVadModelPath({required String path}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_String(path, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 42,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_unit,
decodeErrorData: sse_decode_bridge_error,
),
constMeta: kCrateApiSetTenVadModelPathConstMeta,
argValues: [path],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiSetTenVadModelPathConstMeta => const TaskConstMeta(
debugName: "set_ten_vad_model_path",
argNames: ["path"],
);
@override
Future<void> crateApiSetTransmitMode({required BridgeTransmitMode mode}) {
return handler.executeNormal(
@@ -1404,7 +1372,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 43,
funcId: 42,
port: port_,
);
},
@@ -1432,7 +1400,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 44,
funcId: 43,
port: port_,
);
},
@@ -1459,7 +1427,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 45,
funcId: 44,
port: port_,
);
},
@@ -1487,7 +1455,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 46,
funcId: 45,
port: port_,
);
},
@@ -1519,7 +1487,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 47,
funcId: 46,
port: port_,
);
},
@@ -1548,7 +1516,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 48,
funcId: 47,
port: port_,
);
},
@@ -1643,11 +1611,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
BridgeAudioDevice dco_decode_bridge_audio_device(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 2)
throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
if (arr.length != 5)
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
return BridgeAudioDevice(
name: dco_decode_String(arr[0]),
isDefault: dco_decode_bool(arr[1]),
id: dco_decode_String(arr[0]),
name: dco_decode_String(arr[1]),
details: dco_decode_String(arr[2]),
isDefault: dco_decode_bool(arr[3]),
isSelected: dco_decode_bool(arr[4]),
);
}
@@ -1694,8 +1665,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 19)
throw Exception('unexpected arr length: expect 19 but see ${arr.length}');
if (arr.length != 24)
throw Exception('unexpected arr length: expect 24 but see ${arr.length}');
return BridgeAudioProcessingStats(
inputDbfs: dco_decode_f_32(arr[0]),
renderDbfs: dco_decode_f_32(arr[1]),
@@ -1716,8 +1687,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
outputUnderruns: dco_decode_u_64(arr[14]),
callbackXruns: dco_decode_u_64(arr[15]),
clippedSamples: dco_decode_u_64(arr[16]),
sonoraEnabled: dco_decode_bool(arr[17]),
platformVoiceProcessingEnabled: dco_decode_bool(arr[18]),
zeroFrames: dco_decode_u_64(arr[17]),
captureFrames: dco_decode_u_64(arr[18]),
callbacks10Ms: dco_decode_u_64(arr[19]),
callbacks20Ms: dco_decode_u_64(arr[20]),
callbacksOther: dco_decode_u_64(arr[21]),
sonoraEnabled: dco_decode_bool(arr[22]),
platformVoiceProcessingEnabled: dco_decode_bool(arr[23]),
);
}
@@ -1887,6 +1863,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
target: dco_decode_box_autoadd_bridge_message_target(raw[4]),
);
case 12:
return BridgeEvent_ServerActivity(message: dco_decode_String(raw[1]));
case 13:
return BridgeEvent_AudioRouteChanged(
route: dco_decode_bridge_audio_route(raw[1]),
);
@@ -2194,9 +2172,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
SseDeserializer deserializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_id = sse_decode_String(deserializer);
var var_name = sse_decode_String(deserializer);
var var_details = sse_decode_String(deserializer);
var var_isDefault = sse_decode_bool(deserializer);
return BridgeAudioDevice(name: var_name, isDefault: var_isDefault);
var var_isSelected = sse_decode_bool(deserializer);
return BridgeAudioDevice(
id: var_id,
name: var_name,
details: var_details,
isDefault: var_isDefault,
isSelected: var_isSelected,
);
}
@protected
@@ -2270,6 +2257,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
var var_outputUnderruns = sse_decode_u_64(deserializer);
var var_callbackXruns = sse_decode_u_64(deserializer);
var var_clippedSamples = sse_decode_u_64(deserializer);
var var_zeroFrames = sse_decode_u_64(deserializer);
var var_captureFrames = sse_decode_u_64(deserializer);
var var_callbacks10Ms = sse_decode_u_64(deserializer);
var var_callbacks20Ms = sse_decode_u_64(deserializer);
var var_callbacksOther = sse_decode_u_64(deserializer);
var var_sonoraEnabled = sse_decode_bool(deserializer);
var var_platformVoiceProcessingEnabled = sse_decode_bool(deserializer);
return BridgeAudioProcessingStats(
@@ -2290,6 +2282,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
outputUnderruns: var_outputUnderruns,
callbackXruns: var_callbackXruns,
clippedSamples: var_clippedSamples,
zeroFrames: var_zeroFrames,
captureFrames: var_captureFrames,
callbacks10Ms: var_callbacks10Ms,
callbacks20Ms: var_callbacks20Ms,
callbacksOther: var_callbacksOther,
sonoraEnabled: var_sonoraEnabled,
platformVoiceProcessingEnabled: var_platformVoiceProcessingEnabled,
);
@@ -2519,6 +2516,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
target: var_target,
);
case 12:
var var_message = sse_decode_String(deserializer);
return BridgeEvent_ServerActivity(message: var_message);
case 13:
var var_route = sse_decode_bridge_audio_route(deserializer);
return BridgeEvent_AudioRouteChanged(route: var_route);
default:
@@ -2917,8 +2917,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
SseSerializer serializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_String(self.id, serializer);
sse_encode_String(self.name, serializer);
sse_encode_String(self.details, serializer);
sse_encode_bool(self.isDefault, serializer);
sse_encode_bool(self.isSelected, serializer);
}
@protected
@@ -2978,6 +2981,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
sse_encode_u_64(self.outputUnderruns, serializer);
sse_encode_u_64(self.callbackXruns, serializer);
sse_encode_u_64(self.clippedSamples, serializer);
sse_encode_u_64(self.zeroFrames, serializer);
sse_encode_u_64(self.captureFrames, serializer);
sse_encode_u_64(self.callbacks10Ms, serializer);
sse_encode_u_64(self.callbacks20Ms, serializer);
sse_encode_u_64(self.callbacksOther, serializer);
sse_encode_bool(self.sonoraEnabled, serializer);
sse_encode_bool(self.platformVoiceProcessingEnabled, serializer);
}
@@ -3168,8 +3176,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
sse_encode_String(senderName, serializer);
sse_encode_String(message, serializer);
sse_encode_box_autoadd_bridge_message_target(target, serializer);
case BridgeEvent_AudioRouteChanged(route: final route):
case BridgeEvent_ServerActivity(message: final message):
sse_encode_i_32(12, serializer);
sse_encode_String(message, serializer);
case BridgeEvent_AudioRouteChanged(route: final route):
sse_encode_i_32(13, serializer);
sse_encode_bridge_audio_route(route, serializer);
}
}