fade: cosmetic cleanups
[paraslash.git] / aacdec.c
index 9ed1201..79c437d 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -53,7 +53,7 @@ struct private_aacdec_data {
         * return value of aac_find_esds(). Used to call the right aacdec
         * init function
         */
-       int decoder_length;
+       unsigned long decoder_length;
        /** number of times the decoder returned an error */
        unsigned error_count;
        /** number of bytes already consumed from the imput stream */
@@ -79,9 +79,9 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
        if (!padd->initialized) {
                unsigned long rate = 0;
                unsigned char channels = 0;
-               padd->decoder_length = aac_find_esds(inbuf, len, &skip);
-               PARA_INFO_LOG("decoder len: %d\n", padd->decoder_length);
-               if (padd->decoder_length < 0) {
+               ret = aac_find_esds(inbuf, len, &skip, &padd->decoder_length);
+               if (ret < 0) {
+                       PARA_INFO_LOG("%s\n", PARA_STRERROR(-ret));
                        ret = NeAACDecInit(padd->handle, inbuf,
                                len, &rate, &channels);
                        PARA_INFO_LOG("decoder init: %d\n", ret);
@@ -91,6 +91,8 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                        }
                        consumed = ret;
                } else {
+                       PARA_INFO_LOG("decoder len: %lu\n",
+                               padd->decoder_length);
                        consumed += skip;
                        p = inbuf + consumed;
                        ret = -E_AACDEC_INIT;
@@ -154,8 +156,8 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                goto out;
        for (i = 0; i < padd->frame_info.samples; i++) {
                short *s = (short *)outbuffer;
-               fn->buf[fn->loaded++] = s[i] & 0xff;
-               fn->buf[fn->loaded++] = (s[i] >> 8) & 0xff;
+               write_int16_host_endian(fn->buf + fn->loaded, s[i]);
+               fn->loaded += 2;
        }
 success:
        ret = consumed;