Navigation Menu

Skip to content

Commit

Permalink
opus support using opusfile library (bug #4200)
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Jun 15, 2018
1 parent 8cf6f39 commit 69cd7f4
Show file tree
Hide file tree
Showing 8 changed files with 715 additions and 19 deletions.
6 changes: 4 additions & 2 deletions SDL_mixer.h
Expand Up @@ -80,7 +80,8 @@ typedef enum
MIX_INIT_MOD = 0x00000002,
MIX_INIT_MP3 = 0x00000008,
MIX_INIT_OGG = 0x00000010,
MIX_INIT_MID = 0x00000020
MIX_INIT_MID = 0x00000020,
MIX_INIT_OPUS = 0x00000040
} MIX_InitFlags;

/* Loads dynamic libraries and prepares them for use. Flags should be
Expand Down Expand Up @@ -134,7 +135,8 @@ typedef enum {
MUS_MP3,
MUS_MP3_MAD_UNUSED,
MUS_FLAC,
MUS_MODPLUG_UNUSED
MUS_MODPLUG_UNUSED,
MUS_OPUS
} Mix_MusicType;

/* The internal format for a music chunk interpreted via mikmod */
Expand Down
254 changes: 239 additions & 15 deletions configure
Expand Up @@ -781,6 +781,8 @@ PLAYWAVE_OBJECTS
VERSION_OBJECTS
OBJECTS
ac_aux_dir
OPUSFILE_LIBS
OPUSFILE_CFLAGS
SMPEG_LIBS
SMPEG_CFLAGS
SMPEG_CONFIG
Expand Down Expand Up @@ -922,6 +924,8 @@ enable_music_mp3_mad_gpl
enable_music_mp3_mad_gpl_dithering
enable_music_mp3_mpg123
enable_music_mp3_mpg123_shared
enable_music_opus
enable_music_opus_shared
'
ac_precious_vars='build_alias
host_alias
Expand All @@ -936,7 +940,9 @@ PKG_CONFIG
SDL_CFLAGS
SDL_LIBS
MODPLUG_CFLAGS
MODPLUG_LIBS'
MODPLUG_LIBS
OPUSFILE_CFLAGS
OPUSFILE_LIBS'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1598,6 +1604,9 @@ Optional Features:
enable MP3 music via libmpg123 [[default=yes]]
--enable-music-mp3-mpg123-shared
dynamically load libmpg123 library [[default=yes]]
--enable-music-opus enable Opus music [[default=yes]]
--enable-music-opus-shared
dynamically load opusfile library [[default=yes]]

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -1627,6 +1636,10 @@ Some influential environment variables:
C compiler flags for MODPLUG, overriding pkg-config
MODPLUG_LIBS
linker flags for MODPLUG, overriding pkg-config
OPUSFILE_CFLAGS
C compiler flags for OPUSFILE, overriding pkg-config
OPUSFILE_LIBS
linker flags for OPUSFILE, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -3930,13 +3943,13 @@ if ${lt_cv_nm_interface+:} false; then :
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:3933: $ac_compile\"" >&5)
(eval echo "\"\$as_me:3946: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
(eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval echo "\"\$as_me:3949: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
(eval echo "\"\$as_me:3939: output\"" >&5)
(eval echo "\"\$as_me:3952: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
Expand Down Expand Up @@ -5147,7 +5160,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 5150 "configure"' > conftest.$ac_ext
echo '#line 5163 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
Expand Down Expand Up @@ -6977,11 +6990,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:6980: $lt_compile\"" >&5)
(eval echo "\"\$as_me:6993: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:6984: \$? = $ac_status" >&5
echo "$as_me:6997: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -7316,11 +7329,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7319: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7332: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7323: \$? = $ac_status" >&5
echo "$as_me:7336: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
Expand Down Expand Up @@ -7421,11 +7434,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7424: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7437: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7428: \$? = $ac_status" >&5
echo "$as_me:7441: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -7476,11 +7489,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7479: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7492: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7483: \$? = $ac_status" >&5
echo "$as_me:7496: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -9845,7 +9858,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 9848 "configure"
#line 9861 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -9941,7 +9954,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 9944 "configure"
#line 9957 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12997,6 +13010,217 @@ else
$as_echo "$as_me: WARNING: MP3 support disabled" >&2;}
fi

# Check whether --enable-music-opus was given.
if test "${enable_music_opus+set}" = set; then :
enableval=$enable_music_opus;
else
enable_music_opus=yes
fi


# Check whether --enable-music-opus-shared was given.
if test "${enable_music_opus_shared+set}" = set; then :
enableval=$enable_music_opus_shared;
else
enable_music_opus_shared=yes
fi

if test x$enable_music_opus = xyes; then

pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPUSFILE" >&5
$as_echo_n "checking for OPUSFILE... " >&6; }

if test -n "$PKG_CONFIG"; then
if test -n "$OPUSFILE_CFLAGS"; then
pkg_cv_OPUSFILE_CFLAGS="$OPUSFILE_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5
($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_OPUSFILE_CFLAGS=`$PKG_CONFIG --cflags "opusfile >= 0.2" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$OPUSFILE_LIBS"; then
pkg_cv_OPUSFILE_LIBS="$OPUSFILE_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5
($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_OPUSFILE_LIBS=`$PKG_CONFIG --libs "opusfile >= 0.2" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "opusfile >= 0.2"`
else
OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "opusfile >= 0.2"`
fi
# Put the nasty error message in config.log where it belongs
echo "$OPUSFILE_PKG_ERRORS" >&5

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
have_opusfile_hdr=yes
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lopusfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char op_open_callbacks ();
int
main ()
{
return op_open_callbacks ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_opusfile_op_open_callbacks=yes
else
ac_cv_lib_opusfile_op_open_callbacks=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
have_opusfile_lib=yes
fi


elif test $pkg_failed = untried; then
ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default"
if test "x$ac_cv_header_opus_opusfile_h" = xyes; then :
have_opusfile_hdr=yes
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5
$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; }
if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lopusfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char op_open_callbacks ();
int
main ()
{
return op_open_callbacks ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_opusfile_op_open_callbacks=yes
else
ac_cv_lib_opusfile_op_open_callbacks=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5
$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; }
if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then :
have_opusfile_lib=yes
fi


else
OPUSFILE_CFLAGS=$pkg_cv_OPUSFILE_CFLAGS
OPUSFILE_LIBS=$pkg_cv_OPUSFILE_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
have_opusfile_hdr=yes
have_opusfile_lib=yes

fi

if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
have_opusfile=yes
case "$host" in
*-*-darwin*)
opusfile_lib=`find_lib libopusfile.dylib`
;;
*-*-cygwin* | *-*-mingw32*)
opusfile_lib=`find_lib "libopusfile*.dll"`
;;
*)
opusfile_lib=`find_lib "libopusfile[0-9]*.so.*"`
if test x$opusfile_lib = x; then
opusfile_lib=`find_lib "libopusfile.so.*"`
fi
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
echo "-- dynamic opusfile -> $opusfile_lib"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&5
$as_echo "$as_me: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&2;}
fi
fi

EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"

OBJECTS=`echo $SOURCES`
Expand Down

0 comments on commit 69cd7f4

Please sign in to comment.