aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.rs
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-08 00:55:52 +0200
committersalmonik <raisersoft@proton.me>2026-05-08 00:55:52 +0200
commitc88f056289040533b692fdf0e7cd06d2988e5c92 (patch)
treee18e0cfb02631b801c16d50808bc30bb85f50e4d /src/audio.rs
parentExtract queue module, add comprehensive tests, fix queue/play bugs (diff)
downloadrsplayer-c88f056289040533b692fdf0e7cd06d2988e5c92.tar.gz
rsplayer-c88f056289040533b692fdf0e7cd06d2988e5c92.zip
Add desktop notifications for track changes, queue end, and errors
Uses notify-rust to send D-Bus desktop notifications from the daemon when tracks change, the queue empties, or audio errors occur.
Diffstat (limited to '')
-rw-r--r--src/audio.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/audio.rs b/src/audio.rs
index 58ad2bf..7218f84 100644
--- a/src/audio.rs
+++ b/src/audio.rs
@@ -1,3 +1,4 @@
1use crate::notification;
1use std::path::PathBuf; 2use std::path::PathBuf;
2use std::sync::atomic::{AtomicBool, Ordering}; 3use std::sync::atomic::{AtomicBool, Ordering};
3use std::sync::mpsc::{self, Receiver, Sender}; 4use std::sync::mpsc::{self, Receiver, Sender};
@@ -331,6 +332,7 @@ fn audio_thread(
331 Ok(stream) => { 332 Ok(stream) => {
332 if let Err(e) = stream.play() { 333 if let Err(e) = stream.play() {
333 eprintln!("Failed to start stream: {}", e); 334 eprintln!("Failed to start stream: {}", e);
335 notification::notify_error("Failed to start audio stream");
334 is_playing.store(false, Ordering::SeqCst); 336 is_playing.store(false, Ordering::SeqCst);
335 } else { 337 } else {
336 current_stream = Some(stream); 338 current_stream = Some(stream);
@@ -338,12 +340,14 @@ fn audio_thread(
338 } 340 }
339 Err(e) => { 341 Err(e) => {
340 eprintln!("Failed to create stream: {}", e); 342 eprintln!("Failed to create stream: {}", e);
343 notification::notify_error("Failed to create audio stream");
341 is_playing.store(false, Ordering::SeqCst); 344 is_playing.store(false, Ordering::SeqCst);
342 } 345 }
343 } 346 }
344 } 347 }
345 Err(e) => { 348 Err(e) => {
346 eprintln!("Failed to open audio: {}", e); 349 eprintln!("Failed to open audio: {}", e);
350 notification::notify_error("Failed to open audio file");
347 is_playing.store(false, Ordering::SeqCst); 351 is_playing.store(false, Ordering::SeqCst);
348 } 352 }
349 } 353 }