@@ -26,7 +26,12 @@ private const val TAG = "AudioSwitch"
26
26
* should be routed to. It is strongly recommended that instances of this class are created and
27
27
* accessed from a single application thread. Accessing an instance from multiple threads may cause
28
28
* synchronization problems.
29
- */
29
+ *
30
+ * @property loggingEnabled A property to configure AudioSwitch logging behavior. AudioSwitch logging is disabled by
31
+ * default.
32
+ * @property selectedAudioDevice Retrieves the selected [AudioDevice] from [AudioSwitch.selectDevice].
33
+ * @property availableAudioDevices Retrieves the current list of available [AudioDevice]s.
34
+ **/
30
35
class AudioSwitch {
31
36
32
37
private var logger: Logger = ProductionLogger ()
@@ -67,58 +72,30 @@ class AudioSwitch {
67
72
}
68
73
}
69
74
70
- /* *
71
- * A property to configure AudioSwitch logging behavior. AudioSwitch logging is disabled by
72
- * default.
73
- */
74
75
var loggingEnabled: Boolean
75
- /* *
76
- * Returns `true` if logging is enabled. Returns `false` by default.
77
- */
78
76
get() = logger.loggingEnabled
79
77
80
- /* *
81
- * Toggle whether logging is enabled.
82
- */
83
78
set(value) {
84
79
logger.loggingEnabled = value
85
80
}
86
-
87
- /* *
88
- * Retrieves the selected [AudioDevice] from [AudioSwitch.selectDevice].
89
- *
90
- * @return the selected [AudioDevice]
91
- */
92
81
val selectedAudioDevice: AudioDevice ? get() = selectedDevice
93
-
94
- /* *
95
- * Retrieves the current list of available [AudioDevice]s.
96
- *
97
- * @return the current list of [AudioDevice]s
98
- */
99
82
val availableAudioDevices: List <AudioDevice > = mutableAudioDevices
100
83
101
84
/* *
102
85
* Constructs a new AudioSwitch instance.
103
- *
104
- * @param context An Android Context.
105
- * @param loggingEnabled Toggle whether logging is enabled. This argument is false by default.
106
- * @param audioFocusChangeListener A listener that is invoked when the system audio focus is updated.
86
+ * - [context] - An Android Context.
87
+ * - [loggingEnabled] - Toggle whether logging is enabled. This argument is false by default.
88
+ * - [audioFocusChangeListener] - A listener that is invoked when the system audio focus is updated.
107
89
* Note that updates are only sent to the listener after [activate] has been called.
108
- * @param preferredDeviceList The order in which [AudioSwitch] automatically selects and activates
90
+ * - [ preferredDeviceList] - The order in which [AudioSwitch] automatically selects and activates
109
91
* an [AudioDevice]. This parameter is ignored if the [selectedAudioDevice] is not `null`.
110
- *
111
92
* The default preferred [AudioDevice] order is the following:
112
- *
113
93
* [BluetoothHeadset], [WiredHeadset], [Earpiece], [Speakerphone]
114
- *
115
- * [preferredDeviceList] is added to the front of the default list. For example, if [preferredDeviceList]
94
+ * . The [preferredDeviceList] is added to the front of the default list. For example, if [preferredDeviceList]
116
95
* is [Speakerphone] and [BluetoothHeadset], then the new preferred audio
117
96
* device list will be:
118
- *
119
97
* [Speakerphone], [BluetoothHeadset], [WiredHeadset], [Earpiece].
120
- *
121
- * @throws IllegalArgumentException if the [preferredDeviceList] contains duplicate [AudioDevice] elements.
98
+ * An [IllegalArgumentException] is thrown if the [preferredDeviceList] contains duplicate [AudioDevice] elements.
122
99
*/
123
100
@JvmOverloads
124
101
constructor (
@@ -171,11 +148,9 @@ class AudioSwitch {
171
148
}
172
149
173
150
/* *
174
- * Starts listening for audio device changes. **Note:** When audio device listening is no
175
- * longer needed, [AudioSwitch.stop] should be called in order to prevent a
176
- * memory leak.
177
- *
178
- * @param listener receives audio device change events
151
+ * Starts listening for audio device changes and calls the [listener] upon each change.
152
+ * **Note:** When audio device listening is no longer needed, [AudioSwitch.stop] should be
153
+ * called in order to prevent a memory leak.
179
154
*/
180
155
fun start (listener : AudioDeviceChangeListener ) {
181
156
audioDeviceChangeListener = listener
@@ -253,11 +228,10 @@ class AudioSwitch {
253
228
}
254
229
255
230
/* *
256
- * Selects the desired [AudioDevice]. If the provided [AudioDevice] is not
257
- * available, no changes are made. If the provided [AudioDevice] is null, an [AudioDevice] is
258
- * chosen based on the following preference: Bluetooth, Wired Headset, Earpiece, Speakerphone.
259
- *
260
- * @param audioDevice The [AudioDevice] to use
231
+ * Selects the desired [audioDevice]. If the provided [AudioDevice] is not
232
+ * available, no changes are made. If the provided device is null, one is chosen based on the
233
+ * specified preferred device list or the following default list:
234
+ * [BluetoothHeadset], [WiredHeadset], [Earpiece], [Speakerphone].
261
235
*/
262
236
fun selectDevice (audioDevice : AudioDevice ? ) {
263
237
if (selectedDevice != audioDevice) {
0 commit comments