Skip to content

Commit

Permalink
Use swift-ddc v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksey-mashanov committed Nov 29, 2020
1 parent 696ce1c commit 1a3bae0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"package": "swift-ddc",
"repositoryURL": "https://github.com/aleksey-mashanov/swift-ddc.git",
"state": {
"branch": "master",
"revision": "40d9ac39e9204727b983637af1bfa7c46d4beef6",
"version": null
"branch": null,
"revision": "4c4e1487515d5cfcea55470eb44be59a27a11a25",
"version": "1.0.0"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
.macOS(.v10_13),
],
dependencies: [
.package(url: "https://github.com/aleksey-mashanov/swift-ddc.git", .branch("master")),
.package(url: "https://github.com/aleksey-mashanov/swift-ddc.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.0")),
],
targets: [
Expand Down
23 changes: 1 addition & 22 deletions Sources/brisyncd/target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,22 @@ class TargetDisplays: PublishTerminateHandler {

class TargetDisplay: Display {
let display: io_service_t
let framebuffer: io_service_t
let ddc: DDC
var brightness: UInt16 = 101
var contrast: UInt16 = 101
var config = Config.defaultConfig
var job = Job()

init?(_ display: io_service_t) {
guard let framebuffer = Self.framebuffer(forDisplay: display) else {
IOObjectRelease(display)
return nil
}
self.display = display
self.framebuffer = framebuffer
guard let ddc = try? DDC(framebuffer: framebuffer) else {
IOObjectRelease(framebuffer)
guard let ddc = try? DDC(display: display) else {
IOObjectRelease(display)
return nil
}
self.ddc = ddc
}

deinit {
IOObjectRelease(framebuffer)
IOObjectRelease(display)
}

Expand Down Expand Up @@ -179,17 +171,4 @@ class TargetDisplay: Display {
}
}
}

static func framebuffer(forDisplay display: io_service_t) -> io_service_t? {
var displayConnect: io_service_t = 0
guard IORegistryEntryGetParentEntry(display, kIOServicePlane, &displayConnect) == KERN_SUCCESS else {
return nil
}
defer { IOObjectRelease(displayConnect) }
var framebuffer: io_service_t = 0
guard IORegistryEntryGetParentEntry(displayConnect, kIOServicePlane, &framebuffer) == KERN_SUCCESS else {
return nil
}
return framebuffer
}
}

0 comments on commit 1a3bae0

Please sign in to comment.