capacitor-voice-recorder-wav-stereo 7.0.7 → 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.
@@ -106,16 +106,16 @@ public class VoiceRecorder: CAPPlugin {
106
106
  let audioSession = AVAudioSession.sharedInstance()
107
107
  var devices = [[String: Any]]()
108
108
 
109
- // 現在の設定をログ出力
110
- print("Current Category: \(audioSession.category.rawValue)")
111
- print("Current Mode: \(audioSession.mode.rawValue)")
112
- print("Current Route: \(audioSession.currentRoute)")
113
-
114
- // 変更前のルートを保持
115
- let originalRoute = audioSession.currentRoute
109
+ // ロックを取得して状態変更を防ぐ
110
+ objc_sync_enter(audioSession)
111
+ defer { objc_sync_exit(audioSession) }
116
112
 
117
113
  do {
118
- // セッションを変更せずにデバイス情報を取得
114
+ // 現在のルートを強制保持
115
+ let originalRoute = audioSession.currentRoute
116
+ print("Original Route: \(originalRoute)")
117
+
118
+ // カテゴリ変更を完全に排除
119
119
  let availableInputs = audioSession.availableInputs ?? []
120
120
  for port in availableInputs {
121
121
  devices.append([
@@ -126,8 +126,8 @@ public class VoiceRecorder: CAPPlugin {
126
126
  ])
127
127
  }
128
128
 
129
- let currentOutputs = audioSession.currentRoute.outputs
130
- for port in currentOutputs {
129
+ // 出力デバイスは現在のルートから取得(変更なし)
130
+ for port in originalRoute.outputs {
131
131
  devices.append([
132
132
  "deviceId": port.uid,
133
133
  "kind": "audiooutput",
@@ -136,14 +136,15 @@ public class VoiceRecorder: CAPPlugin {
136
136
  ])
137
137
  }
138
138
 
139
- // ルートが変更されたか確認
139
+ // ルート変更検知
140
140
  if audioSession.currentRoute != originalRoute {
141
- print("Route changed during operation!")
141
+ print("Route changed unexpectedly!")
142
142
  print("New Route: \(audioSession.currentRoute)")
143
+ throw NSError(domain: "AudioSessionError", code: 1, userInfo: nil)
143
144
  }
144
145
 
145
146
  } catch {
146
- call.reject("Failed to get audio devices: \(error.localizedDescription)")
147
+ call.reject("Audio session conflict: \(error.localizedDescription)")
147
148
  return
148
149
  }
149
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-voice-recorder-wav-stereo",
3
- "version": "7.0.7",
3
+ "version": "7.0.9",
4
4
  "description": "Capacitor plugin for voice recording in wav format",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",