Audio input, Audio optimisation

This commit is contained in:
Niellun
2025-06-03 07:05:47 +03:00
committed by Niellune
parent cb13925433
commit 5e97501c0c
17 changed files with 304 additions and 68 deletions
+36 -32
View File
@@ -1,7 +1,9 @@
# FastCarPlay
This is C++ implementation of carplay receiver for "Autobox" dongles.
This is C++ implementation of Carplay receiver and Android Auto receiver for "Autobox" dongles.
The purpose of the project is to make application lightweight to run on Raspberry PI Zero 2W using hardware decoding.
![Logo](docs/images/screenshot.png)
## Dongles
The dongles are readily available from Amazon or Aliexpress labeled by Carlinkit. They also seems to have official web site https://www.carlinkit.com/.
Devices might have different vendor and product id's. Check your with lsusb and update settings if necessary.
@@ -18,7 +20,7 @@ sudo apt install ffmpeg libsdl2-2.0-0 libsdl2-ttf-2.0-0 libusb-1.0-0 libssl3
```
### USB Permissions and device id
On linux app may not have permisiions to read USB device. You need to create udev rule to grant persmissions for dongle.
On linux app may not have permissions to read USB device. You need to create udev rule to grant permissions for dongle.
First you need to figure out your idVendor and idProduct.
```
lsusb
@@ -52,7 +54,8 @@ cp ./settings.txt /conf
### Customisation
You can change font and background images by replacing files in ./src/resource
- background.bmp for background image. Use BMP format only.
- font.ttf for font. Use TTF fdrmat only
- font.ttf for font. Use TTF format only
- you can edit colours.h to modify text colours in RGBA format
The names of the file need to be exactly same. Resources are embedded in executable, remake the project to regenerate resources
```
@@ -67,55 +70,56 @@ The following keys have been mapped:
- Enter - select active item
- Backspace - Go back
- f - toggle fullscreen mode
- q - exit
- r - force refresh
## Status
What is working:
- Carplay and Android Auto
- Video
- Audio (multiple channels)
- Key navigation
- Simple touch
- Microphone (calls, siri)
What is not working:
- Multi touch - i have no means to test it
- Microphone - that's next step for me to figure out how to feed sound
- Telephone - the listening part will work, but because there is no mic implementation you can't speak
- Multi touch - i have no means to test it and no idea how it should work
- Some android keys are not mapped
- No methods to edit autoconnect list or switch wireless devices
### Notes
Regardless the resolution there are 2 types of settings
- source-width source-height source-fps - defines what video parameters will be requested from device
- width height fps - defines video drawing resolution and fps
The SDL will anyway scale the image to your screen/window size using internal HW scaling, so ideally you should use same values for width and height.
If the source parameters will be different the scaling will be applied, however that scaling is not hardware accelerated and can consume a lot of CPU.
You can set the 'scaler' in setting to define scaling algorithm. On my Raspbery Pi Zero 2W even easiest algorithm loads CPU to 100% and cause fram drop.
Increasing FPS above Source-FPS will cause app to run UI loop with less delays and do more event polling. This can increase responsivenes of the system, but also will make X11 to use more resources.
- Do not try to run debug builds if you do not need to debug application. They consume a lot of memory for address sanitising thats grow over time.
- Increasing FPS above Source-FPS will cause app to run UI loop with less delays and do more event polling. This can increase responsivenes of the system, but also will make X11 to use more resources.
- For multichannel audion (driving guidance over music) you need to have multichannel driver in the system (puslsaudio, pipewire). If you only have ALSA backend the second channel will not work
- Android has it's own video resolution system which is fixed for 480p 720p 1080p. So set up resolution that is closest to what you want and adjust DPI for UI scale. If you do not have full screen Android Auto, you might need to enable resolution negotiation. Go to Android Auto app info and search for "Additional settings in the app" option. Scrol down and tap fast 5 times on version. Now you can use top right three dots menu to go to "Developer settings". Tap "Video Resolution" and select "Allow to car and phone to negotiate".
### Progress and plans
Done
- Implement direct buffer transfer from video decoder to renderer (should reduce amount of memory copies and CPU load)
- Control audio buffers better (now system use 3 decoding threads but in reality only 2 required)
- Reduce music volume when there is navigation messages
- Add abilities to run script on device connect and device disconnect
- Add encrypted USB communication option with magic code 0x55bb55bb for new firmware
- Improve touch responsiveness
- Protocol debugging option + python script to decode usb dumps
- Android Auto (have not tested much, but seems to work for me)
- [x] Implement direct buffer transfer from video decoder to renderer (should reduce amount of memory copies and CPU load)
- [x] Control audio buffers better (now system use 3 decoding threads but in reality only 2 required)
- [x] Reduce music volume when there is navigation messages
- [x] Add abilities to run script on device connect and device disconnect
- [x] Add encrypted USB communication option with magic code 0x55bb55bb for new firmware
- [x] Improve touch responsiveness
- [x] Protocol debugging option + python script to decode usb dumps
- [x] Android Auto (have not tested much, but seems to work for me)
- [x] Microphone support (Calls, Siri)
Next
- Add microphone support (Calls, Siri)
- CAR menu with status, settings and options to run custom scripts
- [ ] Car menu with status, settings and options to run custom scripts
- [ ] Canbus script communication or some sort of side key press handling
- [ ] Better android navigation
- [ ] Switch between wireless devices
## Acknowledgement
The project is inspired and based on great work done by other developers:
- ![pycarplay by electric-monk](https://github.com/electric-monk/pycarplay)
- ![carplay-receiver by harrylepotter](https://github.com/harrylepotter/carplay-receiver)
- ![react-carplay by rhysmorgan134](https://github.com/rhysmorgan134/react-carplay)
- ![carplay-client by rayphee](https://github.com/rayphee/carplay-client)
- [pycarplay by electric-monk](https://github.com/electric-monk/pycarplay)
- [carplay-receiver by harrylepotter](https://github.com/harrylepotter/carplay-receiver)
- [react-carplay by rhysmorgan134](https://github.com/rhysmorgan134/react-carplay)
- [carplay-client by rayphee](https://github.com/rayphee/carplay-client)
The project is licenced under GPL-3 licence. See LICENCE for details.
The project is using Open Sans font (https://fonts.google.com/specimen/Open+Sans). See FONT_LICENCE for details.
The project is using [Open Sans font](https://fonts.google.com/specimen/Open+Sans). See FONT_LICENCE for details.
## Finally
If you have any questions, suggestions or you find problems running this feel free to open issue.
If you have any questions, suggestions or you find problems running this feel free to open issue.