private fun onRtspClientStopped() {
if (DEBUG) Log.v(TAG, "onRtspClientStopped()")
uiHandler.post { statusListener?.onRtspStatusDisconnected() }
stopDecoders()
rtspThread = null
}
The listener is notified before the rtspThread is set to null. So in the start method there can be a NullPointerException in one of the 2 last lines:
fun start(requestVideo: Boolean, requestAudio: Boolean) {
if (DEBUG) Log.v(TAG, "start(requestVideo=$requestVideo, requestAudio=$requestAudio)")
if (rtspThread != null) rtspThread?.stopAsync()
this.requestVideo = requestVideo
this.requestAudio = requestAudio
rtspThread = RtspThread()
rtspThread!!.name = "RTSP IO thread [${getUriName()}]" // NullPointerException here
rtspThread!!.start() // Or NullPointerException here
}
I propose the following fix (post the listener after rtspThread is set to null):
private fun onRtspClientStopped() {
if (DEBUG) Log.v(TAG, "onRtspClientStopped()")
stopDecoders()
rtspThread = null
uiHandler.post { statusListener?.onRtspStatusDisconnected() } // Move this line after nullifying everything
}
The problem is in this method:
The listener is notified before the rtspThread is set to null. So in the start method there can be a NullPointerException in one of the 2 last lines:
I propose the following fix (post the listener after rtspThread is set to null):