|
|
|
|
@ -668,10 +668,10 @@ def worker():
@@ -668,10 +668,10 @@ def worker():
|
|
|
|
|
# Repeat_one: loop the first track |
|
|
|
|
if repeat_mode == "repeat_one": |
|
|
|
|
with queue_lock: |
|
|
|
|
current_track = queue[0] |
|
|
|
|
path_current = os.path.join(MUSIC_DIR, current_track) |
|
|
|
|
current_track = queue[0] if queue else None |
|
|
|
|
path_current = os.path.join(MUSIC_DIR, current_track) if current_track else None |
|
|
|
|
set_rds(f"RT {current_track}") |
|
|
|
|
played_ok = stream_file(path_current) |
|
|
|
|
played_ok = stream_file(path_current) if path_current else False |
|
|
|
|
write_silence(0.25) |
|
|
|
|
with queue_lock: |
|
|
|
|
current_track = None |
|
|
|
|
@ -680,13 +680,13 @@ def worker():
@@ -680,13 +680,13 @@ def worker():
|
|
|
|
|
|
|
|
|
|
# Normal / repeat_all |
|
|
|
|
with queue_lock: |
|
|
|
|
current_track = queue[0] |
|
|
|
|
path_current = os.path.join(MUSIC_DIR, current_track) |
|
|
|
|
current_track = queue[0] if queue else None |
|
|
|
|
path_current = os.path.join(MUSIC_DIR, current_track) if current_track else None |
|
|
|
|
set_rds(f"RT {current_track}") |
|
|
|
|
|
|
|
|
|
print(f"[WORKER] Starting: {current_track} | queue={queue} | skip={skip_flag} stop={stop_flag}") |
|
|
|
|
|
|
|
|
|
played_ok = stream_file(path_current) |
|
|
|
|
played_ok = stream_file(path_current) if path_current else False |
|
|
|
|
|
|
|
|
|
# Snapshot flags under lock to avoid races |
|
|
|
|
with queue_lock: |
|
|
|
|
@ -718,6 +718,12 @@ def worker():
@@ -718,6 +718,12 @@ def worker():
|
|
|
|
|
print(f"[WORKER] Skip: popped {popped} | queue now {queue}") |
|
|
|
|
write_silence(0.25) |
|
|
|
|
continue |
|
|
|
|
if not current_track: |
|
|
|
|
# there was no song to play |
|
|
|
|
write_silence(1) |
|
|
|
|
time.sleep(1) |
|
|
|
|
stop_flag = True |
|
|
|
|
continue |
|
|
|
|
# Real failure: log and drop the track to avoid infinite loop |
|
|
|
|
print("[WORKER] Track failed to play:", current_track) |
|
|
|
|
with queue_lock: |
|
|
|
|
|