Fix sound once again :)

This commit is contained in:
Kevin Hamacher 2021-09-30 12:33:14 +02:00
parent cd2f9ddfd8
commit 6c1ad38f0a
3 changed files with 11 additions and 24 deletions

View File

@ -1,20 +1,6 @@
let let
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; }; nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
rustNightlyChannelClippy = (nixpkgs.rustChannelOf { date = "2020-01-29"; channel = "nightly"; }).rust.override {
extensions = [
"rust-src"
"rls-preview"
"rustfmt-preview"
];
};
rustNightlyChannel = nixpkgs.latest.rustChannels.nightly.rust.override {
extensions = [
"rust-src"
"rls-preview"
"rustfmt-preview"
];
};
rustStableChannel = nixpkgs.latest.rustChannels.stable.rust.override { rustStableChannel = nixpkgs.latest.rustChannels.stable.rust.override {
extensions = [ extensions = [
"rust-src" "rust-src"
@ -28,12 +14,11 @@ in
stdenv.mkDerivation { stdenv.mkDerivation {
name = "moz_overlay_shell"; name = "moz_overlay_shell";
buildInputs = [ buildInputs = [
rustNightlyChannelClippy rustStableChannel
rls rls
rustup rustup
pkg-config pkg-config
SDL2 SDL2
pulseaudio pulseaudio
]; ];
TELOXIDE_TOKEN = "916718418:AAFFtn9WmqipuKCvwiXZ2cEIA_IuNqlO94I";
} }

View File

@ -369,7 +369,10 @@ impl Interconnect {
0xFF70 => { 0xFF70 => {
if self.wram_bank != val { if self.wram_bank != val {
if val > 7 { if val > 7 {
panic!("Trying to switch to wram bank {} which is non-existing", val); panic!(
"Trying to switch to wram bank {} which is non-existing",
val
);
} }
if val == 0 { if val == 0 {
self.wram_bank = 1; self.wram_bank = 1;

View File

@ -379,7 +379,10 @@ impl SoundManager {
let mut counter = 0; let mut counter = 0;
while !do_exit.load(Ordering::Relaxed) { while !do_exit.load(Ordering::Relaxed) {
for _ in 0..100 { const N_SAMPLES: usize = 1024;
let mut sample_buffer = [[128u8; 2]; N_SAMPLES];
for idx in 0..N_SAMPLES {
if let Some((s1, s2)) = { if let Some((s1, s2)) = {
let mut c_obj = obj.lock().unwrap(); let mut c_obj = obj.lock().unwrap();
@ -397,14 +400,10 @@ impl SoundManager {
// Get sample // Get sample
c_obj.sample() c_obj.sample()
} { } {
let samps = [[s1, s2]]; sample_buffer[idx] = [s1, s2];
playback.write(&samps[..]);
} else {
let samps = [[128, 128]];
playback.write(&samps[..]);
} }
} }
std::thread::sleep(std::time::Duration::from_millis(1)); playback.write(&sample_buffer[..]);
} }
}) })
.unwrap(), .unwrap(),