Skip to content

Commit db55db4

Browse files
committed
fix(audio): remove dummy audio driver and improve notification reliability with logging
1 parent a6d73fb commit db55db4

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

‎bigbox/app.py‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ def _init_display(self) -> pygame.Surface:
283283
os.environ["SDL_VIDEODRIVER"] = "fbcon"
284284
os.environ.setdefault("SDL_FBDEV", "/dev/fb0")
285285

286-
# Don't try to open ALSA — most handheld builds have no configured
287-
# sound card on first boot, and pygame's audio init is noisy when it
288-
# fails. Sound is opt-in via SDL_AUDIODRIVER if/when we add it.
289-
os.environ.setdefault("SDL_AUDIODRIVER", "dummy")
290-
291-
# Init only the subsystems we use, so a missing audio device or
292286
# joystick doesn't sink the whole startup.
293287
pygame.display.init()
294288
pygame.font.init()
@@ -661,16 +655,30 @@ def play_notification(self) -> None:
661655
"""Plays the system notification sound (assets/chat_notify.mp3)."""
662656
try:
663657
if not pygame.mixer.get_init():
664-
pygame.mixer.init()
658+
# Ensure we have the pulse environment if available
659+
from bigbox import audio as _audio
660+
env = _audio._pulse_env()
661+
for k, v in env.items():
662+
os.environ[k] = v
663+
664+
try:
665+
pygame.mixer.init()
666+
except Exception:
667+
# Fallback to ALSA if pulse fails
668+
os.environ["SDL_AUDIODRIVER"] = "alsa"
669+
pygame.mixer.init()
665670

666671
if self._notif_sound is None:
667672
p = Path(__file__).resolve().parents[1] / "assets" / "chat_notify.mp3"
668673
if p.exists():
669674
self._notif_sound = pygame.mixer.Sound(str(p))
670-
self._notif_sound.set_volume(0.5)
675+
self._notif_sound.set_volume(0.7)
671676

672677
if self._notif_sound:
678+
# Stop any currently playing notification before starting new one
679+
self._notif_sound.stop()
673680
self._notif_sound.play()
681+
print("[app] notification played")
674682
except Exception as e:
675683
print(f"[app] play_notification failed: {e}")
676684

‎bigbox/ui/chat.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@ def __init__(self, app: App) -> None:
4646
self._poll_thread.start()
4747

4848
def _poll_loop(self):
49+
print(f"[chat] polling started for {self.username}")
4950
while not self._stop_event.is_set():
5051
try:
5152
url = f"{API_URL}?after={self.last_id}" if self.last_id > 0 else API_URL
5253
res = requests.get(url, timeout=5)
5354
if res.status_code == 200:
5455
new_msgs = res.json()
5556
if new_msgs:
57+
print(f"[chat] received {len(new_msgs)} messages")
5658
was_at_bottom = self.scroll_y >= self.max_scroll - 10 or self.max_scroll == 0
5759
# Only play sound if this isn't the first load
5860
if self.last_id > 0:
61+
print("[chat] triggering notification")
5962
self.app.play_notification()
6063

6164
for m in new_msgs:

‎bigbox/update_checker.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,20 @@ def _check_now(self) -> bool:
5252

5353
def _run(self) -> None:
5454
# Initial wait to let system boot and network stabilize
55+
print("[update_checker] waiting 10s for network...")
5556
time.sleep(10)
5657

5758
while not self._stop.is_set():
5859
try:
60+
print("[update_checker] checking for updates...")
5961
if self._check_now():
6062
if not self.update_ready:
6163
self.update_ready = True
64+
print("[update_checker] update found, triggering toast and notification")
6265
self.app.toast("SYSTEM UPDATE AVAILABLE")
6366
self.app.play_notification()
67+
else:
68+
print("[update_checker] system up to date")
6469
except Exception:
6570
# Whole-iteration safety net: a surprise from
6671
# _check_now (it has its own try/except, but bugs

0 commit comments

Comments
 (0)