Skip to content

Comments

dont crash if there's no mic#477

Open
cjpais wants to merge 1 commit intomainfrom
dont-crash-no-mic
Open

dont crash if there's no mic#477
cjpais wants to merge 1 commit intomainfrom
dont-crash-no-mic

Conversation

@cjpais
Copy link
Owner

@cjpais cjpais commented Dec 20, 2025

title

@VirenMohindra
Copy link
Contributor

VirenMohindra commented Dec 20, 2025

this prevents the crash from #475, which is good. however it introduces silent failures -- if there's no mic, the app won't crash but also won't tell the user anything. they'll press push-to-talk and nothing happens

additionally, if the worker exits early during init, calling stop() later will deadlock because it waits on a response channel from a dead thread

i think we should validate the audio config in open() before spawning the worker thread, so failures are caught and returned to the caller. and this also lets the UI show an appropriate error message

Ok(c) => c,
Err(e) => {
log::error!("Failed to get audio config: {}", e);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this prevents the crash but now open() returns Ok(()) even when the worker immediately exits. the caller (audio manager) sets is_open = true and thinks everything is fine

maybe we do config validation in open() before spawning the worker, or use a oneshot channel to communicate init success / failure back

}
};

if let Err(e) = stream.play() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the worker exits here ^, stop() will deadlock, and it sends Cmd::Stop(resp_tx) to a dead worker and resp_rx.recv() blocks forever waiting for a response that never comes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should not let open() succeed if init fails

@cjpais
Copy link
Owner Author

cjpais commented Dec 20, 2025

Thanks for the review @VirenMohindra, I definitely want to consider a toasting ui of some kind for error handling generally. I think probably having some unified way to throw up to the UI would be helpful for big errors

Tbh I just let Claude write whatever and hadn't even reviewed this, if you would like to submit changes and improvements I would be overjoyed!! I already have a huge backlog and would love to focus on keyboard input stuff instead

@VirenMohindra
Copy link
Contributor

if you would like to submit changes and improvements

happy to! def want to clear out my in flight PRs before i jump on this one though, before they get too stale 😅

@cjpais
Copy link
Owner Author

cjpais commented Dec 28, 2025

@VirenMohindra i will try and get them in soon! I'm not planning to pull much else in for a week or two. I'm trying to wrap up a rewrite of the keyboard input library generally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants