File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments