aac: detect whether to pass "uint32_t*" to NeAACDecInit2()
neaacdec.h declares all arguments as "unsigned long", but internally expects uint32_t pointers. This triggers gcc warnings on 64 bit architectures. To avoid that, make configure.ac detect whether we're using Debian's corrected headers or the original libfaad headers. In any case, pass a pointer to an uint32_t, conditionally casted to "unsigned long*".
This commit is contained in:
parent
acfba02310
commit
9c4e97a61b
31
configure.ac
31
configure.ac
@ -622,6 +622,37 @@ fi
|
|||||||
|
|
||||||
AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)
|
AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)
|
||||||
|
|
||||||
|
if test x$enable_aac = xyes; then
|
||||||
|
oldcflags=$CFLAGS
|
||||||
|
oldlibs=$LIBS
|
||||||
|
oldcppflags=$CPPFLAGS
|
||||||
|
CFLAGS="$CFLAGS $MPD_CFLAGS $FAAD_CFLAGS -Werror"
|
||||||
|
LIBS="$LIBS $MPD_LIBS $FAAD_LIBS"
|
||||||
|
CPPFLAGS=$CFLAGS
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for broken libfaad headers)
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[AC_MSG_RESULT(correct)],
|
||||||
|
[AC_MSG_RESULT(broken);
|
||||||
|
AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])
|
||||||
|
|
||||||
|
CFLAGS=$oldcflags
|
||||||
|
LIBS=$oldlibs
|
||||||
|
CPPFLAGS=$oldcppflags
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$enable_aac = xyes; then
|
if test x$enable_aac = xyes; then
|
||||||
enable_mp4=yes
|
enable_mp4=yes
|
||||||
MP4FF_LIBS="-lmp4ff"
|
MP4FF_LIBS="-lmp4ff"
|
||||||
|
@ -251,7 +251,15 @@ static float getAacFloatTotalTime(const char *file)
|
|||||||
float length;
|
float length;
|
||||||
faacDecHandle decoder;
|
faacDecHandle decoder;
|
||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
unsigned long sample_rate;
|
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 char channels;
|
||||||
struct input_stream inStream;
|
struct input_stream inStream;
|
||||||
long bread;
|
long bread;
|
||||||
@ -272,9 +280,9 @@ static float getAacFloatTotalTime(const char *file)
|
|||||||
fillAacBuffer(&b);
|
fillAacBuffer(&b);
|
||||||
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
||||||
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
||||||
&sample_rate, &channels);
|
sample_rate_r, &channels);
|
||||||
#else
|
#else
|
||||||
bread = faacDecInit(decoder, b.buffer, &sample_rate, &channels);
|
bread = faacDecInit(decoder, b.buffer, sample_rate_r, &channels);
|
||||||
#endif
|
#endif
|
||||||
if (bread >= 0 && sample_rate > 0 && channels > 0)
|
if (bread >= 0 && sample_rate > 0 && channels > 0)
|
||||||
length = 0;
|
length = 0;
|
||||||
@ -307,7 +315,15 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
faacDecFrameInfo frameInfo;
|
faacDecFrameInfo frameInfo;
|
||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
long bread;
|
long bread;
|
||||||
unsigned long sample_rate;
|
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 char channels;
|
||||||
unsigned int sampleCount;
|
unsigned int sampleCount;
|
||||||
char *sampleBuffer;
|
char *sampleBuffer;
|
||||||
@ -343,9 +359,9 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
|
|||||||
|
|
||||||
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
#ifdef HAVE_FAAD_BUFLEN_FUNCS
|
||||||
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
bread = faacDecInit(decoder, b.buffer, b.bytesIntoBuffer,
|
||||||
&sample_rate, &channels);
|
sample_rate_r, &channels);
|
||||||
#else
|
#else
|
||||||
bread = faacDecInit(decoder, b.buffer, &sample_rate, &channels);
|
bread = faacDecInit(decoder, b.buffer, sample_rate_r, &channels);
|
||||||
#endif
|
#endif
|
||||||
if (bread < 0) {
|
if (bread < 0) {
|
||||||
ERROR("Error not a AAC stream.\n");
|
ERROR("Error not a AAC stream.\n");
|
||||||
|
@ -112,6 +112,14 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
unsigned char *mp4_buffer;
|
unsigned char *mp4_buffer;
|
||||||
unsigned int mp4_buffer_size;
|
unsigned int mp4_buffer_size;
|
||||||
uint32_t sample_rate;
|
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 char channels;
|
||||||
long sample_id;
|
long sample_id;
|
||||||
long num_samples;
|
long num_samples;
|
||||||
@ -160,7 +168,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
mp4ff_get_decoder_config(mp4fh, track, &mp4_buffer, &mp4_buffer_size);
|
mp4ff_get_decoder_config(mp4fh, track, &mp4_buffer, &mp4_buffer_size);
|
||||||
|
|
||||||
if (faacDecInit2(decoder, mp4_buffer, mp4_buffer_size,
|
if (faacDecInit2(decoder, mp4_buffer, mp4_buffer_size,
|
||||||
&sample_rate, &channels) < 0) {
|
sample_rate_r, &channels) < 0) {
|
||||||
g_warning("Not an AAC stream.\n");
|
g_warning("Not an AAC stream.\n");
|
||||||
faacDecClose(decoder);
|
faacDecClose(decoder);
|
||||||
mp4ff_close(mp4fh);
|
mp4ff_close(mp4fh);
|
||||||
|
Loading…
Reference in New Issue
Block a user