Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/lib/providers/capture_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,15 @@ class CaptureProvider extends ChangeNotifier

Future streamDeviceRecording({BtDevice? device}) async {
debugPrint("streamDeviceRecording $device");

// Prevent device recording if system audio is active (desktop only)
if (PlatformService.isDesktop &&
recordingState == RecordingState.systemAudioRecord) {
debugPrint("Skipping device recording - system audio is active");
if (device != null) _updateRecordingDevice(device); // Still track device
return;
}

if (device != null) _updateRecordingDevice(device);
Comment on lines +738 to 745
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's code duplication here. The call if (device != null) _updateRecordingDevice(device); appears both inside the new if block (line 730) and after it (line 734). This can lead to maintenance issues if one instance is updated and the other is forgotten.

To improve maintainability and remove redundancy, you can move this call to before the if block and remove the other two instances. This ensures the device is updated regardless of the recording state, which matches the current logic but in a cleaner way.

Suggested change
if (PlatformService.isDesktop &&
recordingState == RecordingState.systemAudioRecord) {
debugPrint("Skipping device recording - system audio is active");
if (device != null) _updateRecordingDevice(device); // Still track device
return;
}
if (device != null) _updateRecordingDevice(device);
if (device != null) _updateRecordingDevice(device);
// Prevent device recording if system audio is active (desktop only)
if (PlatformService.isDesktop &&
recordingState == RecordingState.systemAudioRecord) {
debugPrint("Skipping device recording - system audio is active");
return;
}


bool wasPaused = _isPaused;
Expand Down Expand Up @@ -760,6 +769,11 @@ class CaptureProvider extends ChangeNotifier
return;
}

// Stop device recording if active
if (recordingState == RecordingState.deviceRecord && _recordingDevice != null) {
debugPrint("Stopping device recording to start system audio");
await stopStreamDeviceRecording(cleanDevice: false);
}
// User wants to record - enable auto-resume after wake
_shouldAutoResumeAfterWake = true;

Expand Down