diff options
| author | Andreas Grois <andi@grois.info> | 2024-02-11 16:25:42 +0100 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2024-02-11 16:25:42 +0100 |
| commit | 4db89fd85b97c40e0f05a9faf6b73c72ba3893b5 (patch) | |
| tree | 7b2de82cd9480acc740808c02e532476f534459c /alsa/src/runnable.rs | |
| parent | e5ebcc0e4f7598ec26f1a67305d7f9a42bf35a59 (diff) | |
Fix initial volume update in ALSA
Diffstat (limited to 'alsa/src/runnable.rs')
| -rw-r--r-- | alsa/src/runnable.rs | 8 |
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 +} |
