mirror of
https://github.com/italicsjenga/agb.git
synced 2025-02-02 04:26:40 +11:00
Don't require leaking the track
This commit is contained in:
parent
71a7b6431c
commit
afddd77ce8
2 changed files with 7 additions and 7 deletions
|
@ -95,8 +95,8 @@ pub mod __private {
|
|||
pub use agb_tracker_interop::Track;
|
||||
|
||||
/// Stores the required state in order to play tracker music.
|
||||
pub struct TrackerInner<TChannelId> {
|
||||
track: &'static Track,
|
||||
pub struct TrackerInner<'track, TChannelId> {
|
||||
track: &'track Track,
|
||||
channels: Vec<TrackerChannel<TChannelId>>,
|
||||
envelopes: Vec<Option<EnvelopeState>>,
|
||||
|
||||
|
@ -132,9 +132,9 @@ struct GlobalSettings {
|
|||
volume: Num<i32, 8>,
|
||||
}
|
||||
|
||||
impl<TChannelId> TrackerInner<TChannelId> {
|
||||
impl<'track, TChannelId> TrackerInner<'track, TChannelId> {
|
||||
/// Create a new tracker playing a specified track. See the [example](crate#example) for how to use the tracker.
|
||||
pub fn new(track: &'static Track) -> Self {
|
||||
pub fn new(track: &'track Track) -> Self {
|
||||
let mut channels = Vec::new();
|
||||
channels.resize_with(track.num_channels, Default::default);
|
||||
|
||||
|
@ -586,4 +586,4 @@ impl<'gba> Mixer for agb::sound::mixer::Mixer<'gba> {
|
|||
|
||||
#[cfg(feature = "agb")]
|
||||
/// The type to use if you're using agb-tracker with agb
|
||||
pub type Tracker = TrackerInner<agb::sound::mixer::ChannelId>;
|
||||
pub type Tracker = TrackerInner<'static, agb::sound::mixer::ChannelId>;
|
||||
|
|
|
@ -15,10 +15,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let file_path = &args[1];
|
||||
let module = load_module_from_file(Path::new(file_path))?;
|
||||
|
||||
let track = Box::leak::<'static>(Box::new(agb_xm_core::parse_module(&module)));
|
||||
let track = agb_xm_core::parse_module(&module);
|
||||
|
||||
let mut mixer = Mixer::new();
|
||||
let mut tracker = agb_tracker::TrackerInner::new(track);
|
||||
let mut tracker = agb_tracker::TrackerInner::new(&track);
|
||||
|
||||
let host = cpal::default_host();
|
||||
let device = host
|
||||
|
|
Loading…
Add table
Reference in a new issue