fread(data, *size, sizeof(char), fp);
fseek(fp, offset, SEEK_SET);
return(data);
-}
+} /* getfiledata */
static
int32_t make_id(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
{
return (a << 24) | (b << 16) | (c << 8) | d;
-}
+} /* make_id */
static int
if (magic == make_id('O','G','G','V'))
return OGGV;
return -1;
-}
+} /* get_type */
static float
if (v<mn) return mn;
if (v>mx) return mx;
return v;
-}
+} /* limit */
/**********************************************************************
rsmp->src_data.end_of_input = 0;
return rsmp;
-}
+} /* resampler_init */
+
+
static void
resampler_cleanup(resampler_t *rsmp)
{
free(rsmp->input);
free(rsmp->output);
free(rsmp->scratch);
-}
+} /* resampler_cleanup */
/*0 done running, 1 run again with more data*/
if (rsmp->src_data.output_frames == 0)
return 0;
return 1;
-}
+} /* resampler_step */
static void
{
rsmp->src_data.data_out = rsmp->output;
rsmp->src_data.output_frames = frotz_audio.buffer_size;
-}
+} /* resampler_consume */
/**********************************************************************
return 0;
return 1;
-}
+} /* process_mod */
+
static void
cleanup_mod(sound_stream_t *s)
ModPlug_Unload(self->mod);
free(self->shortbuffer);
free(self->filedata);
-}
+} /* cleanup_mod */
/*file, data start, id, volume*/
stream->shortbuffer = (int16_t*)calloc(frotz_audio.buffer_size, sizeof(short) * 2);
return (sound_stream_t*)stream;
-}
+} /* load_mod */
+
/**********************************************************************
* AIFF/OGG *
}
return 1;
-}
+} /* process_aiff */
static void
free(self->rsmp);
sf_close(self->sndfile);
free(self->floatbuffer);
-}
+} /* cleanup_aiff */
static sf_count_t
to_read -= did_read;
}
return read_total;
-}
+} /* mem_snd_read */
static sf_count_t
fr->pos = pos;
return 0;
-}
+} /* mem_snd_seek */
static long
mem_tell(void *datasource) {
file_reader_t *fr = (file_reader_t*)datasource;
return fr->pos;
-}
+} /* mem_tell */
static sf_count_t
{
file_reader_t *fr = (file_reader_t*)datasource;
return fr->len;
-}
+} /* mem_get_filelen */
static sound_stream_t *
aiff->sf_info.channels * sizeof(float));
return (sound_stream_t*) aiff;
-}
+} /* load_aiff */
}
}
}
-}
+} /* process_engine */
static void*
ao_play(device, (char*)buf, outsize);
}
return 0;
-}
+} /* audio_loop */
static void
free(s);
}
}
-}
+} /* sound_halt_aiff */
static void
free(s);
}
}
-}
+} /* sound_halt_mod */
static void
free(s);
}
}
-}
+} /* sound_halt_ogg */
static sound_stream_t *load_mod(FILE *fp, long startpos, int id, float volume);
frotz_audio.event.type = EVENT_STOP_STREAM;
frotz_audio.event.data.i = id;
ux_sem_post(&frotz_audio.ev_pending);
-}
+} /* sound_stop_id */
static void
free(s);
}
}
-}
+} /* sound_stop_id_real */
static void
frotz_audio.event.type = EVENT_START_STREAM;
frotz_audio.event.data.e = s;
ux_sem_post(&frotz_audio.ev_pending);
-}
+} /* sound_enqueue */
static void
e->voices[i].repid = 0;
break;
}
-}
+} /* sound_enqueue_real */
static float
if (vol > 8) vol = 8;
return lut[vol-1];
/* return powf(2, vol - 8); */
-}
+} /* volume_factor */
/**********************************************************************
fprintf(stderr, "Can't create audio thread :[%s]", strerror(err));
os_quit(EXIT_FAILURE);
}
-}
+} /* os_init_sound */
/*
if (s)
sound_enqueue(s);
-}
+} /* os_start_sample */
void os_beep(int bv)
/* low frequency for bv=2 */
/* fprintf(audio_log, "os_beep(%d)...\n", bv); */
beep();
-}
+} /* os_beep */
void os_prepare_sample(int id)
(void) id;
/* Currently not implemented */
/* fprintf(audio_log, "os_prepare_sample(%d)...\n", id); */
-}
+} /* os_prepare_sample */
void os_stop_sample(int id)
/* fprintf(audio_log, "os_stop_sample(%d)...\n", id); */
if (!f_setup.sound) return;
sound_stop_id(id);
-}
+} /* os_stop_sample */
+
void os_finish_with_sample(int id)
{
/* fprintf(audio_log, "os_finish_with_sample(%d)...\n", id); */
os_stop_sample(id);
-}
+} /* os_finish_with_sample */
#endif /* NO_SOUND */
if (mixer_fd >= 0)
ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &old_volume);
_exit(EXIT_SUCCESS);
-}
+} /* sigterm_handler */
+
static void oss_sigint_handler(int signal) {
num_repeats = 1;
-}
+} /* oss_sigint_handler */
+
static void play_sound(int volume, int repeats) {
struct sigaction sa;
if (mixer_fd >= 0)
ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &old_volume);
_exit(EXIT_SUCCESS);
-}
+} /* play_sound */
/*
* or low-pitched (number == 2).
*
*/
-
void os_beep (int number)
{
/* This should later be expanded to support high and low beeps. */
* Load the sample from the disk.
*
*/
-
void os_prepare_sample (int number)
{
FILE *samples;
sa.sa_flags = 0;
sigaction(SIGCHLD, &sa, NULL);
end_of_sound();
-}
+} /* sigchld_handler */
/*
* as the sound finishes.
*
*/
-
void os_start_sample (int number, int volume, int repeats, zword eos)
{
/* INCOMPLETE */
sigaction(SIGCHLD, &sa, NULL);
sigprocmask(SIG_UNBLOCK, &sigchld_mask, NULL);
-}
+} /* stop_player */
/*
* Remove the current sample from memory (if any).
*
*/
-
void os_finish_with_sample (int number)
{
/* INCOMPLETE */
* Stop repeating the current sample and wait until it finishes.
*
*/
-
void os_wait_sample (void)
{
stop_player(SIGINT);