From: Andre Noll Date: Sun, 4 Mar 2007 22:54:17 +0000 (+0100) Subject: simplify ogg_compute_chunk_table() X-Git-Tag: v0.2.16~57 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=ec48b7d6022f59f509cedcbdd635979e37671d4e;p=paraslash.git simplify ogg_compute_chunk_table() it rewinds the input file on entry and on exit. Do this in the caller instead which allows to get rid of the file parameter in ogg_compute_chunk_table(). --- diff --git a/ogg_afh.c b/ogg_afh.c index ad7da3ee..6ca31a58 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -148,7 +148,7 @@ static void tunetable(void) * offset in the current input file at which the sample containing time i * * CHUNK_TIME begins. */ -static void ogg_compute_chunk_table(FILE *file, double time_total) +static void ogg_compute_chunk_table(double time_total) { int i, ret, num; ssize_t pos = 0, min = 0, old_pos; @@ -161,7 +161,6 @@ static void ogg_compute_chunk_table(FILE *file, double time_total) chunk_table = para_malloc(num * sizeof(size_t)); chunk_table[0] = 0; max_chunk_len = 0; - rewind(file); for (i = 1; ret == 0; i++) { ogg_int64_t diff; ret = ov_time_seek(oggvorbis_file, i * chunk_time); @@ -183,7 +182,6 @@ static void ogg_compute_chunk_table(FILE *file, double time_total) tunetable(); PARA_INFO_LOG("%zu chunks (%fs), max chunk: %zd, min chunk: %zd\n", num_chunks, chunk_time, max_chunk_len, min); - rewind(file); } static void ogg_close_audio_file(void) @@ -251,7 +249,9 @@ static int ogg_get_file_info(FILE *file, char *info_str, long unsigned *frames, vi_sampling_rate = vi->rate; vi_bitrate = ov_bitrate(oggvorbis_file, 0); vi_bitrate_nominal = vi->bitrate_nominal; - ogg_compute_chunk_table(file, time_total); + rewind(file); + ogg_compute_chunk_table(time_total); + rewind(file); *frames = num_chunks; *vss_chunk_table = chunk_table; sprintf(info_str, "audio_file_info1:%zu x %lu, %ldkHz, %d channels, %ldkbps\n"