twilio / audioswitch

An Android audio management library for real-time communication apps.
Apache License 2.0
160 stars 49 forks source link

[Feature request] need an API AudioSwitch.start() without parameter listener or manager multiple listeners #116

Open Tougee opened 2 years ago

Tougee commented 2 years ago

Thanks for making this convenient library!

Currently the start() must invoke with a listener parameter, and the listener parameter will override audioDeviceChangeListener which means it cannot use multiple listeners.

Is it possible to provide a start() without any parameters like this:

fun start(listener: AudioDeviceChangeListener) {
        audioDeviceChangeListener = listener
        start()
    }

fun start() {
        when (state) {
            STOPPED -> {
                bluetoothHeadsetManager?.start(bluetoothDeviceConnectionListener)
                wiredHeadsetReceiver.start(wiredDeviceConnectionListener)
                enumerateDevices()
                state = STARTED
            }
            else -> {
                logger.d(TAG, "Redundant start() invocation while already in the started or activated state")
            }
        }
    }

or provider some addListener() API to manager a list of audioDeviceChangeListener.