replace TARGET_AUDIO_SPEC with separate constants for freq and channels
This commit is contained in:
parent
94922caf71
commit
9e8727c02b
|
@ -1,6 +1,6 @@
|
||||||
use std::ops::{Index, IndexMut};
|
use std::ops::{Index, IndexMut};
|
||||||
|
|
||||||
use sdl2::audio::{AudioCallback, AudioFormat, AudioSpecDesired};
|
use sdl2::audio::{AudioCallback, AudioFormat, AudioFormatNum, AudioSpecDesired};
|
||||||
use sdl2::AudioSubsystem;
|
use sdl2::AudioSubsystem;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
@ -14,13 +14,10 @@ pub const AUDIO_FREQUENCY_44KHZ: u32 = 44100;
|
||||||
pub const AUDIO_FREQUENCY_22KHZ: u32 = 22050;
|
pub const AUDIO_FREQUENCY_22KHZ: u32 = 22050;
|
||||||
pub const AUDIO_FREQUENCY_11KHZ: u32 = 11025;
|
pub const AUDIO_FREQUENCY_11KHZ: u32 = 11025;
|
||||||
|
|
||||||
pub const SILENCE: u8 = sdl2::audio::AudioFormatNum::SILENCE;
|
pub const SILENCE: u8 = AudioFormatNum::SILENCE;
|
||||||
|
|
||||||
pub const TARGET_AUDIO_SPEC: AudioSpec = AudioSpec {
|
pub const TARGET_AUDIO_FREQUENCY: u32 = AUDIO_FREQUENCY_22KHZ;
|
||||||
frequency: AUDIO_FREQUENCY_22KHZ,
|
pub const TARGET_AUDIO_CHANNELS: u8 = 1;
|
||||||
channels: 1,
|
|
||||||
format: AudioFormat::U8,
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -246,8 +246,8 @@ impl SystemBuilder {
|
||||||
};
|
};
|
||||||
|
|
||||||
let audio_spec = AudioSpecDesired {
|
let audio_spec = AudioSpecDesired {
|
||||||
freq: Some(TARGET_AUDIO_SPEC.frequency() as i32),
|
freq: Some(TARGET_AUDIO_FREQUENCY as i32),
|
||||||
channels: Some(TARGET_AUDIO_SPEC.channels()),
|
channels: Some(TARGET_AUDIO_CHANNELS),
|
||||||
samples: None,
|
samples: None,
|
||||||
};
|
};
|
||||||
let mut audio = Audio::new(audio_spec, &sdl_audio_subsystem)?;
|
let mut audio = Audio::new(audio_spec, &sdl_audio_subsystem)?;
|
||||||
|
|
Loading…
Reference in a new issue