diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-08 00:55:52 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-08 00:55:52 +0200 |
| commit | c88f056289040533b692fdf0e7cd06d2988e5c92 (patch) | |
| tree | e18e0cfb02631b801c16d50808bc30bb85f50e4d /src/audio.rs | |
| parent | Extract queue module, add comprehensive tests, fix queue/play bugs (diff) | |
| download | rsplayer-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 'src/audio.rs')
| -rw-r--r-- | src/audio.rs | 4 |
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 @@ | |||
| 1 | use crate::notification; | ||
| 1 | use std::path::PathBuf; | 2 | use std::path::PathBuf; |
| 2 | use std::sync::atomic::{AtomicBool, Ordering}; | 3 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 3 | use std::sync::mpsc::{self, Receiver, Sender}; | 4 | use 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 | } |
