mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
chore: add trace logging to volume module
This commit is contained in:
parent
5a7ad5675d
commit
76ca6115a3
4 changed files with 30 additions and 3 deletions
|
@ -6,7 +6,7 @@ use libpulse_binding::context::introspect::SinkInputInfo;
|
|||
use libpulse_binding::context::subscribe::Operation;
|
||||
use std::sync::{Arc, Mutex, mpsc};
|
||||
use tokio::sync::broadcast;
|
||||
use tracing::{debug, error};
|
||||
use tracing::{debug, error, instrument, trace};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SinkInput {
|
||||
|
@ -35,10 +35,12 @@ impl From<&SinkInputInfo<'_>> for SinkInput {
|
|||
}
|
||||
|
||||
impl Client {
|
||||
#[instrument(level = "trace")]
|
||||
pub fn sink_inputs(&self) -> Arc<Mutex<Vec<SinkInput>>> {
|
||||
self.data.sink_inputs.clone()
|
||||
}
|
||||
|
||||
#[instrument(level = "trace")]
|
||||
pub fn set_input_volume(&self, index: u32, volume_percent: f64) {
|
||||
if let ConnectionState::Connected { introspector, .. } = &mut *lock!(self.connection) {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
@ -61,6 +63,7 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "trace")]
|
||||
pub fn set_input_muted(&self, index: u32, muted: bool) {
|
||||
if let ConnectionState::Connected { introspector, .. } = &mut *lock!(self.connection) {
|
||||
introspector.set_sink_input_mute(index, muted, None);
|
||||
|
@ -112,6 +115,8 @@ pub fn add(
|
|||
return;
|
||||
};
|
||||
|
||||
trace!("adding {info:?}");
|
||||
|
||||
lock!(inputs).push(info.into());
|
||||
send!(tx, Event::AddInput(info.into()));
|
||||
}
|
||||
|
@ -125,6 +130,8 @@ fn update(
|
|||
return;
|
||||
};
|
||||
|
||||
trace!("updating {info:?}");
|
||||
|
||||
{
|
||||
let mut inputs = lock!(inputs);
|
||||
let Some(pos) = inputs.iter().position(|input| input.index == info.index) else {
|
||||
|
@ -141,6 +148,8 @@ fn update(
|
|||
fn remove(index: u32, inputs: &ArcMutVec<SinkInput>, tx: &broadcast::Sender<Event>) {
|
||||
let mut inputs = lock!(inputs);
|
||||
|
||||
trace!("removing {index}");
|
||||
|
||||
if let Some(pos) = inputs.iter().position(|s| s.index == index) {
|
||||
let info = inputs.remove(pos);
|
||||
send!(tx, Event::RemoveInput(info.index));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue