projects
/
fishladder.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2f91573
)
fix bug with audio fadeout
author
hgn
<hgodden00@gmail.com>
Sun, 14 Nov 2021 09:35:14 +0000
(09:35 +0000)
committer
hgn
<hgodden00@gmail.com>
Sun, 14 Nov 2021 09:35:14 +0000
(09:35 +0000)
fishladder.c
patch
|
blob
|
history
vg/vg_audio.h
patch
|
blob
|
history
diff --git
a/fishladder.c
b/fishladder.c
index 66a3eba09c6987d391f27df522135e8022294ede..0abe4b52946b9490dfa3f85bd8c53291a9020136 100644
(file)
--- a/
fishladder.c
+++ b/
fishladder.c
@@
-502,6
+502,20
@@
static int console_load_map( int argc, char const *argv[] )
}
}
}
}
+static void simulation_stop(void)
+{
+ world.simulating = 0;
+ world.num_fishes = 0;
+ world.sim_frame = 0;
+
+ for( int i = 0; i < arrlen( world.io ); i ++ )
+ world.io[i].recv_count = 0;
+
+ sfx_system_fadeout( &audio_system_balls_rolling, 44100 );
+
+ vg_info( "Stopping simulation!\n" );
+}
+
static int console_changelevel( int argc, char const *argv[] )
{
if( argc >= 1 )
static int console_changelevel( int argc, char const *argv[] )
{
if( argc >= 1 )
@@
-509,7
+523,10
@@
static int console_changelevel( int argc, char const *argv[] )
// Save current level
if( console_save_map( 0, NULL ) )
if( console_load_map( argc, argv ) )
// Save current level
if( console_save_map( 0, NULL ) )
if( console_load_map( argc, argv ) )
+ {
+ simulation_stop();
return 1;
return 1;
+ }
}
else
{
}
else
{
@@
-795,22
+812,6
@@
void vg_update(void)
if( vg_get_button_down( "prev" ) ) { if( curlevel > 0 ) changelvl --; }
else if( vg_get_button_down( "next" ) ) { if( curlevel < vg_list_size( level_pack )-1 ) changelvl ++; }
if( vg_get_button_down( "prev" ) ) { if( curlevel > 0 ) changelvl --; }
else if( vg_get_button_down( "next" ) ) { if( curlevel < vg_list_size( level_pack )-1 ) changelvl ++; }
- if( changelvl != curlevel )
- {
- console_changelevel( 1, level_pack + changelvl );
- curlevel = changelvl;
-
- // TEMP!!! code dupe
- world.simulating = 0;
- world.num_fishes = 0;
- world.sim_frame = 0;
-
- for( int i = 0; i < arrlen( world.io ); i ++ )
- world.io[i].recv_count = 0;
-
- vg_info( "Stopping simulation!\n" );
- }
-
// Fit within screen
float r1 = (float)vg_window_y / (float)vg_window_x,
// Fit within screen
float r1 = (float)vg_window_y / (float)vg_window_x,
@@
-866,16
+867,7
@@
void vg_update(void)
{
if( world.simulating )
{
{
if( world.simulating )
{
- world.simulating = 0;
- world.num_fishes = 0;
- world.sim_frame = 0;
-
- for( int i = 0; i < arrlen( world.io ); i ++ )
- world.io[i].recv_count = 0;
-
- vg_info( "Stopping simulation!\n" );
-
- sfx_system_fadeout( &audio_system_balls_rolling, 44100 );
+ simulation_stop();
}
else
{
}
else
{
diff --git
a/vg/vg_audio.h
b/vg/vg_audio.h
index c0a3720e898e4f8c98748f65b133a8f3e1fbb391..0c9a666691e64f62f4926041d41f4fc0679e33cf 100644
(file)
--- a/
vg/vg_audio.h
+++ b/
vg/vg_audio.h
@@
-654,13
+654,21
@@
static void sfx_system_fadeout( sfx_system *sys, u32 length_samples )
{
if( sfx_begin_edit( sys ) )
{
{
if( sfx_begin_edit( sys ) )
{
- sys->fadeout_current = length_samples;
- sys->fadeout = length_samples;
+ if( sys->end )
+ {
+ sys->fadeout_current = length_samples;
+ sys->fadeout = length_samples;
+
+ if( sys->thread_clone )
+ sys->cur = sys->thread_clone->cur;
- if( sys->thread_clone )
- sys->cur = sys->thread_clone->cur;
-
- sfx_save( sys );
+ sfx_save( sys );
+ }
+ else
+ {
+ // Sound was not initialized
+ MUTEX_UNLOCK( sfx_mux_t01 );
+ }
}
}
}
}