Skip to content

Commit bb15c07

Browse files
committed
fixed Mic permission stall, UI manipulations being done not on the main thread, Aggregate device channel count
1 parent f1147ea commit bb15c07

4 files changed

Lines changed: 49 additions & 41 deletions

File tree

native/app/Source/Application.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ class Application {
344344

345345
private static func setupUI () {
346346
Console.log("Setting up UI")
347-
ui = UI()
348-
setupDataBus()
347+
ui = UI {
348+
setupDataBus()
349+
}
349350
}
350351

351352
private static func stopEngines () {

native/app/Source/Audio/Outputs/Output.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ class Output {
149149
outputEngine.setOutputDevice(device)
150150

151151
let outputSampleRate = device.actualSampleRate()!
152-
let channels = device.channels(direction: Direction.playback)
153-
let format = AVAudioFormat.init(standardFormatWithSampleRate: outputSampleRate, channels: channels)!
154-
152+
Console.log(device.channels(direction: .playback))
153+
let format = AVAudioFormat.init(standardFormatWithSampleRate: outputSampleRate, channels: 2)!
154+
155155
varispeed.rate = Float(Driver.device!.actualSampleRate()! / outputSampleRate)
156156
intialCalcRate = varispeed.rate;
157157
Console.log("Varispeed Rate: \(varispeed.rate)")

native/app/Source/Audio/Sources/Sources.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ class Sources: NSObject {
9393
}
9494
}
9595
}
96+
} else {
97+
callback()
9698
}
97-
9899
}
99100
} else {
100101
Application.quit()

native/app/Source/UI/UI.swift

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,18 @@ class UI: StoreSubscriber {
125125

126126
static var mode: UIMode = .window {
127127
willSet {
128-
if (newValue == .popover) {
129-
window.close()
130-
window.contentViewController = nil
131-
popover.popover.contentViewController = viewController
132-
popover.show()
133-
} else {
134-
popover.hide()
135-
popover.popover.contentViewController = nil
136-
window.contentViewController = viewController
137-
window.show()
128+
DispatchQueue.main.async {
129+
if (newValue == .popover) {
130+
window.close()
131+
window.contentViewController = nil
132+
popover.popover.contentViewController = viewController
133+
popover.show()
134+
} else {
135+
popover.hide()
136+
popover.popover.contentViewController = nil
137+
window.contentViewController = viewController
138+
window.show()
139+
}
138140
}
139141
}
140142
}
@@ -208,34 +210,38 @@ class UI: StoreSubscriber {
208210
static var statusItemClickedListener: EventListener<Void>!
209211
static var bridge: Bridge!
210212

211-
init () {
212-
UI.window.contentView = UI.viewController.view
213+
init (_ completion: @escaping () -> Void) {
214+
DispatchQueue.main.async {
215+
UI.window.contentView = UI.viewController.view
213216

214-
({
215-
UI.mode = Application.store.state.ui.mode
216-
UI.width = Application.store.state.ui.width
217-
UI.height = Application.store.state.ui.height
218-
})()
219-
220-
// TODO: Fix window position state saving (need to look if the current position is still accessible, what if the monitor isn't there anymore)
221-
// if let windowPosition = Application.store.state.ui.windowPosition {
222-
// window.position = windowPosition
223-
// }
224-
setupStateListener()
225-
UI.setupBridge()
226-
UI.setupListeners()
227-
UI.load()
228-
229-
func checkIfVisible () {
230-
let shown = UI.isShown
231-
if (UI.cachedIsShown != shown) {
232-
UI.cachedIsShown = shown
233-
UI.isShownChanged.emit(shown)
217+
({
218+
UI.mode = Application.store.state.ui.mode
219+
UI.width = Application.store.state.ui.width
220+
UI.height = Application.store.state.ui.height
221+
})()
222+
223+
// TODO: Fix window position state saving (need to look if the current position is still accessible, what if the monitor isn't there anymore)
224+
// if let windowPosition = Application.store.state.ui.windowPosition {
225+
// window.position = windowPosition
226+
// }
227+
self.setupStateListener()
228+
UI.setupBridge()
229+
UI.setupListeners()
230+
UI.load()
231+
232+
func checkIfVisible () {
233+
let shown = UI.isShown
234+
if (UI.cachedIsShown != shown) {
235+
UI.cachedIsShown = shown
236+
UI.isShownChanged.emit(shown)
237+
}
238+
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: checkIfVisible)
234239
}
235-
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: checkIfVisible)
240+
241+
checkIfVisible()
242+
completion()
236243
}
237-
238-
checkIfVisible()
244+
239245
}
240246

241247
static func reload () {

0 commit comments

Comments
 (0)