Skip to content

Commit

Permalink
fix(audio/linux): Fix busy loop + packet buildup (#2375)
Browse files Browse the repository at this point in the history
  • Loading branch information
The-personified-devil authored Sep 5, 2024
1 parent b71059f commit f66a213
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion alvr/audio/src/linux.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alvr_common::{anyhow::Result, debug, error, parking_lot::Mutex};
use alvr_common::{anyhow::Result, debug, error, parking_lot::Mutex, ConnectionError};
use alvr_session::AudioBufferingConfig;
use alvr_sockets::{StreamReceiver, StreamSender};
use pipewire::{
Expand Down Expand Up @@ -71,6 +71,15 @@ pub fn play_microphone_loop_pipewire(
average_buffer_frames_count,
)
.ok();

// if we end up here then no consumer is currently connected to the output,
// so discard audio packets to not cause a buildup
if matches!(
receiver.recv(Duration::from_millis(500)),
Err(ConnectionError::Other(_))
) {
break;
};
}

if pw_sender.send(Terminate).is_err() {
Expand Down

0 comments on commit f66a213

Please sign in to comment.