fix bug with audio fadeout
[fishladder.git] / vg / vg_audio.h
index c0a3720e898e4f8c98748f65b133a8f3e1fbb391..0c9a666691e64f62f4926041d41f4fc0679e33cf 100644 (file)
@@ -654,13 +654,21 @@ static void sfx_system_fadeout( sfx_system *sys, u32 length_samples )
 {
        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 );
+               }
        }
 }