vss.c: Introduce get_audio_file_info().
authorAndre Noll <maan@systemlinux.org>
Sun, 9 Sep 2007 12:56:41 +0000 (14:56 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 9 Sep 2007 12:56:41 +0000 (14:56 +0200)
This is going to be used from within aft's com_add() which ATM only
supports mp3.

chunk_queue.c
vss.c
vss.h

index 0b1e300..17d70ea 100644 (file)
@@ -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 d0f57ae..e0c0b58 100644 (file)
--- 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 7d2764d..3374e94 100644 (file)
--- 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);