]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Various wma fixes.
authorAndre Noll <maan@systemlinux.org>
Wed, 7 Oct 2009 18:53:47 +0000 (20:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 18 Nov 2009 18:34:11 +0000 (19:34 +0100)
configure.ac
error.h
wma_afh.c
wma_common.c

index 4583b1eb3fb5dfb251496bb15f6c70463009ad23..aadaee34f8ee150283bb013c9302fe5a1ce39e1d 100644 (file)
@@ -123,7 +123,7 @@ audiod_errlist_objs="audiod signal string daemon stat net
        client_common ggo udp_recv color fec prebuffer_filter sha1 audiod_command_list
        bitstream mdct wma_common wmadec_filter"
 audiod_ldflags=""
-audiod_audio_formats=""
+audiod_audio_formats="wma"
 
 afh_cmdline_objs="add_cmdline(afh)"
 afh_errlist_objs="afh string fd mp3_afh afh_common time wma_afh wma_common"
@@ -390,7 +390,7 @@ if test "$have_ogg" = "yes"; then
        audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
        afh_errlist_objs="$afh_errlist_objs ogg_afh"
 
-       audiod_audio_formats="ogg"
+       audiod_audio_formats="$audiod_audio_formats ogg"
        server_audio_formats="$server_audio_formats ogg"
        AC_SUBST(oggvorbis_cppflags)
        AC_SUBST(oggvorbis_libs)
diff --git a/error.h b/error.h
index 7553699c534300c907d2989135fe1c8ff5d88cfa..0d2566d7b480e13eba20320561562965d32690c1 100644 (file)
--- a/error.h
+++ b/error.h
@@ -35,10 +35,14 @@ DEFINE_ERRLIST_OBJECT_ENUM;
 #define AFS_COMMAND_LIST_ERRORS
 #define AUDIOD_COMMAND_LIST_ERRORS
 #define WMA_AFH_ERRORS
-#define WMA_COMMON_ERRORS
 
 extern const char **para_errlist[];
 
+#define WMA_COMMON_ERRORS \
+       PARA_ERROR(WMA_NO_GUID, "audio stream guid not found"), \
+       PARA_ERROR(WMA_BAD_ASF_HEADER, "invalid asf header"), \
+
+
 #define WMADEC_FILTER_ERRORS \
        PARA_ERROR(WMA_BAD_PARAMS, "invalid WMA parameters"), \
        PARA_ERROR(WMA_OUTPUT_SPACE, "insufficient output space"), \
index 335ab890b4e129bb9f257f58c4158003770c0b63..2d463900e7be81d148cd3ab6dce554d61ce3044a 100644 (file)
--- a/wma_afh.c
+++ b/wma_afh.c
@@ -191,16 +191,15 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        const uint8_t *f, *start = (uint8_t *)buf;
        int i, j, frames_per_chunk, chunk_time;
        size_t ct_size = 250;
+       int count = 0, num_frames;
+
        afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t));
        afhi->chunk_table[0] = 0;
        afhi->chunk_table[1] = afhi->header_len;
 
-
-       int count = 0, num_frames;
-
        num_frames = count_frames(buf, buf_size, block_align,
                &afhi->chunks_total);
-       PARA_ERROR_LOG("%d frames\n", num_frames);
+       PARA_INFO_LOG("%d frames\n", num_frames);
        afhi->seconds_total = num_frames * 2048 /* FIXME */
                / afhi->frequency;
        frames_per_chunk = num_frames / afhi->chunks_total;
@@ -208,7 +207,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        j = 1;
        FOR_EACH_FRAME(f, start, buf_size, block_align) {
                count += f[WMA_FRAME_SKIP] & 0x0f;
-               while (count > j * frames_per_chunk) {
+               while (count > j * frames_per_chunk && f > start) {
                        j++;
                        if (j >= ct_size) {
                                ct_size *= 2;
@@ -223,7 +222,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        afhi->chunks_total = j;
        chunk_time = num_frames * 1000 / afhi->frequency * 2048
                / afhi->chunks_total;
-       PARA_ERROR_LOG("ct: %d\n", chunk_time);
+       PARA_INFO_LOG("ct: %d\n", chunk_time);
        afhi->chunk_tv.tv_sec = chunk_time / 1000;
        afhi->chunk_tv.tv_usec = (chunk_time % 1000) * 1000;
        //set_chunk_tv(num_frames, j, afhi->frequency, &afhi->chunk_tv);
index 9a7a22acf30bd310f2dd14f8494f93cff5adc070..c4d96ad0f62c396cac54e3fcdabca87974f241d6 100644 (file)
@@ -46,10 +46,8 @@ static int find_audio_stream_info(const char *buf, int len)
        const char pattern[] = {0x40, 0x9e, 0x69, 0xf8};
        const char *p = search_pattern(pattern, sizeof(pattern), buf, len);
 
-       if (!p) {
-               PARA_NOTICE_LOG("audio stream guid not found");
-               return -1;
-       }
+       if (!p)
+               return -E_WMA_NO_GUID;
        PARA_DEBUG_LOG("found audio stream guid@%0zx\n", p - buf);
        return p - buf;
 }
@@ -58,11 +56,9 @@ static int read_header_len(char *buf, int len)
 {
        uint16_t header_len;
 
-       if (len < 18)
-               return -1;
        header_len = read_u16(buf + 16) + 46;
        if (header_len > len)
-               return -2;
+               return -E_WMA_BAD_ASF_HEADER;
        PARA_DEBUG_LOG("header_len: %d\n", header_len);
        return header_len;
 }