Skip to content

Commit

Permalink
Add the ability to start dpaudiothru from app
Browse files Browse the repository at this point in the history
  • Loading branch information
SoneeJohn committed Apr 10, 2019
1 parent 131c896 commit 950d813
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions VirtualKVM/Uiltites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SwiftyBeaver

static let shared = Uiltites()
var log: SwiftyBeaver.Type?
fileprivate var task: Process?

@objc func setupLogging() {
guard log == nil else { return }
Expand All @@ -29,6 +30,22 @@ import SwiftyBeaver
log?.addDestination(file)
}

@objc func startAudioDaemon() {
guard task?.isRunning == false || task?.isRunning == nil else { return }
OperationQueue().addOperation {
self.task = Process()
self.task?.launchPath = "/usr/libexec/dpaudiothru"
self.task?.arguments = [""]
self.task?.launch()
self.task?.waitUntilExit()
}
}

@objc func stopAudioDaemon() {
guard task?.isRunning ?? false else { return }
self.task?.terminate()
}

@objc var logFilePath: String? {
guard log?.destinations.isEmpty == false else { return nil }
for desination in (log?.destinations)! {
Expand Down

0 comments on commit 950d813

Please sign in to comment.