diff --git a/README.md b/README.md index ccb0b8c..6e40be1 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,11 @@ sudo ./provision_domain_hostname.sh - If you have issues with mDNS name resolution, check for conflicting mDNS stacks (e.g., systemd-resolved, Bonjour, or other daemons). - Some Linux clients may not resolve multi-label mDNS names via NSS—test with `avahi-resolve-host-name` and try from another device if needed. +# uart reset over hci does not work: +stty -F /dev/ttyAMA3 -hupcl +stty -F /dev/ttyAMA3 -a | grep -o 'hupcl' || echo "-hupcl is set" + + # Audio latency if there is hearable audio error with aes67, tune sess.latency.msec in pipewire-aes67.conf @@ -202,7 +207,7 @@ sudo ldconfig # refresh linker cache - sudo modprobe i2c-dev - echo i2c_bcm2835 | sudo tee -a /etc/modules - echo i2c-dev | sudo tee -a /etc/modules -- read temp /src/scripts/temp +- read temp /src/scripts/temp # Known issues: - When running on a laptop there might be issues switching between usb and browser audio input since they use the same audio device diff --git a/src/auracast/server/multicast_server.py b/src/auracast/server/multicast_server.py index 8f0e960..8bd2f34 100644 --- a/src/auracast/server/multicast_server.py +++ b/src/auracast/server/multicast_server.py @@ -263,58 +263,55 @@ async def _autostart_from_settings(): return while True: - try: - # Do not interfere if user started a stream manually in the meantime - if multicaster1 and multicaster1.get_status().get('is_streaming'): + # Do not interfere if user started a stream manually in the meantime + if multicaster1 and multicaster1.get_status().get('is_streaming'): + return + # Abort if saved settings changed to a different target while we were polling + current_settings = load_stream_settings() or {} + if current_settings.get('timestamp') != original_ts: + # Settings were updated (likely by user via /init) + # If the target device or mode changed, stop autostart + if ( + current_settings.get('input_device') != input_device_name or + current_settings.get('audio_mode') != audio_mode + ): return - # Abort if saved settings changed to a different target while we were polling - current_settings = load_stream_settings() or {} - if current_settings.get('timestamp') != original_ts: - # Settings were updated (likely by user via /init) - # If the target device or mode changed, stop autostart - if ( - current_settings.get('input_device') != input_device_name or - current_settings.get('audio_mode') != audio_mode - ): - return - # Avoid refreshing PortAudio while we poll - usb = [d for _, d in list_usb_pw_inputs(refresh=False)] - net = [d for _, d in list_network_pw_inputs(refresh=False)] - names = {d.get('name') for d in usb} | {d.get('name') for d in net} - if input_device_name in names: - # Build a minimal config based on saved fields - bigs = [ - auracast_config.AuracastBigConfig( - name=channel_names[0] if channel_names else "Broadcast0", - program_info=program_info[0] if isinstance(program_info, list) and program_info else program_info, - language=languages[0] if languages else "deu", - audio_source=f"device:{input_device_name}", - input_format=f"int16le,{rate},1", - iso_que_len=1, - sampling_frequency=rate, - octets_per_frame=octets, - ) - ] - conf = auracast_config.AuracastConfigGroup( - auracast_sampling_rate_hz=rate, + # Avoid refreshing PortAudio while we poll + usb = [d for _, d in list_usb_pw_inputs(refresh=False)] + net = [d for _, d in list_network_pw_inputs(refresh=False)] + names = {d.get('name') for d in usb} | {d.get('name') for d in net} + if input_device_name in names: + # Build a minimal config based on saved fields + bigs = [ + auracast_config.AuracastBigConfig( + name=channel_names[0] if channel_names else "Broadcast0", + program_info=program_info[0] if isinstance(program_info, list) and program_info else program_info, + language=languages[0] if languages else "deu", + audio_source=f"device:{input_device_name}", + input_format=f"int16le,{rate},1", + iso_que_len=1, + sampling_frequency=rate, octets_per_frame=octets, - transport=TRANSPORT1, - bigs=bigs, ) - # Initialize and start - await initialize(conf) - return - except Exception: - log.warning("Autostart polling encountered an error", exc_info=True) + ] + conf = auracast_config.AuracastConfigGroup( + auracast_sampling_rate_hz=rate, + octets_per_frame=octets, + transport=TRANSPORT1, + bigs=bigs, + ) + # Initialize and start + await initialize(conf) + return await asyncio.sleep(2) except Exception: log.warning("Autostart task failed", exc_info=True) -@app.on_event("startup") -async def _startup_autostart_event(): - # Spawn the autostart task without blocking startup - asyncio.create_task(_autostart_from_settings()) +# @app.on_event("startup") +# async def _startup_autostart_event(): +# # Spawn the autostart task without blocking startup +# asyncio.create_task(_autostart_from_settings()) @app.post("/refresh_audio_inputs") @@ -348,8 +345,6 @@ async def refresh_audio_inputs(force: bool = False): return {"status": "ok", "inputs": [], "stopped_stream": stopped} - - @app.get("/audio_inputs_pw_usb") async def audio_inputs_pw_usb(): """List PipeWire USB input nodes mapped to sounddevice indices. diff --git a/src/service/stop_server_and_frontend.sh b/src/service/stop_server_and_frontend.sh index f91fbd1..d467b10 100644 --- a/src/service/stop_server_and_frontend.sh +++ b/src/service/stop_server_and_frontend.sh @@ -2,15 +2,15 @@ # Requires sudo privileges echo "Stopping auracast-frontend.service ..." -sudo systemctl stop auracast-frontend.service +sudo systemctl kill auracast-frontend.service sudo systemctl disable auracast-frontend.service echo "Stopping auracast-server.service..." -systemctl --user stop auracast-server.service +systemctl --user kill auracast-server.service systemctl --user disable auracast-server.service - +sudo systemctl kill auracast-server.service +sudo systemctl disable auracast-server.service +sudo rm -f /etc/systemd/system/auracast-server.service sudo systemctl status auracast-frontend.service --no-pager systemctl --user status auracast-server.service --no-pager - -echo "auracast-server and auracast-frontend services stopped, disabled, and status printed successfully." diff --git a/src/service/update_and_run_server_and_frontend.sh b/src/service/update_and_run_server_and_frontend.sh index fc93513..7dc42af 100644 --- a/src/service/update_and_run_server_and_frontend.sh +++ b/src/service/update_and_run_server_and_frontend.sh @@ -7,7 +7,7 @@ set -e # Copy system service file for frontend sudo cp /home/caster/bumble-auracast/src/service/auracast-frontend.service /etc/systemd/system/auracast-frontend.service -# Copy user service file for backend (now using WantedBy=default.target) +# Copy user service file for backend mkdir -p /home/caster/.config/systemd/user cp /home/caster/bumble-auracast/src/service/auracast-server.service /home/caster/.config/systemd/user/auracast-server.service