better audio queuing
authorhgn <hgodden00@gmail.com>
Wed, 27 Oct 2021 18:21:05 +0000 (19:21 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 27 Oct 2021 18:21:05 +0000 (19:21 +0100)
fishladder.c
vg/vg_audio.h
vg/vg_debug.h

index d7a1f28343749ef16bbb47c3c8853af2cba18ad5..e8a8a3fad09286aead57c21cc1099c71be6cebb3 100644 (file)
@@ -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 ++ )
index 249bedc8f390452ba9a98adab4d6cbaecee7d535..e375a5bf087159f74bd0a4dabdc0b5275a965326 100644 (file)
@@ -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.
index 9f0ac1c81eb3ee33d5870934093867a3531b0ecc..ba61dd21a120e8685c247a828f58cc3077192c24 100644 (file)
@@ -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;