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.
@@ -106,20 +106,16 @@ public class VoiceRecorder: CAPPlugin {
106
106
  let audioSession = AVAudioSession.sharedInstance()
107
107
  var devices = [[String: Any]]()
108
108
 
109
- // カテゴリ変更を防ぐためのフラグ
110
- var didChangeCategory = false
111
- let originalCategory = audioSession.category
112
- let originalMode = audioSession.mode
109
+ // ロックを取得して状態変更を防ぐ
110
+ objc_sync_enter(audioSession)
111
+ defer { objc_sync_exit(audioSession) }
113
112
 
114
113
  do {
115
- // カテゴリがPlayAndRecordの場合のみ変更
116
- if audioSession.category == .playAndRecord {
117
- try audioSession.setCategory(.ambient, mode: .default)
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
- let currentOutputs = audioSession.currentRoute.outputs
134
- for port in currentOutputs {
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 didChangeCategory {
145
- try audioSession.setCategory(originalCategory, mode: originalMode)
146
- try audioSession.setActive(true)
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("Failed to get audio devices: \(error.localizedDescription)")
147
+ call.reject("Audio session conflict: \(error.localizedDescription)")
151
148
  return
152
149
  }
153
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-voice-recorder-wav-stereo",
3
- "version": "7.0.8",
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",