fix(audio): optimize audio configuration for iOS and Android platforms

This commit is contained in:
cogwheel0
2025-11-27 18:41:41 +05:30
parent 852a65f870
commit d092bb2e44
7 changed files with 276 additions and 267 deletions

View File

@@ -130,6 +130,29 @@ class CallKitService {
return <Map<String, dynamic>>[];
}
/// Checks for active calls and clears them if they are not tracked by the app.
Future<void> checkAndCleanActiveCalls() async {
if (!_shouldUseCallKit('check active calls')) return;
try {
final calls = await activeCalls();
if (calls.isNotEmpty) {
developer.log(
'Found ${calls.length} active CallKit calls on startup. Cleaning up.',
name: 'callkit',
);
await endAllCalls();
}
} catch (error, stackTrace) {
developer.log(
'Failed to clean up active calls: $error',
name: 'callkit',
error: error,
stackTrace: stackTrace,
);
}
}
/// Stream of CallKit events from the native layer.
Stream<CallEvent> get events {
if (!_callKitAllowed) {
@@ -182,7 +205,7 @@ class CallKitService {
ios: const IOSParams(
handleType: 'generic',
supportsVideo: false,
audioSessionMode: 'default',
audioSessionMode: 'voiceChat',
audioSessionActive: true,
audioSessionPreferredSampleRate: 44100.0,
audioSessionPreferredIOBufferDuration: 0.005,