Updates back on claude

This commit is contained in:
Logan
2026-04-12 01:32:05 -04:00
parent f8c58dbda8
commit 26d21d42e1
3 changed files with 26 additions and 27 deletions
+7 -4
View File
@@ -27,12 +27,15 @@ class CallRecorder:
self._current_file = self._recordings_dir / f"{ts}_{call_id}.mp3" self._current_file = self._recordings_dir / f"{ts}_{call_id}.mp3"
self._current_call_id = call_id self._current_call_id = call_id
# Read directly from the PulseAudio monitor source (zero-delay, no Icecast burst buffer). # Read from the Icecast stream. burst-size=0 in icecast config ensures
# PULSE_SERVER env var is set in the container environment. # each new connection starts at the live position with no buffered data.
stream_url = f"http://{settings.icecast_host}:{settings.icecast_port}{settings.icecast_mount}"
cmd = [ cmd = [
"ffmpeg", "-y", "ffmpeg", "-y",
"-f", "pulse", "-reconnect", "1",
"-i", "default", "-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-i", stream_url,
"-acodec", "libmp3lame", "-acodec", "libmp3lame",
"-ar", "22050", "-ar", "22050",
"-b:a", "32k", "-b:a", "32k",
+17 -21
View File
@@ -46,10 +46,8 @@ class RadioBot:
# Remember where we are so the watchdog can rejoin if we drop # Remember where we are so the watchdog can rejoin if we drop
self._guild_id = guild_id self._guild_id = guild_id
self._channel_id = channel_id self._channel_id = channel_id
if call_active: self._play_stream()
self._was_streaming = True logger.info(f"Joined #{channel.name} in {guild.name}")
self._play_stream()
logger.info(f"Joined #{channel.name} in {guild.name} (streaming={'yes' if call_active else 'waiting for call'})")
return True return True
except Exception as e: except Exception as e:
logger.error(f"Failed to join voice channel: {e}") logger.error(f"Failed to join voice channel: {e}")
@@ -73,19 +71,12 @@ class RadioBot:
return False return False
def start_stream(self): def start_stream(self):
"""Called when an OP25 call starts — begin transmitting audio and light the ring.""" """Called when an OP25 call starts — stream plays continuously, nothing to do."""
self._was_streaming = True pass
if self._voice_client and self._voice_client.is_connected():
if not self._voice_client.is_playing():
self._play_stream()
logger.debug("Stream started (call active).")
def stop_stream(self): def stop_stream(self):
"""Called when an OP25 call ends — stop transmitting so the ring goes dark.""" """Called when an OP25 call ends — stream plays continuously, nothing to do."""
self._was_streaming = False pass
if self._voice_client and self._voice_client.is_connected():
self._stop_stream()
logger.debug("Stream stopped (call ended).")
async def stop(self): async def stop(self):
self._guild_id = None self._guild_id = None
@@ -110,17 +101,23 @@ class RadioBot:
def _play_stream(self): def _play_stream(self):
if not self._voice_client: if not self._voice_client:
return return
# Read directly from PulseAudio monitor (zero-delay, no Icecast buffer). from app.config import settings
# PULSE_SERVER is set in the container environment to the shared socket. stream_url = f"http://{settings.icecast_host}:{settings.icecast_port}{settings.icecast_mount}"
source = discord.FFmpegPCMAudio( source = discord.FFmpegPCMAudio(
"default", stream_url,
before_options="-f pulse", before_options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -probesize 32 -analyzeduration 0 -fflags nobuffer",
) )
self._voice_client.play( self._voice_client.play(
discord.PCMVolumeTransformer(source, volume=1.0), discord.PCMVolumeTransformer(source, volume=1.0),
after=lambda e: logger.error(f"Stream ended unexpectedly: {e}") if e else None, after=self._on_stream_end,
) )
def _on_stream_end(self, error):
if error:
logger.error(f"Stream ended: {error}")
if self._voice_client and self._voice_client.is_connected() and not self._voice_client.is_playing():
asyncio.get_event_loop().call_soon_threadsafe(self._play_stream)
def _stop_stream(self): def _stop_stream(self):
if self._voice_client and self._voice_client.is_playing(): if self._voice_client and self._voice_client.is_playing():
self._voice_client.stop() self._voice_client.stop()
@@ -144,7 +141,6 @@ class RadioBot:
self._guild_id, self._guild_id,
self._channel_id, self._channel_id,
self._current_token, self._current_token,
call_active=self._was_streaming,
) )
if rejoined: if rejoined:
logger.info("Watchdog: successfully rejoined voice channel.") logger.info("Watchdog: successfully rejoined voice channel.")
+2 -2
View File
@@ -10,8 +10,8 @@
<client-timeout>30</client-timeout> <client-timeout>30</client-timeout>
<header-timeout>15</header-timeout> <header-timeout>15</header-timeout>
<source-timeout>10</source-timeout> <source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect> <burst-on-connect>0</burst-on-connect>
<burst-size>65535</burst-size> <burst-size>0</burst-size>
</limits> </limits>
<authentication> <authentication>