From: hgn Date: Wed, 27 Oct 2021 18:21:05 +0000 (+0100) Subject: better audio queuing X-Git-Url: https://harrygodden.com/git/?p=fishladder.git;a=commitdiff_plain;h=d7980e9e89e1e75ea457ff995fb199586260049c better audio queuing --- diff --git a/fishladder.c b/fishladder.c index d7a1f28..e8a8a3f 100644 --- a/fishladder.c +++ b/fishladder.c @@ -639,9 +639,9 @@ void vg_update(void) // Fish ticks if( world.simulating ) { - while( world.sim_frame < (int)((vg_time-world.sim_start)*20.0f) ) + while( world.sim_frame < (int)((vg_time-world.sim_start)*200.0f) ) { - vg_info( "frame: %u\n", world.sim_frame ); + //vg_info( "frame: %u\n", world.sim_frame ); sfx_set_playrnd( &audio_random, &audio_system_balls_switching, 0, 5 ); for( int i = 0; i < arrlen( world.io ); i ++ ) diff --git a/vg/vg_audio.h b/vg/vg_audio.h index 249bedc..e375a5b 100644 --- a/vg/vg_audio.h +++ b/vg/vg_audio.h @@ -36,8 +36,6 @@ struct sfx_system u32 ch, end, cur; u32 flags; - int is_queued; - // Effects u32 fadeout, fadeout_current; @@ -229,29 +227,19 @@ static int sfx_begin_edit( sfx_system *sys ) { MUTEX_LOCK( sfx_mux_t01 ); - if( sys->is_queued ) + if( sfx_q_len >= SFX_MAX_SYSTEMS ) { MUTEX_UNLOCK( sfx_mux_t01 ); - - vg_warn( "Sfx system locked for writing.. Spam is being created!\n" ); + vg_warn( "Warning: No free space in sound queue\n" ); return 0; } - sys->is_queued = 1; return 1; } // Mark change to be uploaded to queue system static int sfx_save( sfx_system *sys ) { - if( sfx_q_len >= SFX_MAX_SYSTEMS ) - { - vg_error( "Warning: No free space in sound queue\n" ); - - MUTEX_UNLOCK( sfx_mux_t01 ); - return 0; - } - // Mark change in queue sfx_q[ sfx_q_len ++ ] = sys; @@ -383,8 +371,6 @@ void audio_mixer_callback( ma_device *pDevice, void *pOutBuf, const void *pInput while( sfx_q_len --> 0 ) { sfx_system *src = sfx_q[sfx_q_len]; - src->is_queued = 0; - sfx_system *clone; // This is a 'new' sound if thread_clone not set. diff --git a/vg/vg_debug.h b/vg/vg_debug.h index 9f0ac1c..ba61dd2 100644 --- a/vg/vg_debug.h +++ b/vg/vg_debug.h @@ -44,19 +44,20 @@ static void sfx_internal_debug_overlay(void) // Draw audio stack for( int i = 0; i < num_systems; i ++ ) { - ui_global_ctx.cursor[2] = 300; - ui_global_ctx.cursor[3] = 25; + ui_global_ctx.cursor[2] = 150; + ui_global_ctx.cursor[3] = 12; u32 alpha = (infos[i].flags & SFX_FLAG_GHOST)? 0x44000000: 0xff000000; ui_new_node( &ui_global_ctx ); - { + { ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x00333333 | alpha ); - ui_global_ctx.cursor[2] = (int)(((float)infos[i].cursor / (float)infos[i].length) * 300.0f); + ui_rect_pad( ui_global_ctx.cursor, 2 ); + ui_global_ctx.cursor[2] = (int)(((float)infos[i].cursor / (float)infos[i].length) * 150.0f); ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x77ffffff ); - ui_text( &ui_global_ctx, infos[i].name, 2, 0 ); + ui_text( &ui_global_ctx, infos[i].name, 1, 0 ); } ui_end_down( &ui_global_ctx ); ui_global_ctx.cursor[1] += 1;