Skip to content

Commit

Permalink
wip: AudioObject
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Apr 1, 2024
1 parent 493b7dd commit 8078049
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/audio/audio_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ pub struct Volume {
value: u32,
}

pub trait AudioObject {
fn alias(&self) -> String;
fn name(&self) -> String;
fn volume(&self) -> Vec<u32>;
fn index(&self) -> u32;
fn channels(&self) -> u16;
fn muted(&self) -> bool;
fn toggle_muted(&mut self);
fn active(&self) -> i32;
}

impl Volume {
pub fn from_i32(value: i32) -> Option<Self> {
match value {
Expand Down Expand Up @@ -170,6 +181,40 @@ impl From<&SourceInfo<'_>> for Source {
}
}

impl AudioObject for Source {
fn alias(&self) -> String {
self.alias.clone()
}

fn name(&self) -> String {
self.name.clone()
}

fn volume(&self) -> Vec<u32> {
self.volume
}

fn index(&self) -> u32 {
self.index
}

fn channels(&self) -> u16 {
self.channels
}

fn muted(&self) -> bool {
self.muted
}

fn toggle_muted(&mut self) {
self.muted = !self.muted;
}

fn active(&self) -> i32 {
self.active
}
}

#[derive(Debug, Clone, Default)]
pub struct Sink {
pub index: u32,
Expand Down

0 comments on commit 8078049

Please sign in to comment.