mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Add lifetimes to the mixer
This commit is contained in:
parent
5ac408d414
commit
2bab48b422
|
@ -114,7 +114,7 @@ impl MixerController {
|
|||
}
|
||||
|
||||
/// Get a [`Mixer`] in order to start producing sounds.
|
||||
pub fn mixer(&mut self, frequency: Frequency) -> Mixer {
|
||||
pub fn mixer(&mut self, frequency: Frequency) -> Mixer<'_> {
|
||||
Mixer::new(frequency)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use core::cell::RefCell;
|
||||
use core::marker::PhantomData;
|
||||
use core::pin::Pin;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
|
@ -78,7 +79,7 @@ extern "C" {
|
|||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Mixer {
|
||||
pub struct Mixer<'gba> {
|
||||
interrupt_timer: Timer,
|
||||
// SAFETY: Has to go before buffer because it holds a reference to it
|
||||
_interrupt_handler: InterruptHandler<'static>,
|
||||
|
@ -91,6 +92,8 @@ pub struct Mixer {
|
|||
working_buffer: Box<[Num<i16, 4>], InternalAllocator>,
|
||||
|
||||
fifo_timer: Timer,
|
||||
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
/// A pointer to a currently playing channel.
|
||||
|
@ -116,7 +119,7 @@ pub struct Mixer {
|
|||
/// ```
|
||||
pub struct ChannelId(usize, i32);
|
||||
|
||||
impl Mixer {
|
||||
impl Mixer<'_> {
|
||||
pub(super) fn new(frequency: Frequency) -> Self {
|
||||
let buffer = Box::pin_in(MixerBuffer::new(frequency), InternalAllocator);
|
||||
|
||||
|
@ -158,6 +161,8 @@ impl Mixer {
|
|||
|
||||
working_buffer: working_buffer.into_boxed_slice(),
|
||||
fifo_timer,
|
||||
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue