mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
🧹 Replace unsafe unwrap on Mutex lock with unwrap_or_else (#33)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
95761f6a5a
commit
c6577cd5e0
+2
-2
@@ -58,7 +58,7 @@ impl SoundpadGui {
|
||||
|
||||
pub fn play_toggle(&mut self) {
|
||||
let (new_state, request) = {
|
||||
let guard = self.audio_player_state_shared.lock().unwrap();
|
||||
let guard = self.audio_player_state_shared.lock().unwrap_or_else(|e| e.into_inner());
|
||||
match guard.state {
|
||||
PlayerState::Playing => (Some(PlayerState::Paused), Some(Request::pause(None))),
|
||||
PlayerState::Paused => (Some(PlayerState::Playing), Some(Request::resume(None))),
|
||||
@@ -71,7 +71,7 @@ impl SoundpadGui {
|
||||
}
|
||||
|
||||
if let Some(state) = new_state {
|
||||
let mut guard = self.audio_player_state_shared.lock().unwrap();
|
||||
let mut guard = self.audio_player_state_shared.lock().unwrap_or_else(|e| e.into_inner());
|
||||
guard.new_state = Some(state.clone());
|
||||
guard.state = state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user