-1

I want to stop my sample at certain point , but it sends me some weird error. This is my code:

ALLEGRO_SAMPLE_ID id;
ALLEGRO_SAMPLE* spl = al_load_sample("sound.ogg");
al_play_sample(spl, 1.0, 0, 1.0, 0, &id);
al_stop_sample(&id);
al_destroy_sample(spl)
0liCom
  • 35
  • 8

2 Answers2

0

As suggested here, Allegro most likely had bad luck being destroyed before the object doing playback is trying to stop & destroy:

Have you made sure that Allegro was deinitialized after you destroyed everything? I've encountered this problem by putting the shutdown code in an atexit callback but letting Allegro register a custom atexit callback. In such a situation, Allegro's atexit callback may be run first, so instead of al_init() you have to use al_install_system(NULL, ALLEGRO_VERSION_INT) and call al_uninstall_system() in your custom atexit callback.

Dmitry Mikushin
  • 1,478
  • 15
  • 16
-1

try this

ALLEGRO_SAMPLE_ID *id_sample = NULL;
id_sample = malloc(sizeof(ALLEGRO_SAMPLE_ID));
l_play_sample(sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_BIDIR, id_sample);
printf("id_sample %p\n", id_sample);
al_rest(2);
al_stop_sample(id_sample);