int repeats;
} EFFECT;
-static void paiff(void *);
-static int playaiff(EFFECT);
+static void *playaiff(EFFECT *);
static int playmod(EFFECT);
static int playogg(EFFECT);
static void floattopcm16(short *, float *, int);
{
bb_result_t resource;
EFFECT myeffect;
+ int err;
+ static pthread_attr_t attr;
+
if (blorb_map == NULL) return;
myeffect.vol = volume;
myeffect.repeats = repeats;
- if (blorb_map->chunks[resource.chunknum].type == bb_make_id('F','O','R','M')) {
- playaiff(myeffect);
+ 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')) {
+ err = pthread_create(&playaiff_id, &attr, (void *) &playaiff, &myeffect);
+ if (err != 0) {
+ printf("Can't create playaiff thread :[%s]", strerror(err));
+ exit(1);
+ }
} else if (blorb_map->chunks[resource.chunknum].type == bb_make_id('M','O','D',' ')) {
playmod(myeffect);
/* Something else was in there. Ignore it. */
}
+ /* If I don't have this usleep() here, Frotz will segfault. Why?*/
+ usleep(0);
}/* os_start_sample */
/*
}
}
-static void paiff(void *pass_arg)
-{
- EFFECT *foobar = pass_arg;
-
- playaiff(*foobar);
-
- return;
-}
/*
* playaiff
*
* the big problem is.
*
*/
-static int playaiff(EFFECT myeffect)
+void *playaiff(EFFECT *raw_effect)
{
int frames_read;
int count;
SNDFILE *sndfile;
SF_INFO sf_info;
+ EFFECT myeffect = *raw_effect;
sf_info.format = 0;
fseek(myeffect.fp, filestart, SEEK_SET);
sf_close(sndfile);
- return(1);
-
+ pthread_exit((void*) raw_effect);
}