mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-01-07 19:46:53 +00:00
fix stack overflows in audio code by moving huge structs to heap
This commit is contained in:
parent
0e06113738
commit
4c20234d5e
|
@ -445,10 +445,10 @@ where
|
|||
let mut state = PlaybackState::Stopped;
|
||||
let mut saved_state: PlaybackStateType = PlaybackStateType::None;
|
||||
let mut speed = 1.0;
|
||||
let mut org_engine = OrgPlaybackEngine::new();
|
||||
let mut org_engine = Box::new(OrgPlaybackEngine::new());
|
||||
#[cfg(feature = "ogg-playback")]
|
||||
let mut ogg_engine = OggPlaybackEngine::new();
|
||||
let mut pixtone = PixTonePlayback::new();
|
||||
let mut ogg_engine = Box::new(OggPlaybackEngine::new());
|
||||
let mut pixtone = Box::new(PixTonePlayback::new());
|
||||
pixtone.create_samples();
|
||||
|
||||
log::info!("Audio format: {} {}", sample_rate, channels);
|
||||
|
|
|
@ -32,10 +32,10 @@ lazy_static! {
|
|||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Waveform {
|
||||
pub waveform_type: u8,
|
||||
pub pitch: f32,
|
||||
pub level: i32,
|
||||
pub offset: i32,
|
||||
pub waveform_type: u8,
|
||||
}
|
||||
|
||||
impl Waveform {
|
||||
|
@ -96,12 +96,12 @@ impl Envelope {
|
|||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Channel {
|
||||
pub enabled: bool,
|
||||
pub length: u32,
|
||||
pub carrier: Waveform,
|
||||
pub frequency: Waveform,
|
||||
pub amplitude: Waveform,
|
||||
pub envelope: Envelope,
|
||||
pub length: u32,
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
|
@ -179,9 +179,9 @@ impl PixToneParameters {
|
|||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub struct PlaybackState {
|
||||
id: u8,
|
||||
looping: bool,
|
||||
pos: f32,
|
||||
tag: u32,
|
||||
looping: bool,
|
||||
freq: f32,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue