In the previous article, I described how I explored the hardware of the Vordon VW-910S, investigated some of Android's features, and tested its ability to interact with the vehicle's electronics.
After the initial experiments, I temporarily put the head unit aside because my main focus was on developing CaRaBack.
By that point, the concept of CaRadio had already changed significantly from the original idea. The system now consisted of two main components: CaRaBack handled communication with the iPhone and the CarPlay protocols, while the client application was responsible for displaying video, playing audio, and sending user commands.
When CaRaBack development reached the stage where further progress required full interaction with a client application, it was time to return to the Android head unit.
The First C++ and SDL Implementation
Initially, I decided to use an approach I was already familiar with.
Previous versions of CaRadio and the client application had been developed in C++ using SDL, so continuing with the same technologies seemed like a logical choice.
SDL also supports Android, which meant that a significant portion of the existing work could be reused on the new platform.
This led to the first version of the Android client application, written in C++ and SDL.
Its main purpose was to communicate with CaRaBack, receive the video stream, and display it on the head unit's screen.
After completing the initial development, I installed the application on the Vordon VW-910S, and the head unit was mounted in the car.
Everything seemed to be going according to plan.
However, the very first drive showed that the system was not performing as well as I had hoped.
Performance Problems
While driving, I began noticing occasional freezes and stuttering in the displayed image.
The problem was especially noticeable when using navigation. The map did not update smoothly enough, and sometimes there were visible delays in the image.
At first, it looked like either the head unit lacked sufficient processing power or the data transmission from CaRaBack was unstable.
However, understanding the actual cause required a closer investigation.
I removed the head unit from the car again and brought it back home to my workbench.
After examining the application's behavior, I discovered that the main problem was related to how the video stream was displayed.
Hardware Decoding Is Not Enough
CaRaBack sends an H.264 video stream to the client application, which must decode it and display it on the screen.
Android provides hardware decoding through MediaCodec. However, hardware decoding alone does not guarantee efficient video rendering.
The first implementation used SDL, and this was where the limitation appeared.
With the approach I had chosen for SDL, I could not arrange for the decoded video to be displayed directly from the hardware decoder to the screen.
As a result, additional operations on video frames were required, increasing the CPU load.
On a sufficiently powerful device, this might have gone unnoticed, but the MediaTek MT8321 in my head unit is far from a high-performance processor.
The extra video frame processing pushed the CPU almost to its limits.
This caused the delays that were particularly noticeable during navigation.
The problem was not so much H.264 itself or the hardware decoder, but rather the path the decoded image took before reaching the screen.
Why Kotlin
In theory, the problem could have been solved while keeping the application in C++.
Android supports native code and provides mechanisms for custom video rendering. However, this would have required additional platform-specific components and made the interaction between C++, SDL, and Android more complicated.
Such an approach was certainly possible, but it conflicted with one of the goals of the new CaRadio version: simplifying the system and eliminating unnecessary intermediate solutions.
After exploring the available options, I decided to move the application to Kotlin.
This allowed me to use Android's standard mechanisms directly, without having to adapt video rendering to SDL.
The main change was how MediaCodec was used.
Instead of retrieving decoded frames and then displaying them through SDL, the video decoder now renders directly to an Android Surface.
This means the decoded frames no longer need to pass through an intermediate software rendering path.
It significantly reduces the number of additional operations and the load on the CPU.
The CaRaBack architecture itself remained unchanged. It still handles communication with the iPhone and transfers the necessary data to the client application.
Only the Android client implementation changed.
Is a Multi-Window System Really Necessary?
During development, I noticed another interesting detail.
CaRadio was originally designed for Raspberry Pi, where practically every head unit function had to be implemented manually.
That was why I had planned a full multi-window application combining the different features of an automotive multimedia system.
However, the Android head unit already had its own operating system and ready-made software.
Many of the features I had planned to implement myself on Raspberry Pi were already available out of the box.
For example, multimedia handling, system settings, audio control, and interaction with some of the vehicle's hardware.
Gradually, I realized that there was simply no need to transfer the entire original CaRadio architecture to Android.
Why develop something again when it already exists and works?
Instead of building a large multi-window application, I could focus on the functions that were actually needed: communication with CaRaBack, displaying CarPlay, playing audio, and handling user input.
The remaining features could be left to the standard Android system when necessary.
As a result, the new version of CaRadio became not only technically different but also considerably simpler in its overall concept.
Current Project Status
In the end, the initial C++ and SDL implementation was replaced by an application written in Kotlin.
The system now consists of two main parts:
- CaRaBack — handles communication with the iPhone, CarPlay protocols, and the transmission of audio and video data.
- CaRadio v2 — a Kotlin Android application that receives data from CaRaBack, displays the video stream using MediaCodec and Android Surface, plays audio, and sends user commands.
This approach made it possible to use Android's capabilities directly and eliminate some of the solutions that had been necessary when developing the Raspberry Pi-based head unit.
Switching to Kotlin was never a goal in itself. I still consider C++ a suitable tool for this kind of work, as demonstrated by the development of CaRaBack.
However, in this particular case, using Android's native mechanisms proved to be the more practical solution.
The CaRadio v2 story once again demonstrated that transferring an existing architecture to a new platform without changes is not always the best approach.
Sometimes it makes more sense to reconsider the design itself and take advantage of the hardware and operating system already available.
There was still more work ahead: further integration with the vehicle, real-world testing, and optimizing the system to run on hardware that was far from powerful.