Skip to content

Commit

Permalink
Merge pull request #1328 from shogo4405/feature/cicontext
Browse files Browse the repository at this point in the history
Performance improvements related to CIContext
  • Loading branch information
shogo4405 authored Nov 1, 2023
2 parents b251f91 + d9ce742 commit 13b6272
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Sources/Media/IOVideoMixer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ final class IOVideoMixer<T: IOVideoMixerDelegate> {
var muted = false
var multiCamCaptureSettings: MultiCamCaptureSettings = .default
weak var delegate: T?
var context: CIContext = .init()
var context: CIContext = .init() {
didSet {
for effect in effects {
effect.ciContext = context
}
}
}
private var extent = CGRect.zero {
didSet {
guard extent != oldValue else {
Expand Down
12 changes: 11 additions & 1 deletion Sources/Media/IOVideoUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ final class IOVideoUnit: NSObject, IOUnit {
}
#endif

var context: CIContext = .init()
var context: CIContext {
get {
return lockQueue.sync { self.videoMixer.context }
}
set {
lockQueue.async {
self.videoMixer.context = newValue
}
}
}

var isRunning: Atomic<Bool> {
return codec.isRunning
}
Expand Down

0 comments on commit 13b6272

Please sign in to comment.