Skip to content

Commit

Permalink
Fix issue with audio_read_samples
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Sep 11, 2024
1 parent 8352959 commit e98bcab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ncc/examples/ball.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define BALL_RADIUS 20
#define AUDIO_LEN 8_000

// RGBA pixels: 800 * 600
// RGBA pixels
u32 frame_buffer[FRAME_HEIGHT][FRAME_WIDTH];

// Current ball position
Expand Down Expand Up @@ -58,7 +58,7 @@ void draw_ball()
void update()
{
// Clear the frame buffer, set all pixels to black
memset32(frame_buffer, 0, 800 * 600);
memset32(frame_buffer, 0, sizeof(frame_buffer) / sizeof(u32));

draw_ball();

Expand Down
7 changes: 1 addition & 6 deletions vm/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl AudioCallback for InputCB
// Copy the samples to make them accessible to the audio thread
INPUT_STATE.with_borrow_mut(|s| {
s.input_tid = self.thread.id;
s.samples.clear();
s.samples.resize(buf.len(), 0);
s.samples.copy_from_slice(buf);
});

Expand Down Expand Up @@ -110,11 +110,6 @@ thread_local! {
static INPUT_STATE: RefCell<InputState> = RefCell::new(InputState::default());
}






pub fn audio_open_output(thread: &mut Thread, sample_rate: Value, num_channels: Value, format: Value, cb: Value) -> Value
{
if thread.id != 0 {
Expand Down

0 comments on commit e98bcab

Please sign in to comment.