From 843f39ba736fc39c00275850ee2ec860093cd9a2 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 28 Mar 2018 23:36:08 -0700 Subject: Small cleanup to audio interface between emulation code and renderer backend --- ym2612.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'ym2612.c') diff --git a/ym2612.c b/ym2612.c index 7b45e67..11f4e19 100644 --- a/ym2612.c +++ b/ym2612.c @@ -168,8 +168,8 @@ void ym_init(ym2612_context * context, uint32_t sample_rate, uint32_t master_clo static uint8_t registered_finalize; dfopen(debug_file, "ym_debug.txt", "w"); memset(context, 0, sizeof(*context)); - context->audio_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2); - context->back_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2); + context->audio = render_audio_source(2); + context->audio_buffer = render_audio_source_buffer(context->audio); context->sample_rate = sample_rate; context->clock_inc = clock_div * 6; ym_adjust_master_clock(context, master_clock); @@ -266,13 +266,10 @@ void ym_init(ym2612_context * context, uint32_t sample_rate, uint32_t master_clo void ym_free(ym2612_context *context) { + render_free_source(context->audio); if (context == log_context) { ym_finalize_log(); } - free(context->audio_buffer); - //TODO: Figure out how to make this 100% safe - //audio thread could still be using this - free(context->back_buffer); free(context); } @@ -649,7 +646,8 @@ void ym_run(ym2612_context * context, uint32_t to_cycle) context->buffer_pos += 2; if (context->buffer_pos == context->sample_limit) { if (!headless) { - render_wait_ym(context); + context->audio_buffer = render_audio_ready(context->audio); + context->buffer_pos = 0; } } } -- cgit v1.2.3