perf: add adaptive polling and fix lyrics interval leak
- Playback state polling: 1000ms when paused, 250ms when playing - Audio thread timeout: 500ms when idle, 100ms when playing - Lyrics interval: self-check to auto-stop when conditions not met - Add cleanup return to lyrics in +page.svelte - Add build-and-run.sh and monitor-resources.sh scripts - Add OPTIMIZATION_PLAN.md documentation
This commit is contained in:
1 parent
9a817a5203
commit
3e8fe0771a
7 files changed
+442
-6
No files matched your search
@@ -494,8 +494,13 @@ impl Player {
|
||||
log::info!("Audio thread ready and waiting for commands");
|
||||
|
||||
loop {
|
||||
// Use recv_timeout so we can periodically check if sink is empty
|
||||
match rx.recv_timeout(Duration::from_millis(100)) {
|
||||
// Adaptive timeout: fast (100ms) when playing, slow (500ms) when idle
|
||||
let timeout = if thread_state.is_playing.load(Ordering::SeqCst) {
|
||||
Duration::from_millis(100)
|
||||
} else {
|
||||
Duration::from_millis(500)
|
||||
};
|
||||
match rx.recv_timeout(timeout) {
|
||||
Ok(AudioCommand::Play { data, track_id, duration_secs }) => {
|
||||
log::info!("Audio thread: playing track {}", track_id);
|
||||
|
||||
|
||||
Reference in new issue
Block a user