Skip to content

Commit b76eff2

Browse files
committed
fix(config): save state of audio streams
1 parent dc18a26 commit b76eff2

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Reframed/State/ConfigService.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ final class ConfigService {
7070
set { data.dimOuterArea = newValue; save() }
7171
}
7272

73+
var isMicrophoneOn: Bool {
74+
get { data.isMicrophoneOn }
75+
set { data.isMicrophoneOn = newValue; save() }
76+
}
77+
7378
var appearance: String {
7479
get { data.appearance }
7580
set { data.appearance = newValue; save(); applyAppearance() }
@@ -144,6 +149,7 @@ private struct ConfigData: Codable {
144149
var projectFolder: String = "~/Reframed"
145150
var retinaCapture: Bool = false
146151
var dimOuterArea: Bool = true
152+
var isMicrophoneOn: Bool = false
147153
var appearance: String = "system"
148154
var shortcuts: [String: KeyboardShortcut] = [:]
149155
}

Reframed/State/SessionState.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ final class SessionState {
2727

2828
weak var statusItemButton: NSStatusBarButton?
2929

30+
init() {
31+
if ConfigService.shared.isMicrophoneOn, options.selectedMicrophone != nil {
32+
isMicrophoneOn = true
33+
}
34+
}
35+
3036
private let logger = Logger(label: "eu.jankuri.reframed.session")
3137
private var selectionCoordinator: SelectionCoordinator?
3238
private var windowSelectionCoordinator: WindowSelectionCoordinator?
@@ -60,6 +66,7 @@ final class SessionState {
6066
func toggleMicrophone() {
6167
guard options.selectedMicrophone != nil else { return }
6268
isMicrophoneOn.toggle()
69+
ConfigService.shared.isMicrophoneOn = isMicrophoneOn
6370
}
6471

6572
private func startCameraPreview() {
@@ -460,6 +467,7 @@ final class SessionState {
460467
captureTarget = nil
461468
captureMode = .none
462469
stopCameraPreview()
470+
isCameraOn = false
463471
transition(to: .idle)
464472
showToolbar()
465473
return
@@ -468,6 +476,7 @@ final class SessionState {
468476
recordingCoordinator = nil
469477
captureTarget = nil
470478
stopCameraPreview()
479+
isCameraOn = false
471480
devicePreviewWindow?.close()
472481
devicePreviewWindow = nil
473482
deviceCapture?.stop()

0 commit comments

Comments
 (0)