myeffect.number = number;
pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (blorb_map->chunks[resource.chunknum].type == bb_make_id('F','O','R','M')) {
+ if (bleep_playing) {
+ bleep_playing = FALSE;
+ pthread_join(playaiff_id, NULL);
+ }
err = pthread_create(&playaiff_id, &attr, (void *) &playaiff, &myeffect);
if (err != 0) {
printf("Can't create playaiff thread :[%s]", strerror(err));
*/
void os_stop_sample (int number)
{
- if (bleep_playing && number == bleepnum) {
- bleep_stop = TRUE;
+ if (bleep_playing && (number == bleepnum || number == 0)) {
+ bleep_playing = FALSE;
+ while(pthread_kill(playaiff_id, 0) == 0);
}
return;
}/* os_stop_sample */
while (1) {
/* Check if we're being told to stop. */
- if (bleep_stop) break;
+ if (!bleep_playing) break;
sem_wait(&audio_empty);
pthread_mutex_lock(&mutex);
* Whichever, we need to clean up and terminate this thread.
*/
- bleep_stop = FALSE;
bleep_playing = FALSE;
fseek(myeffect.fp, filestart, SEEK_SET);
sf_close(sndfile);
+ free(floatbuffer);
+ free(floatbuffer2);
- pthread_exit((void*) raw_effect);
+ pthread_exit(NULL);
}