From 333c6e79e67b0edfd52869724c983694758bcd37 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 5 Mar 2007 00:15:38 +0100 Subject: [PATCH] ogg_afh.c: Kill global variable num_chunks The code is more readable if this is returned by ogg_compute_chunk_table() and passed where neccessary. --- ogg_afh.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ogg_afh.c b/ogg_afh.c index ba9ef369..379a0ef4 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -37,7 +37,7 @@ static double chunk_time = 0.25; static OggVorbis_File *oggvorbis_file; static int header_len; static char *header; -static ssize_t *chunk_table, num_chunks; +static ssize_t *chunk_table; static struct audio_format_handler *af; static int ogg_compute_header_len(FILE *file) @@ -117,7 +117,7 @@ err1: return ret; } -static void tunetable(void) +static void tunetable(long unsigned num_chunks) { int i = 1, j = -1, lp = 1; while (i < num_chunks) { @@ -147,10 +147,11 @@ 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(double time_total) +static long unsigned ogg_compute_chunk_table(double time_total) { int i, ret, num; ssize_t max_chunk_len, pos = 0, min = 0, old_pos; + long unsigned num_chunks; old_pos = 0; ret = 0; @@ -178,9 +179,10 @@ static void ogg_compute_chunk_table(double time_total) } num_chunks = i - 1; chunk_table[i] = pos; - tunetable(); + tunetable(num_chunks); PARA_INFO_LOG("%zu chunks (%fs), max chunk: %zd, min chunk: %zd\n", num_chunks, chunk_time, max_chunk_len, min); + return num_chunks; } static void ogg_close_audio_file(void) @@ -196,7 +198,6 @@ static void ogg_close_audio_file(void) header_len = 0; free(chunk_table); chunk_table = NULL; - num_chunks = 0; } static int ogg_save_header(FILE *file, int len) @@ -249,14 +250,13 @@ 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); rewind(file); - ogg_compute_chunk_table(time_total); + *frames = 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" + sprintf(info_str, "audio_file_info1:%lu x %lu, %ldkHz, %d channels, %ldkbps\n" "audio_file_info2: \n" "audio_file_info3: \n", - num_chunks, (long unsigned) (chunk_time * 1000 * 1000), + *frames, (long unsigned) (chunk_time * 1000 * 1000), vi_sampling_rate / 1000, vi->channels, vi_bitrate / 1000 ); rewind(file); -- 2.39.5