From 8724da824eb8c54a1db07d90fb0ff36408c9c8d3 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 28 Jul 2021 14:53:41 -0500 Subject: [PATCH] chore: inline some methods --- src/apu.rs | 1 + src/apu/gen.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apu.rs b/src/apu.rs index da09ed7..b1eacc4 100644 --- a/src/apu.rs +++ b/src/apu.rs @@ -166,6 +166,7 @@ impl Apu { self.prod = Some(prod); } + #[inline] pub(crate) fn is_full(&self) -> bool { match self.prod.as_ref() { Some(prod) => prod.is_full(), diff --git a/src/apu/gen.rs b/src/apu/gen.rs index 2a2c3b4..2ab21bf 100644 --- a/src/apu/gen.rs +++ b/src/apu/gen.rs @@ -3,7 +3,7 @@ use rtrb::{Consumer, Producer, PushError, RingBuffer}; pub(crate) const SAMPLE_RATE: u32 = 48000; // Hz const CHANNEL_COUNT: usize = 2; -const AUDIO_BUFFER_LEN: usize = 4096; +const BUFFER_CAPACITY: usize = 4096 * CHANNEL_COUNT; // # of samples * the # of channels pub struct AudioSPSC { inner: RingBuffer, @@ -12,7 +12,7 @@ pub struct AudioSPSC { impl Default for AudioSPSC { fn default() -> Self { Self { - inner: RingBuffer::new(AUDIO_BUFFER_LEN * CHANNEL_COUNT), + inner: RingBuffer::new(BUFFER_CAPACITY), } } } @@ -43,6 +43,7 @@ impl SampleProducer { self.inner.push(value) } + #[inline] pub(crate) fn is_full(&self) -> bool { self.inner.is_full() }