]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aac_afh.c
struct audio_format_handler: use proper pointer type for the init function
[paraslash.git] / aac_afh.c
index b091db03df14212bdb3d91a36c737b24170cd64f..a8d162e4b7de7a895969c53ada0fb67a9c08367e 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -28,6 +28,7 @@
 #include "error.h"
 #include "string.h"
 #include "aac.h"
+#include "fd.h"
 
 /* must be big enough to hold header */
 #define DEFAULT_INBUF_SIZE 65536
@@ -36,16 +37,19 @@ static FILE *infile;
 static int inbuf_size;
 static unsigned char *inbuf;
 static size_t inbuf_len;
-struct audio_format *af;
+struct audio_format_handler *af;
 static size_t num_chunks;
 static size_t entry;
 
 static size_t *chunk_table;
 NeAACDecHandle handle;
 
-
 static void aac_close_audio_file(void)
 {
+       if (!infile)
+               return;
+       fclose(infile);
+       infile = NULL;
 }
 
 static int aac_find_stsz(unsigned char *buf, unsigned buflen, size_t *skip)
@@ -197,16 +201,6 @@ static int aac_reposition_stream(long unsigned request)
 //     return -E_AAC_REPOS;
 }
 
-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 char *aac_read_chunk(long unsigned current_chunk, ssize_t *len)
 {
        int ret;
@@ -239,7 +233,9 @@ static char *aac_read_chunk(long unsigned current_chunk, ssize_t *len)
        return (char *)inbuf;
 }
 
-void aac_afh_init(void *p)
+static const char* aac_suffixes[] = {"m4a", NULL};
+/** the init function of the aac audio format handler */
+void aac_afh_init(struct audio_format_handler *p)
 {
        af = p;
        af->reposition_stream = aac_reposition_stream;
@@ -250,4 +246,5 @@ void aac_afh_init(void *p)
        af->chunk_tv.tv_sec = 0;
        af->chunk_tv.tv_usec = 23120;
        tv_scale(3, &af->chunk_tv, &af->eof_tv);
+       af->suffixes = aac_suffixes;
 }