My program needs to stop playing sound if certain point is in range, for that I have class with function run()
which runs on seperate thread and plays sound using SDL.h
and SDL_mixer.h
:
void SoundCheck::run()
{
Mix_PlayMusic(music, 1);
while(1)
{
if(normalize(sound[0], range_->getPos()))
{
printf("stop sound\n");
Mix_HaltChannel(-1);
}
sleep(1);
}
}
but when if
condition returns true it prints "stop sound" but sound still plays, what seems to be the problem?