]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - ogg_afh.c
ogg_afh.c: make vi_sampling_rate, vi_bitrate local
[paraslash.git] / ogg_afh.c
index ad7da3ee89a7cb7e2c896b4bb9909e7c722afe39..ba9ef369b8761e6dac8e4c98a08c1673c7941f64 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -37,9 +37,8 @@ static double chunk_time = 0.25;
 static OggVorbis_File *oggvorbis_file;
 static int header_len;
 static char *header;
-static ssize_t *chunk_table, max_chunk_len, num_chunks;
+static ssize_t *chunk_table, num_chunks;
 static struct audio_format_handler *af;
-static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal;
 
 static int ogg_compute_header_len(FILE *file)
 {
@@ -148,10 +147,10 @@ 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;
+       ssize_t max_chunk_len, pos = 0, min = 0, old_pos;
 
        old_pos = 0;
        ret = 0;
@@ -161,7 +160,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 +181,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)
@@ -224,6 +221,7 @@ static int ogg_get_file_info(FILE *file, char *info_str, long unsigned *frames,
        double time_total;
        vorbis_info *vi;
        ogg_int64_t raw_total;
+       long vi_sampling_rate, vi_bitrate;
 
        if (!file)
                return -E_OGG_NO_FILE;
@@ -250,8 +248,9 @@ static int ogg_get_file_info(FILE *file, char *info_str, long unsigned *frames,
        *seconds = time_total;
        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"