mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-25 01:01:34 +11:00
Merge pull request #62 from gwilymk/allow-channels-to-loop
Allow channels to loop
This commit is contained in:
commit
2a0192de51
|
@ -43,7 +43,11 @@ impl Mixer {
|
||||||
some_channel.pos += SOUND_BUFFER_SIZE;
|
some_channel.pos += SOUND_BUFFER_SIZE;
|
||||||
|
|
||||||
if some_channel.pos >= some_channel.data.len() {
|
if some_channel.pos >= some_channel.data.len() {
|
||||||
has_finished = true;
|
if some_channel.should_loop {
|
||||||
|
some_channel.pos = 0;
|
||||||
|
} else {
|
||||||
|
has_finished = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +74,21 @@ impl Mixer {
|
||||||
pub struct SoundChannel {
|
pub struct SoundChannel {
|
||||||
data: &'static [u8],
|
data: &'static [u8],
|
||||||
pos: usize,
|
pos: usize,
|
||||||
|
should_loop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SoundChannel {
|
impl SoundChannel {
|
||||||
pub fn new(data: &'static [u8]) -> Self {
|
pub fn new(data: &'static [u8]) -> Self {
|
||||||
SoundChannel { data, pos: 0 }
|
SoundChannel {
|
||||||
|
data,
|
||||||
|
pos: 0,
|
||||||
|
should_loop: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn should_loop(mut self) -> Self {
|
||||||
|
self.should_loop = true;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue