diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-05 23:12:45 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-05 23:12:45 +0200 |
| commit | 9b6e55fe23890ee89efd5b16605ae44b903471e6 (patch) | |
| tree | 308f12ce7fa3c9c0d05f58e94c1ed2f8149ef0c7 /src/audio.rs | |
| parent | Add flexible play command with position flags (diff) | |
| download | rsplayer-9b6e55fe23890ee89efd5b16605ae44b903471e6.tar.gz rsplayer-9b6e55fe23890ee89efd5b16605ae44b903471e6.zip | |
Add dev/release config separation and volume query command
Diffstat (limited to 'src/audio.rs')
| -rw-r--r-- | src/audio.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio.rs b/src/audio.rs index 4e26263..93eb8e6 100644 --- a/src/audio.rs +++ b/src/audio.rs | |||
| @@ -18,6 +18,7 @@ pub struct AudioEngine { | |||
| 18 | is_playing: Arc<AtomicBool>, | 18 | is_playing: Arc<AtomicBool>, |
| 19 | current_track: Arc<Mutex<Option<std::path::PathBuf>>>, | 19 | current_track: Arc<Mutex<Option<std::path::PathBuf>>>, |
| 20 | track_ended: Arc<AtomicBool>, | 20 | track_ended: Arc<AtomicBool>, |
| 21 | volume: Arc<Mutex<f32>>, | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | impl AudioEngine { | 24 | impl AudioEngine { |
| @@ -48,6 +49,7 @@ impl AudioEngine { | |||
| 48 | is_playing, | 49 | is_playing, |
| 49 | current_track, | 50 | current_track, |
| 50 | track_ended, | 51 | track_ended, |
| 52 | volume, | ||
| 51 | } | 53 | } |
| 52 | } | 54 | } |
| 53 | 55 | ||
| @@ -75,6 +77,13 @@ impl AudioEngine { | |||
| 75 | let _ = self.command_tx.send(AudioCommand::SetVolume(volume)); | 77 | let _ = self.command_tx.send(AudioCommand::SetVolume(volume)); |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 80 | pub fn get_volume(&self) -> u8 { | ||
| 81 | self.volume | ||
| 82 | .lock() | ||
| 83 | .map(|v| (*v * 100.0) as u8) | ||
| 84 | .unwrap_or(100) | ||
| 85 | } | ||
| 86 | |||
| 78 | pub fn is_playing(&self) -> bool { | 87 | pub fn is_playing(&self) -> bool { |
| 79 | self.is_playing.load(Ordering::SeqCst) | 88 | self.is_playing.load(Ordering::SeqCst) |
| 80 | } | 89 | } |
