Hi,

On 20 November 2008 14:59, Max Kellermann <[EMAIL PROTECTED]> wrote:
> What did configure say about "broken libfaad headers" on your machine?
> Look what config.log writes.

config.log snippet:
--
configure:9555: checking for broken libfaad headers
configure:9578: gcc -std=gnu99 -c -pthread -g -O2       -Werror
-pthread -g -O2       -Werror conftest.c >&5
cc1: warnings being treated as errors
conftest.c: In function 'main':
conftest.c:10: warning: passing argument 4 of 'NeAACDecInit2' from
incompatible pointer type
configure:9584: $? = 1
configure: failed program was:
|
| #include <faad.h>
| #include <stddef.h>
| #include <stdint.h>
|
| int main() {
|       unsigned char channels;
|       uint32_t sample_rate;
|
|       faacDecInit2(NULL, NULL, 0, &sample_rate, &channels);
|       return 0;
| }
|
configure:9595: result: broken
--
As expected.

And the following line comes up in the configure stdout:
checking for broken libfaad headers... broken

HAVE_FAAD_LONG is defined. So the following lines in the aac plugin
are compiled which triggers the warnings:
259: unsigned long *sample_rate_r = (unsigned long*)&sample_rate;
323: unsigned long *sample_rate_r = (unsigned long*)&sample_rate;

My very simple idea to resolve this situation (not the union-based
one): cast the int32_t pointer argument to void* at the calling like
the attached patch. It compiles without any warnings and runs as well.
What do you think about it? (The patch makes the HAVE_FAAD_LONG define
unneeded.)

Regards,
Kodest
diff --git a/src/decoder/aac_plugin.c b/src/decoder/aac_plugin.c
index d23d43b..68bb9c3 100644
--- a/src/decoder/aac_plugin.c
+++ b/src/decoder/aac_plugin.c
@@ -252,14 +252,6 @@ static float getAacFloatTotalTime(const char *file)
        faacDecHandle decoder;
        faacDecConfigurationPtr config;
        uint32_t sample_rate;
-#ifdef HAVE_FAAD_LONG
-       /* neaacdec.h declares all arguments as "unsigned long", but
-          internally expects uint32_t pointers.  To avoid gcc
-          warnings, use this workaround. */
-       unsigned long *sample_rate_r = (unsigned long*)&sample_rate;
-#else
-       uint32_t *sample_rate_r = &sample_rate;
-#endif
        unsigned char channels;
        struct input_stream inStream;
        long bread;
@@ -279,10 +271,14 @@ static float getAacFloatTotalTime(const char *file)
 
                fillAacBuffer(&b);
 #ifdef HAVE_FAAD_BUFLEN_FUNCS
-               bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
-                                   sample_rate_r, &channels);
+               bread = faacDecInit(
+                       decoder, b.buffer, b.bytesIntoBuffer,
+                       (void *)&sample_rate, &channels
+               );
 #else
-               bread = faacDecInit(decoder, b.buffer, sample_rate_r, 
&channels);
+               bread = faacDecInit(
+                       decoder, b.buffer, (void *)&sample_rate, &channels
+               );
 #endif
                if (bread >= 0 && sample_rate > 0 && channels > 0)
                        length = 0;
@@ -316,14 +312,6 @@ aac_stream_decode(struct decoder *mpd_decoder, struct 
input_stream *inStream)
        faacDecConfigurationPtr config;
        long bread;
        uint32_t sample_rate;
-#ifdef HAVE_FAAD_LONG
-       /* neaacdec.h declares all arguments as "unsigned long", but
-          internally expects uint32_t pointers.  To avoid gcc
-          warnings, use this workaround. */
-       unsigned long *sample_rate_r = (unsigned long*)&sample_rate;
-#else
-       uint32_t *sample_rate_r = &sample_rate;
-#endif
        unsigned char channels;
        unsigned int sampleCount;
        char *sampleBuffer;
@@ -358,10 +346,14 @@ aac_stream_decode(struct decoder *mpd_decoder, struct 
input_stream *inStream)
        }
 
 #ifdef HAVE_FAAD_BUFLEN_FUNCS
-       bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
-                           sample_rate_r, &channels);
+       bread = faacDecInit(
+               decoder, b.buffer, b.bytesIntoBuffer,
+               (void *)&sample_rate, &channels
+       );
 #else
-       bread = faacDecInit(decoder, b.buffer, sample_rate_r, &channels);
+       bread = faacDecInit(
+               decoder, b.buffer, (void *)&sample_rate, &channels
+       );
 #endif
        if (bread < 0) {
                ERROR("Error not a AAC stream.\n");
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to