Skip to content

Commit f9e94ee

Browse files
committed
Small AudioEngine update.
1 parent aeae764 commit f9e94ee

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- SCNRecorder (2.5.0)
2+
- SCNRecorder (2.5.1)
33
- SnapKit (5.0.1)
44

55
DEPENDENCIES:
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
1515
:path: "../"
1616

1717
SPEC CHECKSUMS:
18-
SCNRecorder: 87469846988b24e3b9f28aa501e2133f5edd6d7b
18+
SCNRecorder: b446114276ca77d0b247836b28c3b9ae80b2cb08
1919
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
2020

2121
PODFILE CHECKSUM: a402c811b8b6a231a13402257d93acd3b67abb0d

Example/Pods/Local Podspecs/SCNRecorder.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/SCNRecorder/SCNRecorder-Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SCNRecorder.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SCNRecorder'
3-
s.version = '2.5.0'
3+
s.version = '2.5.1'
44
s.summary = 'A lags-free recorder of ARKit and SceneKit for iOS in Swift'
55
s.homepage = 'https://github.com/gorastudio/SCNRecorder'
66
s.license = { :type => 'MIT', :file => 'LICENSE.md' }

SCNRecorder.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@
10361036
"@executable_path/Frameworks",
10371037
"@loader_path/Frameworks",
10381038
);
1039-
MARKETING_VERSION = 2.5.0;
1039+
MARKETING_VERSION = 2.5.1;
10401040
MODULEMAP_FILE = SCNRecorder.modulemap;
10411041
PRODUCT_BUNDLE_IDENTIFIER = gora.studio.SCNRecorder;
10421042
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
@@ -1066,7 +1066,7 @@
10661066
"@executable_path/Frameworks",
10671067
"@loader_path/Frameworks",
10681068
);
1069-
MARKETING_VERSION = 2.5.0;
1069+
MARKETING_VERSION = 2.5.1;
10701070
MODULEMAP_FILE = SCNRecorder.modulemap;
10711071
PRODUCT_BUNDLE_IDENTIFIER = gora.studio.SCNRecorder;
10721072
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";

Sources/AudioEngine/AudioEngine.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public final class AudioEngine {
9595
guard !isInterrupted else { return false }
9696

9797
do {
98-
try self.activateAudioSessionIfNeeded()
98+
try self.activateAudioSession()
9999
try self.engine.start()
100100
return true
101101
}
@@ -108,15 +108,15 @@ public final class AudioEngine {
108108
player.didPause = { [weak self] in
109109
guard let self = self else { return }
110110
self.engine.pause()
111-
self.deactivateAudioSessionIfNeeded()
111+
self.deactivateAudioSession()
112112
}
113113

114114
player.didStop = { [weak self] in
115115
guard let self = self else { return }
116116

117117
self.engine.stop()
118118
self.engine.reset()
119-
self.deactivateAudioSessionIfNeeded()
119+
self.deactivateAudioSession()
120120
}
121121
}
122122
}
@@ -154,31 +154,29 @@ public final class AudioEngine {
154154
}
155155
}
156156

157-
let exclusivelyManageAudioSession: Bool
157+
let canDeactivateAudioSession: Bool
158158

159159
@Observable public internal(set) var error: Swift.Error?
160160

161-
public init(exclusivelyManageAudioSession: Bool = true) {
162-
self.exclusivelyManageAudioSession = exclusivelyManageAudioSession
161+
public init(canDeactivateAudioSession: Bool = true) {
162+
self.canDeactivateAudioSession = canDeactivateAudioSession
163163
setupObservers()
164164
}
165165

166166
deinit {
167167
recorder?.audioInput.audioFormat = nil
168168
player?.stop()
169169
observers.forEach { notificationCenter.removeObserver($0) }
170-
deactivateAudioSessionIfNeeded()
170+
deactivateAudioSession()
171171
}
172172

173-
func activateAudioSessionIfNeeded() throws {
174-
guard exclusivelyManageAudioSession else { return }
175-
173+
func activateAudioSession() throws {
176174
try audioSession.setCategory(.playAndRecord, options: .defaultToSpeaker)
177175
try audioSession.setActive(true)
178176
}
179177

180-
func deactivateAudioSessionIfNeeded() {
181-
guard exclusivelyManageAudioSession else { return }
178+
func deactivateAudioSession() {
179+
guard canDeactivateAudioSession else { return }
182180

183181
do { try audioSession.setActive(false) }
184182
catch { self.error = error }

0 commit comments

Comments
 (0)