Skip to content

Commit 0ddd331

Browse files
committed
Another fix for volume notifications
1 parent a25300f commit 0ddd331

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src-tauri/src/sendspin/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ async fn run_client(
220220
// Convert tokio mpsc sender to std mpsc sender for compatibility
221221
let (std_tx, std_rx) = std::sync::mpsc::channel::<(u8, bool)>();
222222

223-
// Spawn a task to forward std mpsc messages to tokio mpsc
223+
// Spawn a blocking task to forward std mpsc messages to tokio mpsc
224+
// std::sync::mpsc::recv() is blocking and must not block the tokio runtime
224225
let volume_change_tx_clone = volume_change_tx.clone();
225-
tokio::spawn(async move {
226+
tokio::task::spawn_blocking(move || {
226227
while let Ok((volume, muted)) = std_rx.recv() {
227-
let _ = volume_change_tx_clone.send((volume, muted)).await;
228+
// Use blocking_send since we're in a blocking context
229+
let _ = volume_change_tx_clone.blocking_send((volume, muted));
228230
}
229231
});
230232

0 commit comments

Comments
 (0)