From: Andre Noll Date: Sun, 9 Sep 2007 12:56:41 +0000 (+0200) Subject: vss.c: Introduce get_audio_file_info(). X-Git-Tag: v0.3.0~440 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=a4aada551a8f979918024e28343b90e0690542c2 vss.c: Introduce get_audio_file_info(). This is going to be used from within aft's com_add() which ATM only supports mp3. --- diff --git a/chunk_queue.c b/chunk_queue.c index 0b1e3000..17d70eac 100644 --- a/chunk_queue.c +++ b/chunk_queue.c @@ -8,6 +8,7 @@ #include "para.h" #include "list.h" +#include "afh.h" #include "vss.h" #include "string.h" #include "error.h" diff --git a/vss.c b/vss.c index d0f57aec..e0c0b584 100644 --- a/vss.c +++ b/vss.c @@ -226,6 +226,26 @@ static int get_audio_format(int omit) return -E_AUDIO_FORMAT; } +int get_audio_file_info(const char *path, char *data, size_t size, + struct audio_format_info *afhi) +{ + int ret, i, format = guess_audio_format(path); + if (format >= 0) { + ret = afl[format].get_file_info(data, size, afhi); + if (ret >= 0) + return ret; + } + FOR_EACH_AUDIO_FORMAT(i) { + if (i == format) /* we already tried this one to no avail */ + continue; + ret = afl[i].get_file_info(data, size, afhi); + if (ret >= 0) + return ret; + } + return -E_AUDIO_FORMAT; + +} + /* * upddate shared mem */ diff --git a/vss.h b/vss.h index 7d2764da..3374e946 100644 --- a/vss.h +++ b/vss.h @@ -16,6 +16,8 @@ unsigned int vss_paused(void); char *vss_get_header(size_t *header_len); struct timeval *vss_chunk_time(void); int guess_audio_format(const char *name); +int get_audio_file_info(const char *path, char *data, size_t size, + struct audio_format_info *afhi); const char *supported_audio_formats(void); int vss_get_chunk(long unsigned chunk_num, char **buf, size_t *len);