summaryrefslogtreecommitdiff
path: root/reduced_system_layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'reduced_system_layer.c')
-rwxr-xr-xreduced_system_layer.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/reduced_system_layer.c b/reduced_system_layer.c
index c272711..64b7cfb 100755
--- a/reduced_system_layer.c
+++ b/reduced_system_layer.c
@@ -163,7 +163,7 @@ enum {
AUDIO_NUM_CHANNELS = 2,
AUDIO_SAMPLE_RATE = 44100,
- AUDIO_AVAIL_MIN = 256,
+ AUDIO_AVAIL_MIN = 512,
MAX_NUM_AUDIO_FRAMES = 10 * AUDIO_SAMPLE_RATE * AUDIO_NUM_CHANNELS, // 10 seconds
@@ -399,6 +399,10 @@ f64 atan2(f64 y, f64 x);
#ifndef NULL
#define NULL ((void *) 0)
#endif
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
#endif
#ifdef __cplusplus
@@ -1626,6 +1630,7 @@ __attribute__((export_name("js_main"))) void js_main(c8 *href) {
}
__attribute__((export_name("js_init"))) void js_init(void) {
+ ++_num_events;
platform.pixels = _buffer;
platform.input = _input;
platform.done = 1;
@@ -1733,7 +1738,7 @@ void p_queue_sound(i64 delay_in_samples, i64 num_samples, f32 *frames) {
if (num_frames > MAX_NUM_AUDIO_FRAMES)
return;
- i64 begin = (_sound_position + AUDIO_AVAIL_MIN + delay_in_samples * AUDIO_NUM_CHANNELS) % MAX_NUM_AUDIO_FRAMES;
+ i64 begin = (_sound_position + delay_in_samples * AUDIO_NUM_CHANNELS) % MAX_NUM_AUDIO_FRAMES;
if (num_frames <= MAX_NUM_AUDIO_FRAMES - begin)
for (i64 i = 0; i < num_frames; ++i)
@@ -1766,7 +1771,7 @@ __attribute__((export_name("js_sound_buffer"))) void *js_sound_buffer(void) {
}
__attribute__((export_name("js_sound_sync"))) void js_sound_sync(void) {
- _sound_position = 0;
+ _sound_position = AUDIO_AVAIL_MIN;
for (i64 i = 0; i < MAX_NUM_AUDIO_FRAMES; ++i)
_sound_ring[i] = 0.f;
}