Skip to content

Commit

Permalink
impl source for mut references (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
dexterdy authored Dec 25, 2023
1 parent 4973f33 commit e153a19
Showing 1 changed file with 28 additions and 69 deletions.
97 changes: 28 additions & 69 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,77 +374,36 @@ where
}
}

impl<S> Source for Box<dyn Source<Item = S>>
where
S: Sample,
{
#[inline]
fn current_frame_len(&self) -> Option<usize> {
(**self).current_frame_len()
}

#[inline]
fn channels(&self) -> u16 {
(**self).channels()
}

#[inline]
fn sample_rate(&self) -> u32 {
(**self).sample_rate()
}

#[inline]
fn total_duration(&self) -> Option<Duration> {
(**self).total_duration()
}
macro_rules! source_pointer_impl {
($($sig:tt)+) => {
impl $($sig)+ {
#[inline]
fn current_frame_len(&self) -> Option<usize> {
(**self).current_frame_len()
}

#[inline]
fn channels(&self) -> u16 {
(**self).channels()
}

#[inline]
fn sample_rate(&self) -> u32 {
(**self).sample_rate()
}

#[inline]
fn total_duration(&self) -> Option<Duration> {
(**self).total_duration()
}
}
};
}

impl<S> Source for Box<dyn Source<Item = S> + Send>
where
S: Sample,
{
#[inline]
fn current_frame_len(&self) -> Option<usize> {
(**self).current_frame_len()
}
source_pointer_impl!(<S> Source for Box<dyn Source<Item = S>> where S: Sample,);

#[inline]
fn channels(&self) -> u16 {
(**self).channels()
}
source_pointer_impl!(<S> Source for Box<dyn Source<Item = S> + Send> where S: Sample,);

#[inline]
fn sample_rate(&self) -> u32 {
(**self).sample_rate()
}

#[inline]
fn total_duration(&self) -> Option<Duration> {
(**self).total_duration()
}
}

impl<S> Source for Box<dyn Source<Item = S> + Send + Sync>
where
S: Sample,
{
#[inline]
fn current_frame_len(&self) -> Option<usize> {
(**self).current_frame_len()
}
source_pointer_impl!(<S> Source for Box<dyn Source<Item = S> + Send + Sync> where S: Sample,);

#[inline]
fn channels(&self) -> u16 {
(**self).channels()
}

#[inline]
fn sample_rate(&self) -> u32 {
(**self).sample_rate()
}

#[inline]
fn total_duration(&self) -> Option<Duration> {
(**self).total_duration()
}
}
source_pointer_impl!(<'a, S, C> Source for &'a mut C where S: Sample, C: Source<Item = S>,);

0 comments on commit e153a19

Please sign in to comment.