@@ -66,14 +66,7 @@ class AudioDeviceManager(
6666 EndpointMaps (bluetoothEndpoints, nonBluetoothEndpoints)
6767 }
6868
69- private var _cachedAvailableEndpointNamesSet = setOf<String >()
70- private var cachedAvailableEndpointNamesSet: Set <String >
71- get() = _cachedAvailableEndpointNamesSet
72- set(value) {
73- _cachedAvailableEndpointNamesSet = value
74- // send an event to the frontend everytime the list of available endpoints changes
75- sendAudioStatusEvent();
76- }
69+ private var cachedAvailableEndpointNamesSet = setOf<String >()
7770
7871 /* * Returns the currently selected audio device. */
7972 private var _selectedAudioDeviceEndpoint : AudioDeviceEndpoint ? = null
@@ -384,6 +377,11 @@ class AudioDeviceManager(
384377 ))
385378 )
386379
380+ if (devicesChanged) {
381+ // notify the frontend that the available devices changed
382+ this .sendAudioStatusEvent();
383+ }
384+
387385 // Double-check if any Bluetooth headset is connected once again (useful for older android platforms)
388386 // TODO: we can possibly remove this, to be tested on older platforms
389387 if (bluetoothManager.bluetoothState == BluetoothManager .State .HEADSET_AVAILABLE || bluetoothManager.bluetoothState == BluetoothManager .State .HEADSET_UNAVAILABLE ) {
@@ -511,7 +509,7 @@ class AudioDeviceManager(
511509 if (audioFocusLost) {
512510 // removing the currently selected device store, as its untrue
513511 selectedAudioDeviceEndpoint = null
514- // removing the currectly selected device store will make sure a device selection is made
512+ // removing the currently selected device store will make sure a device selection is made
515513 updateAudioDeviceState()
516514 }
517515 audioFocusLost = false
@@ -524,7 +522,7 @@ class AudioDeviceManager(
524522 }
525523 }
526524
527- fun audioStatusMap (): WritableMap {
525+ private fun audioStatusMap (): WritableMap {
528526 val endpoint = this .selectedAudioDeviceEndpoint
529527 val availableEndpoints = Arguments .fromList(getCurrentDeviceEndpoints().map { it.name })
530528
@@ -535,7 +533,7 @@ class AudioDeviceManager(
535533 return data
536534 }
537535
538- fun sendAudioStatusEvent () {
536+ private fun sendAudioStatusEvent () {
539537 try {
540538 if (mReactContext.hasActiveReactInstance()) {
541539 val payload = audioStatusMap()
0 commit comments