Skip to content

Improve video decoder resync handling to prevent freezes (fix for Waze accumulating latency) - #49

Open
14praveenk wants to merge 2 commits into
MaKi983:mainfrom
14praveenk:codex/video-decoder-sync
Open

Improve video decoder resync handling to prevent freezes (fix for Waze accumulating latency)#49
14praveenk wants to merge 2 commits into
MaKi983:mainfrom
14praveenk:codex/video-decoder-sync

Conversation

@14praveenk

Copy link
Copy Markdown

This pull request introduces several improvements to video decoding robustness, buffer management, and code safety across both the JNI C++ backend and the Android Java video output. The main focus is on smarter handling of H.264 video frame synchronization, improved buffer overflow management, and minor code cleanups.

Video decoder synchronization and buffer management improvements

  • Added a new H264NalParser.h utility to inspect H.264 NAL units, enabling detection of keyframes (IDR) and codec configuration frames. This is now used in OMXSource to improve sync handling. [1] [2]
  • Enhanced OMXSource::queueBuffer to detect decoder backlog, drop frames until a keyframe is found, and avoid freezes by timing out if no keyframe arrives. This prevents buffer overflows and ensures the decoder can resynchronize after interruptions. [1] [2]
  • Refactored buffer clearing into a new clearQueuedBuffers() method, used both for overflow and on stop, reducing code duplication and improving safety. [1] [2]

JNI/C++ code safety and cleanup

  • Fixed uninitialized pointer in OMXDecoder::read, and simplified timestamp handling for buffer queuing. [1] [2]
  • Removed unnecessary includes and dead code in Timestamp.cpp, and corrected timestamp extraction using memcpy for portability and correctness. [1] [2]

Android Java video output improvements

  • Made configured_ and running_ flags in NativeVideoOutput volatile for thread safety, adjusted codec thread start order, and set a nonzero timeout for output buffer dequeue to improve playback reliability. [1] [2] [3]

These changes collectively make the video pipeline more robust against stream interruptions, decoder backlogs, and threading issues.

@Ozzy666cz

Copy link
Copy Markdown

Hi, can't you release an apk somewhere so I can download it? If it's more stable?

@14praveenk

Copy link
Copy Markdown
Author

Hi, can't you release an apk somewhere so I can download it? If it's more stable?

Yes, you can try with this build. You will need to uninstall any previous version of OpenDroidAuto for it to install.
https://github.com/14praveenk/OpenDroidAuto/releases/tag/2.5.2-latencyfix

@Ozzy666cz

Copy link
Copy Markdown

Thank you! Will you still be working on this app or will Maki continue?

@RSpliet

RSpliet commented Jul 25, 2026

Copy link
Copy Markdown

Just installed this "latency fix" apk, started it up and toyed around with VLC and GMaps through Android Auto, so far so good, no major regressions at least. Never noticed latency issues (not using Waze), but the decoder improvements sound like they might just be general stability improvements too. Fingers crossed that they resolve the occasional application crash that required me to restart OpenDroidAuto on the road.

@amb007

amb007 commented Jul 27, 2026

Copy link
Copy Markdown

Is the latency - you are talking about - manifesting by seeing the car way behind (stale position, sometimes not even moving) or (less often) ahead (somehow extrapolated, "thinking" I have chosen another turn)? If not, I will search other open issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants