X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mp3.c;h=bac84b6f9ca0e8b0677f7fec691bb42084dff760;hp=3f8eb009bbd3f0cf2b713a9abba72902f08a9cca;hb=e921be422a216b87e3e6812f16b27c9a6927099d;hpb=e0e5a7c1a04c6a2ee4a475e823657e06e6df2f99 diff --git a/mp3.c b/mp3.c index 3f8eb009..bac84b6f 100644 --- a/mp3.c +++ b/mp3.c @@ -32,6 +32,7 @@ #include "server.h" #include "afs.h" #include "error.h" +#include "fd.h" /** \cond some defines and structs which are only used in this file */ @@ -106,17 +107,7 @@ static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mon static struct mp3info mp3; static char mp3buf[8192]; static int chunk_size; -static struct audio_format *af; - -static __must_check int para_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - size_t res = fread(ptr, size, nmemb, stream); - if (res == nmemb) - return size * nmemb; - if (feof(stream)) - return 0; - return -E_FREAD; -} +static struct audio_format_handler *af; static int header_frequency(struct mp3header *h) { @@ -159,11 +150,11 @@ static void write_info_str(char *info_str) int v = mp3.id3_isvalid; snprintf(info_str, MMD_INFO_SIZE, - "audio_file_info1:%d x %lu, %lu kbit/s (%cbr) %i KHz %s\n" + "audio_file_info1:%d x %lums, %lu kbit/s (%cbr) %i KHz %s\n" "audio_file_info2:%s, by %s\n" "audio_file_info3:A: %s, Y: %s, C: %s\n", mp3.frames, - af->chunk_tv.tv_usec, + tv2ms(&af->chunk_tv), mp3.br_average, mp3.vbr? 'v' : 'c', mp3.freq / 1000, @@ -410,7 +401,7 @@ static int mp3_read_info(void) mp3.seconds = (tv2ms(&total_time) + 500) / 1000; tv_divide(fcount, &total_time, &af->chunk_tv); rewind(mp3.file); - PARA_DEBUG_LOG("chunk_time: %lu\n", af->chunk_tv.tv_usec); + PARA_DEBUG_LOG("chunk_time: %lums\n", tv2ms(&af->chunk_tv)); tv_scale(30, &af->chunk_tv, &af->eof_tv); PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&af->eof_tv)); return 1; @@ -490,6 +481,7 @@ static void mp3_close_audio_file(void) mp3.file = NULL; } +static const char* mp3_suffixes[] = {"mp3", NULL}; void mp3_init(void *p) { af = p; @@ -501,4 +493,5 @@ void mp3_init(void *p) /* eof_tv gets overwritten in mp3_get_file_info() */ af->eof_tv.tv_sec = 0; af->eof_tv.tv_usec = 100 * 1000; + af->suffixes = mp3_suffixes; }