aws-samples / amazon-ivs-broadcast-android-sample

MIT No Attribution
9 stars 8 forks source link

Mic resource not being released #66

Open armanate opened 1 week ago

armanate commented 1 week ago

I have modified the camera initialization in the example project to support the zoom feature with the following code:

private fun getCameras(context: Context): List<Device?> {
    val discovery = DeviceDiscovery(context)
    val deviceList = discovery.listLocalDevices()
    val cameras = deviceList.filter { it.descriptor.type == DeviceType.CAMERA }
    return cameras
}

Previously, the default code was:

fun Context.getSortedCameraList(): List<Device.Descriptor> =
    listAvailableDevices(this).sortedBy { it.deviceId }.filter { it.type == Device.Descriptor.DeviceType.CAMERA }

However, I have encountered an issue. When session?.release() is called, the microphone resource is not being released, and the Android OS displays the microphone usage icon in the status bar, indicating that "Mic access is being used by BasicBroadcast."

kvasilye commented 6 days ago

I think what's missing is releasing the DeviceDiscovery object - I would recommend saving it in your Activity or ViewModel so it stays around for the duration of your broadcast session, and can release it when the Activity or ViewModel is destroyed.