@iternio/react-native-auto-play 0.5.10 → 0.5.11
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt
CHANGED
|
@@ -380,8 +380,11 @@ class VoiceInputManager(
|
|
|
380
380
|
) ?: -1
|
|
381
381
|
|
|
382
382
|
if (read < 0) {
|
|
383
|
-
// Whenever the user dismisses the microphone on the car screen, the next call to read will return -1
|
|
384
|
-
|
|
383
|
+
// Whenever the user dismisses the microphone on the car screen, the next call to read will return -1.
|
|
384
|
+
// But calling stop() ourselves also races CarAudioRecord's internal stream close against an
|
|
385
|
+
// in-flight read(), which can likewise surface as -1 — isRecording is already false by then
|
|
386
|
+
// (set before stopRecording() is called), so it distinguishes the two cases.
|
|
387
|
+
cancelledByUser = carAudioRecord != null && read == -1 && isRecording
|
|
385
388
|
break
|
|
386
389
|
}
|
|
387
390
|
|
|
@@ -439,6 +442,10 @@ class VoiceInputManager(
|
|
|
439
442
|
}
|
|
440
443
|
|
|
441
444
|
fun stop() {
|
|
445
|
+
// Mark as no longer recording before triggering any teardown side effects, so anything
|
|
446
|
+
// racing against a concurrent read() sees this is an app-initiated stop.
|
|
447
|
+
isRecording = false
|
|
448
|
+
|
|
442
449
|
// STT path: stopListening() triggers onResults/onError which resolves the continuation
|
|
443
450
|
activeSpeechRecognizer?.let { recognizer ->
|
|
444
451
|
UiThreadUtil.runOnUiThread {
|
|
@@ -446,7 +453,6 @@ class VoiceInputManager(
|
|
|
446
453
|
}
|
|
447
454
|
}
|
|
448
455
|
// PCM path and car-audio STT pump
|
|
449
|
-
isRecording = false
|
|
450
456
|
carAudioRecord?.stopRecording()
|
|
451
457
|
audioRecord?.stop()
|
|
452
458
|
}
|