Restart the app when the low latency toggle changes - #121
Conversation
The low-latency keys from #113 are written into the AMediaFormat when the codec is configured, and the codec is only torn down when its surface goes away. VideoPlayer stop()/start() recycle the UDP receivers and leave the codec alone, and a channel change never touches the surface. So the toast "applies on next video start" promised something that only happened after backgrounding the app or restarting it; a pilot who turned the option off in the field and changed channel kept flying on the old configuration. Do what the VR mode toggle does and restart the app. The preference is read on startup, so the runtime setLowLatency() call in the click handler goes away. Two leftovers from #113 in the same area: setLowLatency() now runs verifyApplicationThread() like every other VideoPlayer setter, and the commented-out AMEDIAFORMAT_KEY_PRIORITY line in h264_configureAMediaFormat is dropped, since writeAndroidPerformanceParams() sets the real key.
PR Summary by QodoRestart app when low-latency decoder setting changes
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
Two review findings on the restart path. The preference was written with apply(), and resetApp() ends the process with System.exit() a few lines later. apply() flushes to disk on a background thread, so the new process could read the old value and come up with the configuration the pilot just switched away from. The VR mode toggle already uses commit() for the same reason; do the same here. resetApp() also killed an active DVR recording without closing the MP4: System.exit() skips every lifecycle callback, and the file is only finalized when the DVR thread exits. stopDvr() joins that thread, so call it first. This covers the VR mode toggle too, which had the same hole.
Follow-up to #113.
The low-latency keys are written into the
AMediaFormatwhen the codec is configured, and the codec is only torn down when its surface goes away (VideoDecoder::setOutputSurface(nullptr)).VideoPlayer::stop()/start()recycle the UDP/UDS receivers and leave the codec alone, and a channel change never touches the surface. So the toast "applies on next video start" only came true after backgrounding or restarting the app. A pilot who turned the option off in the field because of decoder artifacts and then changed channel kept flying on the old configuration.This does what the VR mode toggle does: write the preference and
resetApp(). The preference is read on startup, so the runtimesetLowLatency()call in the click handler goes away.Two small leftovers from #113 in the same area:
VideoPlayer.setLowLatency()now callsverifyApplicationThread()like every other setter in that class.AMEDIAFORMAT_KEY_PRIORITYline inh264_configureAMediaFormatis dropped;writeAndroidPerformanceParams()sets the real key.Not changed here:
resetApp()callsSystem.exit(0)and does not finalize an active DVR recording. That is pre-existing with the VR toggle and worth its own fix.Compile tested:
assembleDebug, arm64-v8a and armeabi-v7a.