aft: Avoid invalid read.
[paraslash.git] / spx_afh.c
index b780635b383e8f95dd6f6df9f69cc09ce2c34d16..caeacb1921341b04b26f117d5de6607a80ab95e9 100644 (file)
--- a/spx_afh.c
+++ b/spx_afh.c
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2010 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2010 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 /* This file is based on speexdec.c, by Jean-Marc Valin, see below. */
 
@@ -88,7 +84,7 @@ static int spx_get_comments(unsigned char *comments, int length,
        if (c + 4 > end)
                return -E_SPX_COMMENT;
        nb_fields = read_u32(c);
-       PARA_DEBUG_LOG("%d comment(s)\n", nb_fields);
+       PARA_DEBUG_LOG("%u comment(s)\n", nb_fields);
        c += 4;
        for (i = 0; i < nb_fields; i++, c += len) {
                char *tag;
@@ -152,13 +148,13 @@ static int spx_get_file_info(char *map, size_t numbytes, __a_unused int fd,
                struct afh_info *afhi)
 {
        struct private_spx_data psd;
-       struct ogg_afh_callback_info spx_callback_info = {
+       struct oac_callback_info spx_callback_info = {
                .packet_callback = spx_packet_callback,
                .private_data = &psd,
        };
 
        memset(&psd, 0, sizeof(psd));
-       return ogg_get_file_info(map, numbytes, afhi, &spx_callback_info);
+       return oac_get_file_info(map, numbytes, afhi, &spx_callback_info);
 }
 
 static size_t spx_make_meta_packet(struct taginfo *tags, char **result)
@@ -244,7 +240,7 @@ static int spx_rewrite_tags(const char *map, size_t mapsize,
        int ret;
 
        meta_sz = spx_make_meta_packet(tags, &meta_packet);
-       ret = ogg_rewrite_tags(map, mapsize, output_fd, meta_packet, meta_sz);
+       ret = oac_rewrite_tags(map, mapsize, output_fd, meta_packet, meta_sz);
        free(meta_packet);
        return ret;
 }
@@ -252,13 +248,14 @@ static int spx_rewrite_tags(const char *map, size_t mapsize,
 static const char * const speex_suffixes[] = {"spx", "speex", NULL};
 
 /**
- * The init function of the ogg/speex audio format handler.
+ * The ogg/speex audio format handler.
  *
- * \param afh Pointer to the struct to initialize.
+ * This codec is considered obsolete because the opus codec surpasses its
+ * performance in all areas. It is only compiled in if both the ogg and the
+ * speex library are installed.
  */
-void spx_afh_init(struct audio_format_handler *afh)
-{
-       afh->get_file_info = spx_get_file_info,
-       afh->suffixes = speex_suffixes;
-       afh->rewrite_tags = spx_rewrite_tags;
-}
+const struct audio_format_handler spx_afh = {
+       .get_file_info = spx_get_file_info,
+       .suffixes = speex_suffixes,
+       .rewrite_tags = spx_rewrite_tags,
+};