Skip to content

Commit

Permalink
Suppress Warnings MTHKView.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jun 12, 2024
1 parent 3494757 commit 48aaba8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Examples/macOS/CameraIngestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class CameraIngestViewController: NSViewController {

override func viewDidAppear() {
super.viewDidAppear()

stream.isMultiTrackAudioMixingEnabled = true

stream.videoMixerSettings.mode = .offscreen
Expand Down
65 changes: 29 additions & 36 deletions Sources/IO/MTHKView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,49 +90,14 @@ public class MTHKView: MTKView {
/// Prepares the receiver for service after it has been loaded from an Interface Builder archive, or nib file.
override open func awakeFromNib() {
super.awakeFromNib()
delegate = self
framebufferOnly = false
enableSetNeedsDisplay = true
if let device {
context = CIContext(mtlDevice: device)
}
}
}

extension MTHKView: IOStreamView {
// MARK: IOStreamView
public func attachStream(_ stream: IOStream?) {
if Thread.isMainThread {
currentStream = stream
} else {
DispatchQueue.main.async {
self.currentStream = stream
}
}
}

public func enqueue(_ sampleBuffer: CMSampleBuffer?) {
if Thread.isMainThread {
currentSampleBuffer = sampleBuffer
#if os(macOS)
self.needsDisplay = true
#else
self.setNeedsDisplay()
#endif
} else {
DispatchQueue.main.async {
self.enqueue(sampleBuffer)
}
}
}
}

extension MTHKView: MTKViewDelegate {
// MARK: MTKViewDelegate
public func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) {
}

public func draw(in view: MTKView) {
override open func draw(_ rect: CGRect) {
guard
let context,
let currentDrawable = currentDrawable,
Expand Down Expand Up @@ -186,4 +151,32 @@ extension MTHKView: MTKViewDelegate {
}
}

extension MTHKView: IOStreamView {
// MARK: IOStreamView
public func attachStream(_ stream: IOStream?) {
if Thread.isMainThread {
currentStream = stream
} else {
DispatchQueue.main.async {
self.currentStream = stream
}
}
}

public func enqueue(_ sampleBuffer: CMSampleBuffer?) {
if Thread.isMainThread {
currentSampleBuffer = sampleBuffer
#if os(macOS)
self.needsDisplay = true
#else
self.setNeedsDisplay()
#endif
} else {
DispatchQueue.main.async {
self.enqueue(sampleBuffer)
}
}
}
}

#endif

0 comments on commit 48aaba8

Please sign in to comment.