aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2024-02-11 16:25:42 +0100
committerAndreas Grois <andi@grois.info>2024-02-11 16:25:42 +0100
commit4db89fd85b97c40e0f05a9faf6b73c72ba3893b5 (patch)
tree7b2de82cd9480acc740808c02e532476f534459c
parente5ebcc0e4f7598ec26f1a67305d7f9a42bf35a59 (diff)
Fix initial volume update in ALSA
-rw-r--r--alsa/src/runnable.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/alsa/src/runnable.rs b/alsa/src/runnable.rs
index 5ff2e62..d307a23 100644
--- a/alsa/src/runnable.rs
+++ b/alsa/src/runnable.rs
@@ -45,10 +45,11 @@ impl<'r> AlsaVolumeRunnable<'r> {
unsafe { snd_mixer_set_callback(mixer.handle, Some(Self::mixer_callback)) };
unsafe { snd_mixer_set_callback_private(mixer.handle, &mixer_scratch_space as *const MixerScratchSpace as *const c_void)};
load_mixer(mixer.handle)?;
+ //send an update right now. Loading the mixer could already have given us data to show.
+ self.send_updated_values_to_main(mixer_scratch_space.elem_scratch.borrow().clone()).expect("Tried to update main thread, but it seems to be gone?");
- let mut should_update_main_even_if_unchanged = true;
loop {
-
+ let mut should_update_main_even_if_unchanged = false;
let descriptor_count = unsafe{snd_mixer_poll_descriptors_count(mixer.handle)};
if descriptor_count < 0 {
return Err(AlsaVolumeError::FailedToGetPollDescriptors);
@@ -111,7 +112,6 @@ impl<'r> AlsaVolumeRunnable<'r> {
if new_values != old_values || should_update_main_even_if_unchanged {
self.send_updated_values_to_main(new_values).expect("Tried to update main thread, but it seems to be gone?");
}
- should_update_main_even_if_unchanged = false;
}
}
@@ -405,4 +405,4 @@ extern "C" {
//int snd_mixer_handle_events ( snd_mixer_t * mixer )
fn snd_mixer_handle_events(mixer : SndMixerHandle) -> c_int;
-} \ No newline at end of file
+}