{
int err;
-/*
- format.byte_format = AO_FMT_NATIVE;
- format.bits = 16;
- format.channels = 2;
- format.rate = SAMPLERATE;
-*/
musicbuffer = malloc(BUFFSIZE * 2 * sizeof(float));
if (musicbuffer == NULL) {
printf("Unable to malloc musicbuffer\n");
if (blorb_map->chunks[resource.chunknum].type == bb_make_id('F','O','R','M')) {
playaiff(myeffect);
+
+
} else if (blorb_map->chunks[resource.chunknum].type == bb_make_id('M','O','D',' ')) {
playmod(myeffect);
} else if (blorb_map->chunks[resource.chunknum].type == bb_make_id('O','G','G','V')) {
format.channels = 2;
format.rate = SAMPLERATE;
+ device = NULL;
+
while (1) {
sem_wait(&audio_full); /* Wait until output buffer is full */
pthread_mutex_lock(&mutex); /* Acquire mutex */
- device = ao_open_live(default_driver, &format, NULL);
- if (device == NULL) {
- printf(" Error opening sound device.\n");
+ if (bleep_playing && device == NULL) {
+ device = ao_open_live(default_driver, &format, NULL);
+ if (device == NULL) {
+ printf(" Error opening sound device.\n");
+ }
}
floattopcm16(shortbuffer, bleepbuffer, BUFFSIZE * 2);
ao_play(device, (char *) shortbuffer, bleepcount * 2);
- ao_close(device);
+ if (!bleep_playing) {
+ ao_close(device);
+ device = NULL;
+ }
pthread_mutex_unlock(&mutex); /* release the mutex lock */
sem_post(&audio_empty); /* signal empty */
}
}
-
-void *startsample(void *pass_arg)
-{
-}
-
/*
* playaiff
*
sf_count_t toread;
long filestart;
-// EFFECT *myeffect = pass_arg;
-
int volcount;
int volfactor;
frames_read = 0;
toread = sf_info.frames * sf_info.channels;
-// device = ao_open_live(default_driver, &format, NULL);
+ bleep_playing = TRUE;
while (toread > 0) {
sem_wait(&audio_empty);
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
sem_post(&audio_full);
}
-
-// ao_close(device);
+ bleep_playing = FALSE;
fseek(myeffect.fp, filestart, SEEK_SET);
sf_close(sndfile);