[AD] [alleg:bugs] #393 Audio sample instance with NULL data could lead to endless loop.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



[bugs:#393] Audio sample instance with NULL data could lead to endless loop.

Status: closed
Created: Sun Feb 23, 2014 01:42 PM UTC by MaxEd
Last Updated: Sun Feb 23, 2014 03:51 PM UTC
Owner: nobody

You can successfully create sound sample instance with NULL sample, but when you try to play it, Allegro will hang in endless loop.

    ALLEGRO_SAMPLE_INSTANCE *pInstance = al_create_sample_instance( 0 );
    al_attach_sample_instance_to_mixer( pInstance,  pMixer );
    al_set_sample_instance_playmode( pInstance, ALLEGRO_PLAYMODE_LOOP );
    al_play_sample_instance( pInstance );

The culprit is the following code in Audio addon (addons/audio/kcm_mixer.c):

  case ALLEGRO_PLAYMODE_LOOP:
     if (spl->step > 0) {
        while (spl->pos >= spl->loop_end) {
           spl->pos -= (spl->loop_end - spl->loop_start);
        }
     }
     else if (spl->step < 0) {
        while (spl->pos < spl->loop_start) {
           spl->pos += (spl->loop_end - spl->loop_start);
        }
     }
     return true;

The trouble is, if ( spl->loop_end == spl->loop_start ) this loop will never end.
So, at least a check of ( spl->loop_end > 0 ) would be welcome here.


Sent from sourceforge.net because alleg-developers@xxxxxxxxxx is subscribed to https://sourceforge.net/p/alleg/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alleg/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/