capacitor-voice-recorder-wav-stereo 7.0.8 → 7.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Plugin/VoiceRecorder.swift +15 -18
- package/package.json +1 -1
|
@@ -106,20 +106,16 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
106
106
|
let audioSession = AVAudioSession.sharedInstance()
|
|
107
107
|
var devices = [[String: Any]]()
|
|
108
108
|
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let originalMode = audioSession.mode
|
|
109
|
+
// ロックを取得して状態変更を防ぐ
|
|
110
|
+
objc_sync_enter(audioSession)
|
|
111
|
+
defer { objc_sync_exit(audioSession) }
|
|
113
112
|
|
|
114
113
|
do {
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
|
|
119
|
-
didChangeCategory = true
|
|
120
|
-
}
|
|
114
|
+
// 現在のルートを強制保持
|
|
115
|
+
let originalRoute = audioSession.currentRoute
|
|
116
|
+
print("Original Route: \(originalRoute)")
|
|
121
117
|
|
|
122
|
-
//
|
|
118
|
+
// カテゴリ変更を完全に排除
|
|
123
119
|
let availableInputs = audioSession.availableInputs ?? []
|
|
124
120
|
for port in availableInputs {
|
|
125
121
|
devices.append([
|
|
@@ -130,8 +126,8 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
130
126
|
])
|
|
131
127
|
}
|
|
132
128
|
|
|
133
|
-
|
|
134
|
-
for port in
|
|
129
|
+
// 出力デバイスは現在のルートから取得(変更なし)
|
|
130
|
+
for port in originalRoute.outputs {
|
|
135
131
|
devices.append([
|
|
136
132
|
"deviceId": port.uid,
|
|
137
133
|
"kind": "audiooutput",
|
|
@@ -140,14 +136,15 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
140
136
|
])
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
//
|
|
144
|
-
if
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
// ルート変更検知
|
|
140
|
+
if audioSession.currentRoute != originalRoute {
|
|
141
|
+
print("Route changed unexpectedly!")
|
|
142
|
+
print("New Route: \(audioSession.currentRoute)")
|
|
143
|
+
throw NSError(domain: "AudioSessionError", code: 1, userInfo: nil)
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
} catch {
|
|
150
|
-
call.reject("
|
|
147
|
+
call.reject("Audio session conflict: \(error.localizedDescription)")
|
|
151
148
|
return
|
|
152
149
|
}
|
|
153
150
|
|