Skip to content

Commit

Permalink
Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Feb 2, 2024
1 parent 63ceb7c commit cd72a25
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
19 changes: 7 additions & 12 deletions src/blip/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(unused)]
// TODO: Remove this allow

/// A Rust based re-implementation of blip-buf
/// https://code.google.com/p/blip-buf
Expand Down Expand Up @@ -66,8 +69,6 @@ pub struct BlipBuf {

impl BlipBuf {
pub fn new(size: usize) -> Self {
assert!(size >= 0);

let blip = Self {
factor: TIME_UNIT / BLIP_MAX_RATIO,
offset: 0,
Expand All @@ -92,17 +93,13 @@ impl BlipBuf {
let factor = (TIME_UNIT as f32 * sample_rate as f32 / clock_rate as f32) as u32;
self.factor = factor;

assert!(0 <= factor - self.factor && factor - self.factor < 1);

if self.factor < factor {
self.factor += 1;
}
}

pub fn clocks_needed(&self, samples: u32) -> u32 {
let mut needed: u32;

assert!(samples >= 0 && self.avail + samples as usize <= self.size);
let needed: u32;

needed = samples * TIME_UNIT;
if needed < self.offset {
Expand Down Expand Up @@ -130,8 +127,6 @@ impl BlipBuf {
}

pub fn read_samples(&mut self, out: &mut [i32], count: usize, stereo: bool) -> usize {
assert!(count >= 0);

let mut count = count;

if count > self.avail {
Expand Down Expand Up @@ -174,7 +169,7 @@ impl BlipBuf {
{
// TODO: Fix this
let fixed = (time as f32 * self.factor as f32) as u32 + self.offset;
let mut out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut();
let out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut();

let phase_shift = FRAC_BITS - PHASE_BITS;
let phase: usize = fixed as usize >> phase_shift & (PHASE_COUNT - 1);
Expand Down Expand Up @@ -202,10 +197,10 @@ impl BlipBuf {
out[7] += BL_STEP[PHASE_COUNT - phase][0] * delta + BL_STEP[PHASE_COUNT - phase - 1][0] * delta2;
}

pub fn add_delta_fast(&mut self, time: u32, mut delta: i32)
pub fn add_delta_fast(&mut self, time: u32, delta: i32)
{
let fixed = time * self.factor + self.offset;
let mut out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut();
let out = &mut self.samples[self.avail + (fixed >> FRAC_BITS) as usize..].as_mut();

let interp = fixed >> (FRAC_BITS - DELTA_BITS) & (DELTA_UNIT - 1);
let delta2 = delta * interp as i32;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ppu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::components::prelude::*;
use crate::config::{Color, Config, Palette};
use bitflags::{bitflags, Flags};
use bitflags::bitflags;

pub const SCREEN_W: usize = 160;
pub const SCREEN_H: usize = 144;
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl Context {
self.window.request_redraw();
}

pub fn recalculate_vertex_buffer(size: PhysicalSize<u32>) -> [Vertex; 4] {
fn recalculate_vertex_buffer(size: PhysicalSize<u32>) -> [Vertex; 4] {
let context_aspect = size.width as f32 / size.height as f32;
let image_aspect = SCREEN_W as f32 / SCREEN_H as f32;

Expand Down
5 changes: 4 additions & 1 deletion src/sound/apu.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![allow(unused)]
// TODO: Remove this allow

use crate::components::memory::Memory;
use crate::sound::prelude::*;
use crate::blip::buffer::BlipBuf;
Expand Down Expand Up @@ -63,7 +66,7 @@ impl APU {
pub fn new(sample_rate: usize) -> Self {
let mut blip_buf = BlipBuf::new(sample_rate);
blip_buf.set_rates(CLOCK_FREQUENCY, sample_rate as u32);
let mut blip = Blip::new(blip_buf);
let blip = Blip::new(blip_buf);

Self {
audio_enabled: true,
Expand Down

0 comments on commit cd72a25

Please sign in to comment.