@capgo/native-audio
Advanced tools
@@ -116,6 +116,5 @@ import AVFoundation | ||
| var result: TimeInterval = 0 | ||
| owner?.executeOnAudioQueue { [weak self] in | ||
| guard let self else { return } | ||
| guard !channels.isEmpty, playIndex < channels.count else { return } | ||
| result = channels[playIndex].currentTime | ||
| owner?.readOnAudioQueue { | ||
| guard !self.channels.isEmpty, self.playIndex < self.channels.count else { return } | ||
| result = self.channels[self.playIndex].currentTime | ||
| } | ||
@@ -317,5 +316,4 @@ return result | ||
| var result = false | ||
| owner?.executeOnAudioQueue { [weak self] in | ||
| guard let self else { return } | ||
| result = channels.contains(where: { $0.isPlaying }) | ||
| owner?.readOnAudioQueue { | ||
| result = self.channels.contains(where: { $0.isPlaying }) | ||
| } | ||
@@ -322,0 +320,0 @@ return result |
@@ -15,3 +15,3 @@ import AVFoundation | ||
| public class NativeAudio: CAPPlugin, AVAudioPlayerDelegate, CAPBridgedPlugin { | ||
| private let pluginVersion: String = "8.3.4" | ||
| private let pluginVersion: String = "8.3.5" | ||
| public let identifier = "NativeAudio" | ||
@@ -1283,2 +1283,11 @@ public let jsName = "NativeAudio" | ||
| /// Use this for read-only access to shared state — avoids the .barrier write lock | ||
| /// that `executeOnAudioQueue` applies, preventing deadlocks with third-party SDKs. | ||
| internal func readOnAudioQueue<T>(_ block: () -> T) -> T { | ||
| if DispatchQueue.getSpecific(key: queueKey) != nil { | ||
| return block() | ||
| } | ||
| return audioQueue.sync { block() } | ||
| } | ||
| @objc func notifyCurrentTime(_ asset: AudioAsset) { | ||
@@ -1285,0 +1294,0 @@ audioQueue.sync { |
+1
-1
| { | ||
| "name": "@capgo/native-audio", | ||
| "version": "8.3.4", | ||
| "version": "8.3.5", | ||
| "description": "A native plugin for native audio engine", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
Sorry, the diff of this file is too big to display
670942
0.29%7779
0.3%