diff --git a/server/index.js b/server/index.js index 27fc145..636842f 100644 --- a/server/index.js +++ b/server/index.js @@ -103,6 +103,7 @@ const proxy = httpProxy.createProxyServer({ let currentUsers = 0; let serialport; +let timeoutAntenna; app.use(bodyParser.urlencoded({ extended: true })); const sessionMiddleware = session({ @@ -526,15 +527,18 @@ wss.on('connection', (ws, request) => { } // Handle Antenna selection - if (serverConfig.antennaNoUnsers === "1") { - output.write("Z0\n"); - } else if (serverConfig.antennaNoUnsers === "2") { - output.write("Z1\n"); - } else if (serverConfig.antennaNoUnsers === "3") { - output.write("Z2\n"); - } else if (serverConfig.antennaNoUnsers === "4") { - output.write("Z3\n"); - } + if (timeoutAntenna) clearTimeout(timeoutAntenna); + timeoutAntenna = setTimeout(() => { + if (serverConfig.antennaNoUsers === "1") { + output.write("Z0\n"); + } else if (serverConfig.antennaNoUsers === "2") { + output.write("Z1\n"); + } else if (serverConfig.antennaNoUsers === "3") { + output.write("Z2\n"); + } else if (serverConfig.antennaNoUsers === "4") { + output.write("Z3\n"); + } + }, serverConfig.antennaNoUsersDelay ? 15000 : 0); } if (tunerLockTracker.has(ws)) { diff --git a/server/server_config.js b/server/server_config.js index 5f754dc..8e8a344 100644 --- a/server/server_config.js +++ b/server/server_config.js @@ -115,7 +115,8 @@ let serverConfig = { stereoStartup: "0", stereoNoUsers: "0", antennaStartup: "0", - antennaNoUnsers: "0" + antennaNoUsers: "0", + antennaNoUsersDelay: false }; // Function to add missing fields without overwriting existing values diff --git a/web/setup.ejs b/web/setup.ejs index bfc20e0..ee723d3 100644 --- a/web/setup.ejs +++ b/web/setup.ejs @@ -227,7 +227,7 @@

Legacy option for Linux / macOS that could resolve audio issues, but will consume additional CPU and RAM usage.

<%- include('_components', {component: 'checkbox', cssClass: '', label: 'Additional FFmpeg', id: 'audio-ffmpeg'}) %> -
+

Sample rate offset

Using a negative value could eliminate audio buffering issues during long periods of listening.
However, a value that’s too low might increase the buffer over time.

@@ -479,7 +479,7 @@
-
+

On no active users

Settings take effect immediately after saving

@@ -530,7 +530,8 @@ }) %>
- <%- include('_components', { component: 'dropdown', id: 'antennaNoUnsers-dropdown', inputId: 'antennaNoUnsers', label: 'Antenna', cssClass: '', placeholder: 'Unchanged', + <%- include('_components', {component: 'checkbox', cssClass: '', label: 'Delayed Antenna Change', id: 'antennaNoUsersDelay'}) %>
+ <%- include('_components', { component: 'dropdown', id: 'antennaNoUsers-dropdown', inputId: 'antennaNoUsers', label: 'Antenna', cssClass: '', placeholder: 'Unchanged', options: [ { value: '0', label: 'Unchanged' }, { value: '1', label: 'Antenna 0' }, @@ -538,7 +539,8 @@ { value: '3', label: 'Antenna 2' }, { value: '4', label: 'Antenna 3' }, ] - }) %>
+ }) %> +