Skip to content

Commit e98bcab

Browse files
committed
Fix issue with audio_read_samples
1 parent 8352959 commit e98bcab

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

ncc/examples/ball.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define BALL_RADIUS 20
1010
#define AUDIO_LEN 8_000
1111

12-
// RGBA pixels: 800 * 600
12+
// RGBA pixels
1313
u32 frame_buffer[FRAME_HEIGHT][FRAME_WIDTH];
1414

1515
// Current ball position
@@ -58,7 +58,7 @@ void draw_ball()
5858
void update()
5959
{
6060
// Clear the frame buffer, set all pixels to black
61-
memset32(frame_buffer, 0, 800 * 600);
61+
memset32(frame_buffer, 0, sizeof(frame_buffer) / sizeof(u32));
6262

6363
draw_ball();
6464

vm/src/audio.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl AudioCallback for InputCB
7676
// Copy the samples to make them accessible to the audio thread
7777
INPUT_STATE.with_borrow_mut(|s| {
7878
s.input_tid = self.thread.id;
79-
s.samples.clear();
79+
s.samples.resize(buf.len(), 0);
8080
s.samples.copy_from_slice(buf);
8181
});
8282

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

113-
114-
115-
116-
117-
118113
pub fn audio_open_output(thread: &mut Thread, sample_rate: Value, num_channels: Value, format: Value, cb: Value) -> Value
119114
{
120115
if thread.id != 0 {

0 commit comments

Comments
 (0)