Skip to content

Commit

Permalink
Rename delegate method.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Dec 10, 2023
1 parent 4d16635 commit 016c34f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
14 changes: 7 additions & 7 deletions Sources/IO/IOCaptureSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import AVFoundation

protocol IOCaptureSessionDelegate: AnyObject {
@available(tvOS 17.0, *)
func session(_ session: IOCaptureSession, sessionRuntimeError session: AVCaptureSession, error: AVError)
func captureSession(_ session: IOCaptureSession, sessionRuntimeError session: AVCaptureSession, error: AVError)
#if os(iOS) || os(tvOS)
@available(tvOS 17.0, *)
func session(_ session: IOCaptureSession, sessionWasInterrupted session: AVCaptureSession, reason: AVCaptureSession.InterruptionReason?)
func captureSession(_ session: IOCaptureSession, sessionWasInterrupted session: AVCaptureSession, reason: AVCaptureSession.InterruptionReason?)
@available(tvOS 17.0, *)
func session(_ session: IOCaptureSession, sessionInterruptionEnded session: AVCaptureSession)
func captureSession(_ session: IOCaptureSession, sessionInterruptionEnded session: AVCaptureSession)
#endif
}

Expand Down Expand Up @@ -231,7 +231,7 @@ final class IOCaptureSession {
default:
break
}
delegate?.session(self, sessionRuntimeError: session, error: error)
delegate?.captureSession(self, sessionRuntimeError: session, error: error)
}

#if os(iOS) || os(tvOS)
Expand All @@ -244,16 +244,16 @@ final class IOCaptureSession {
guard let userInfoValue = notification.userInfo?[AVCaptureSessionInterruptionReasonKey] as AnyObject?,
let reasonIntegerValue = userInfoValue.integerValue,
let reason = AVCaptureSession.InterruptionReason(rawValue: reasonIntegerValue) else {
delegate?.session(self, sessionWasInterrupted: session, reason: nil)
delegate?.captureSession(self, sessionWasInterrupted: session, reason: nil)
return
}
delegate?.session(self, sessionWasInterrupted: session, reason: reason)
delegate?.captureSession(self, sessionWasInterrupted: session, reason: reason)
}

@available(tvOS 17.0, *)
@objc
private func sessionInterruptionEnded(_ notification: Notification) {
delegate?.session(self, sessionInterruptionEnded: session)
delegate?.captureSession(self, sessionInterruptionEnded: session)
}
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/IO/IOMixer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extension IOMixer: AudioCodecDelegate {
extension IOMixer: IOCaptureSessionDelegate {
// MARK: IOCaptureSessionDelegate
@available(tvOS 17.0, *)
func session(_ capture: IOCaptureSession, sessionRuntimeError session: AVCaptureSession, error: AVError) {
func captureSession(_ capture: IOCaptureSession, sessionRuntimeError session: AVCaptureSession, error: AVError) {
switch error.code {
case .unsupportedDeviceActiveFormat:
guard let device = error.device, let format = device.videoFormat(
Expand Down Expand Up @@ -166,12 +166,12 @@ extension IOMixer: IOCaptureSessionDelegate {

#if os(iOS) || os(tvOS)
@available(tvOS 17.0, *)
func session(_ _: IOCaptureSession, sessionWasInterrupted session: AVCaptureSession, reason: AVCaptureSession.InterruptionReason?) {
func captureSession(_ _: IOCaptureSession, sessionWasInterrupted session: AVCaptureSession, reason: AVCaptureSession.InterruptionReason?) {
delegate?.mixer(self, sessionWasInterrupted: session, reason: reason)
}

@available(tvOS 17.0, *)
func session(_ _: IOCaptureSession, sessionInterruptionEnded session: AVCaptureSession) {
func captureSession(_ _: IOCaptureSession, sessionInterruptionEnded session: AVCaptureSession) {
delegate?.mixer(self, sessionInterruptionEnded: session)
}
#endif
Expand Down
15 changes: 7 additions & 8 deletions Sources/IO/IOVideoUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,21 @@ final class IOVideoUnit: NSObject, IOUnit {
#if os(iOS) || os(macOS) || os(tvOS)
var frameRate = IOMixer.defaultFrameRate {
didSet {
if #available(tvOS 17.0, *) {
for capture in captures.values {
capture.setFrameRate(frameRate)
}
guard #available(tvOS 17.0, *) else {
return
}
for capture in captures.values {
capture.setFrameRate(frameRate)
}
}
}

var torch = false {
didSet {
guard torch != oldValue else {
guard #available(tvOS 17.0, *), torch != oldValue else {
return
}
if #available(tvOS 17.0, *) {
setTorchMode(torch ? .on : .off)
}
setTorchMode(torch ? .on : .off)
}
}
@available(tvOS 17.0, *)
Expand Down

0 comments on commit 016c34f

Please sign in to comment.