Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/faderframe-audio-cpal/src/followers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ pub struct Watcher {
}

impl Watcher {
/// Looking for a device and opening it can take seconds (Windows
/// refusing an input it does not let FaderFrame use: #94); the
/// followers' lock, which the control side takes to show the devices,
/// is held only to attach a link, never meanwhile.
pub fn tick(&mut self) {
let now = Instant::now();
let mut followers = self.followers.lock().unwrap_or_else(|e| e.into_inner());
followers.collect();
self.followers
.lock()
.unwrap_or_else(|e| e.into_inner())
.collect();
for f in &mut self.streams {
if f.stream.is_some() && f.failed.load(Ordering::Relaxed) {
// Unplugged (or its device otherwise gone): its channels
Expand Down Expand Up @@ -250,7 +256,12 @@ impl Watcher {
) else {
continue;
};
let Some(end) = followers.attach(f.index, open.sample_rate, open.block) else {
let attached = self
.followers
.lock()
.unwrap_or_else(|e| e.into_inner())
.attach(f.index, open.sample_rate, open.block);
let Some(end) = attached else {
continue;
};
f.failed.store(false, Ordering::Relaxed);
Expand Down