added reasons for the sound stop callback

This commit is contained in:
Andre Leiradella 2015-05-18 15:05:14 -03:00
parent e65aa8bf0d
commit d2d1a4d338
2 changed files with 27 additions and 7 deletions

View File

@ -139,7 +139,7 @@ void rl_sound_stop( int index )
if ( voice->stop_cb && voice->sound )
{
voice->stop_cb( voice->sound );
voice->stop_cb( voice->sound, RL_SOUND_STOPPED );
}
voice->sound = NULL;
@ -154,7 +154,7 @@ void rl_sound_stop_all( void )
{
if ( voice->stop_cb && voice->sound )
{
voice->stop_cb( voice->sound );
voice->stop_cb( voice->sound, RL_SOUND_STOPPED );
}
voice->sound = NULL;
@ -228,7 +228,7 @@ void rl_sound_stop_ogg( void )
if ( ogg_stop_cb )
{
ogg_stop_cb( NULL );
ogg_stop_cb( NULL, RL_SOUND_STOPPED );
}
ogg_stream = NULL;
@ -250,6 +250,11 @@ static void ogg_mix( int32_t* buffer )
{
if ( ogg_repeat )
{
if ( ogg_stop_cb )
{
ogg_stop_cb( NULL, RL_SOUND_REPEATED );
}
stb_vorbis_seek_start( ogg_stream );
goto again;
}
@ -257,7 +262,7 @@ static void ogg_mix( int32_t* buffer )
{
if ( ogg_stop_cb )
{
ogg_stop_cb( NULL );
ogg_stop_cb( NULL, RL_SOUND_FINISHED );
}
stb_vorbis_close( ogg_stream );
@ -316,6 +321,11 @@ again:
if ( voice->repeat )
{
if ( voice->stop_cb )
{
voice->stop_cb( voice->sound, RL_SOUND_REPEATED );
}
buf_free -= pcm_available;
voice->position = 0;
goto again;
@ -323,7 +333,7 @@ again:
if ( voice->stop_cb )
{
voice->stop_cb( voice->sound );
voice->stop_cb( voice->sound, RL_SOUND_FINISHED );
}
voice->sound = NULL;
@ -355,6 +365,11 @@ again:
if ( voice->repeat )
{
if ( voice->stop_cb )
{
voice->stop_cb( voice->sound, RL_SOUND_REPEATED );
}
buf_free -= pcm_available;
voice->position = 0;
goto again;
@ -362,7 +377,7 @@ again:
if ( voice->stop_cb )
{
voice->stop_cb( voice->sound );
voice->stop_cb( voice->sound, RL_SOUND_FINISHED );
}
voice->sound = NULL;

View File

@ -9,6 +9,11 @@
/* Number of 16-bit stereo samples per frame. DO NOT CHANGE! */
#define RL_SAMPLES_PER_FRAME 735
/* Reasons passed to the stop callback. */
#define RL_SOUND_FINISHED 0
#define RL_SOUND_STOPPED 1
#define RL_SOUND_REPEATED 2
typedef struct
{
rl_userdata_t ud;
@ -18,7 +23,7 @@ typedef struct
}
rl_sound_t;
typedef void ( *rl_soundstop_t )( const rl_sound_t* );
typedef void ( *rl_soundstop_t )( const rl_sound_t*, int reason );
void rl_sound_init( void );
void rl_sound_done( void );