Skip to content

Commit

Permalink
0.17.0-rc2: fix detaching mirror device
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Mar 3, 2021
1 parent 1dfcc56 commit 62c0a29
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions MoeStreamer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = "0.17.0-rc1";
MARKETING_VERSION = "0.17.0-rc2";
PRODUCT_BUNDLE_IDENTIFIER = com.zhiayang.MoeStreamer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand Down Expand Up @@ -678,7 +678,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = "0.17.0-rc1";
MARKETING_VERSION = "0.17.0-rc2";
PRODUCT_BUNDLE_IDENTIFIER = com.zhiayang.MoeStreamer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand Down
22 changes: 13 additions & 9 deletions MoeStreamer/src/audio/AudioEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,11 @@ class AudioEngine
self.p2.scheduleBuffer(buffer, completionHandler: nil)
})

try! self.e1.outputNode.auAudioUnit.setDeviceID(device.dev)
try! self.e2.outputNode.auAudioUnit.setDeviceID(device.dev)

self.mirrorDevice = device
if self.p1.isPlaying
{
self.pause()

// this delay is necessary for some reason. if not, then nothing will play.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
self.play()
}
if self.p1.isPlaying {
self.refreshPlayers()
}
}

Expand All @@ -162,4 +156,14 @@ class AudioEngine
{
return self.mirrorDevice
}

private func refreshPlayers()
{
self.pause()

// this delay is necessary for some reason. if not, then nothing will play.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
self.play()
}
}
}
20 changes: 10 additions & 10 deletions MoeStreamer/src/ui/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ struct SettingsView : View

VStack(spacing: 4) {
HStack() {
Text("mirror sound")
.padding(.leading, 24)
Text("mirrors")
.padding(.leading, 30)
.tooltip("mirror playback to the selected audio device")

Spacer()
Expand All @@ -80,12 +80,12 @@ struct SettingsView : View
self.mirrorPlaybackDevice = $0
self.musicCon.audioController().setPlaybackMirrorDevice(to: $0)
})
.frame(width: 155)
.frame(width: 180)
}

HStack() {
Text("music source")
.padding(.leading, 24)
Text("source")
.padding(.leading, 30)
.tooltip("which music backend to use")

Spacer()
Expand All @@ -98,7 +98,7 @@ struct SettingsView : View
// time to change the controller.
changeControllerFor(self.$musicCon, backend: self.backend)
}
}).frame(width: 155)
}).frame(width: 180)
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ private struct LocalMusicSettingsView : View

HStack() {
Text("playlist")
.padding(.leading, 60)
.padding(.leading, 30)
.tooltip("which iTunes playlist to use")

Spacer()
Expand All @@ -285,12 +285,12 @@ private struct LocalMusicSettingsView : View
if let con = self.controller as? LocalMusicController {
con.setCurrentPlaylist(playlist: $0)
}
}).frame(width: 155)
}).frame(width: 180)
}.padding(.bottom, 4)

HStack() {
Text("shuffle")
.padding(.leading, 60)
.padding(.leading, 30)
.tooltip("how to shuffle the playlist")

Spacer()
Expand All @@ -299,7 +299,7 @@ private struct LocalMusicSettingsView : View
if let con = self.controller as? LocalMusicController {
con.setShuffleBehaviour(as: $0)
}
}).frame(width: 155)
}).frame(width: 180)
}.padding(.bottom, 4)
}
}
Expand Down

0 comments on commit 62c0a29

Please sign in to comment.