Audio driver and audio delay settings

This commit is contained in:
Niellun
2025-06-02 07:15:13 +03:00
parent cdc68e4191
commit 44faedbbdd
5 changed files with 45 additions and 10 deletions
+5 -4
View File
@@ -28,11 +28,12 @@ You will see list of devices, try to find the one that looks like dongle. Also y
Bus 003 Device 066: ID 1314:1520 Magic Communication Tec. Auto Box
```
So in my case ID 1314:1520 shows idVendor 1314 and idProduct 1520. We need to use those to create udev rules. If yours are different you also need to put them in settings.txt and run application with settings.txt as argument. Remember that in settings.txt values are in decimal, so you need to convert hex values to base 10 first.
Create udev rules, replace <__Vendor__> <__Product__> and <__Your user__> with your informations
Create udev rules and add user to plugdev group, replace <__Vendor__> <__Product__> and <__Your user name__> with your informations
```
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="<Vendor>", ATTRS{idProduct}=="<Product>", GROUP="<Your user>", MODE="0660"' | sudo tee /etc/udev/rules.d/50-carlinkit.rules
## example
## SUBSYSTEM=="usb", ATTRS{idVendor}=="1314", ATTRS{idProduct}=="1520", GROUP="linux", MODE="0660"
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="<Vendor>", ATTRS{idProduct}=="<Product>", GROUP="plugdev", MODE="0660"' | sudo tee /etc/udev/rules.d/50-carlinkit.rules
## example: SUBSYSTEM=="usb", ATTRS{idVendor}=="1314", ATTRS{idProduct}=="1520", GROUP="plugdev", MODE="0660"
sudo usermod -aG plugdev <Your user name>
## example: sudo usermod -aG plugdev linux
sudo udevadm control --reload-rules
sudo udevadm trigger
```
+10
View File
@@ -77,6 +77,9 @@
# 3 - 1080p => 1920x1080
#android-resolution = 1
# Media delay for android auto
#android-media-delay = 300
##############################################################################
# 3.Application configuration
##############################################################################
@@ -106,6 +109,13 @@
# Reduction level from 1 (no reduction) to 0 (fully silenced)
#audio-fade = 0.3
# Force application to use following audio driver as audio output, if empty use default driver
# See SDL documentation for options. Some of them are
# alsa - Not supporting multiple channels, navigation over music will not work
# pulseaudio
# pipewire
#audio-driver =
# Run script or app on phone connected and disconnected.
# This script/app should be fast, otherwise it will block system.
# If you need to start application in background use scripts with fork
+25 -4
View File
@@ -59,7 +59,7 @@ void processKey(Protocol &protocol, SDL_Keysym key, RunParams &params)
case SDLK_r:
params.dirty = true;
break;
break;
case SDLK_LEFT:
protocol.sendKey(100);
@@ -206,11 +206,11 @@ void application()
Uint32 frameStart = SDL_GetTicks();
while (active)
{
if(processEvents(protocol, p, interface))
if (processEvents(protocol, p, interface))
{
if(p.connected)
if (p.connected)
{
decoder.flush();
decoder.flush();
videoBuffer.reset();
}
}
@@ -253,6 +253,23 @@ void application()
SDL_HideWindow(window);
}
bool setAudioDriver()
{
if (Settings::audioDriver.value.length() < 2)
return true;
int num = SDL_GetNumAudioDrivers();
for (int i = 0; i < num; ++i)
{
if (SDL_GetAudioDriver(i) == Settings::audioDriver.value)
{
SDL_setenv("SDL_AUDIODRIVER", SDL_GetAudioDriver(i), 1);
return true;
}
}
return false;
}
int start()
{
if (!Settings::logging)
@@ -260,12 +277,16 @@ int start()
else
Settings::print();
if (!setAudioDriver())
std::cerr << "[Main] Not supported audio driver " << Settings::audioDriver.value << std::endl;
// Initialize SDL video subsystem
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) != 0)
{
std::cerr << "[Main] SDL initialisation failed: " << SDL_GetError() << std::endl;
return 1;
}
std::cout << "[Main] SDL audio driver: " << SDL_GetCurrentAudioDriver() << std::endl;
if (TTF_Init() != 0)
{
+1 -2
View File
@@ -52,7 +52,6 @@ void Protocol::sendInit(int width, int height, int fps)
void Protocol::sendConfig()
{
int syncTime = std::time(nullptr);
int mediaDelay = 300;
int drivePosition = Settings::leftDrive ? 0 : 1; // 0==left, 1==right
int nightMode = Settings::nightMode; // 0==day, 1==night, 2==auto
if (nightMode < 0 || nightMode > 2)
@@ -95,7 +94,7 @@ void Protocol::sendConfig()
"{\"syncTime\":%d,\"mediaDelay\":%d,\"drivePosition\":%d,"
"\"androidAutoSizeW\":%d,\"androidAutoSizeH\":%d,\"HiCarConnectMode\":0,"
"\"GNSSCapability\":7,\"DashboardInfo\":1,\"UseBTPhone\":0}",
syncTime, mediaDelay, drivePosition, width, height);
syncTime, Settings::mediaDelay.value, drivePosition, width, height);
sendString(CMD_JSON_CONTROL, buffer);
+4
View File
@@ -28,6 +28,9 @@ public:
static inline Setting<int> micType{"mic-type", 1};
static inline Setting<int> dpi{"android-dpi", 120};
static inline Setting<int> androidMode{"android-resolution", 0};
static inline Setting<int> mediaDelay{"android-media-delay", 300};
// Application configuration section
static inline Setting<int> fontSize{"font-size", 30};
@@ -38,6 +41,7 @@ public:
static inline Setting<int> audioQueue{"audio-buffer-size", 16};
static inline Setting<int> audioDelay{"audio-buffer-wait", 2};
static inline Setting<float> audioFade{"audio-fade", 0.3};
static inline Setting<std::string> audioDriver{"audio-driver", ""};
static inline Setting<std::string> onConnect{"on-connect-script", ""};
static inline Setting<std::string> onDisconnect{"on-disconnect-script", ""};