Desktop: the music was played as one SDL_mixer chunk per block, each started when the previous one ended, at frame precision: a gap of up to a frame at each block (measured on the real Freedoom song: 8 gaps, 371 ms of silence in 5 s). - php-sdl-mixer (docker/ext/php-sdl-mixer-stream.patch): a ring buffer fed by PHP (JumPHP_StreamOpen / Push / Buffered / Clear / Volume / Close), read by Mix_HookMusic on SDL's audio thread, mixed with the sound effects by SDL_mixer, silence when empty. Resampling to the device rate in C. - Mix_VolumeMusic does not reach the hook: the stream volume is set by PHP. - PcmStream (desktop): uses the stream when the binding has it, the old chunks otherwise. The browser path is unchanged. - Same functions in the desktop image and in the WebAssembly engine. - Measured in capture (SDL disk driver): 0 gaps, the right frequency, sound effects and music in the same output. Listening test not done yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
47 lines
1.5 KiB
Text
47 lines
1.5 KiB
Text
dnl config.m4 for extension sdl_mixer
|
|
|
|
PHP_ARG_WITH([sdl_mixer],
|
|
[whether to enable sdl_mixer support],
|
|
[AS_HELP_STRING([[--with-sdl_mixer[=DIR]]],
|
|
[Include SDL_mixer support. DIR is the SDL_mixer base include and lib directory])])
|
|
|
|
if test "$PHP_SDL_MIXER" != "no"; then
|
|
SEARCH_PATH="/usr/local /usr"
|
|
SEARCH_FOR="/include/SDL2/SDL_mixer.h"
|
|
AC_MSG_CHECKING([for SDL_mixer files])
|
|
if test -r $PHP_SDL_MIXER/$SEARCH_FOR; then # path given as parameter
|
|
SDL_MIXER_DIR=$PHP_SDL_MIXER
|
|
else # search default path list
|
|
for i in $SEARCH_PATH ; do
|
|
if test -r $i/$SEARCH_FOR; then
|
|
SDL_MIXER_DIR=$i
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if test -z "$SDL_MIXER_DIR"; then
|
|
AC_MSG_RESULT([not found])
|
|
AC_MSG_ERROR([Please reinstall the SDL_mixer distribution])
|
|
fi
|
|
|
|
PHP_ADD_INCLUDE($SDL_MIXER_DIR/include)
|
|
AC_MSG_RESULT(found in $SDL_MIXER_DIR)
|
|
|
|
PKG_CHECK_MODULES([_SDL2], [sdl2 < 3.0])
|
|
PHP_EVAL_INCLINE($_SDL2_CFLAGS)
|
|
|
|
dnl === emscripten ports provide the libraries (-sUSE_SDL_*=2)
|
|
save_LIBS="$LIBS"
|
|
LIBS="$LIBS -L$SDL_MIXER_DIR/$PHP_LIBDIR -lSDL2 -lSDL2_mixer"
|
|
|
|
PHP_SUBST(SDL_MIXER_SHARED_LIBADD)
|
|
AC_DEFINE(HAVE_SDL_MIXER, 1, [ Have sdl_mixer support ])
|
|
|
|
|
|
CFLAGS="$CFLAGS -sUSE_SDL=2"
|
|
CPPFLAGS="$CPPFLAGS -sUSE_SDL=2"
|
|
LDFLAGS="$LDFLAGS -sUSE_SDL=2"
|
|
|
|
PHP_NEW_EXTENSION(sdl_mixer, src/effect_position.c src/effect_stereoreverse.c src/Mix_Music.c src/Mix_Chunk.c src/music.c src/mixer.c src/jumphp_stream.c php_sdl_mixer.c, $ext_shared, -sUSE_SDL=2 -sUSE_SDL_MIXER=2, -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
|
|
PHP_ADD_EXTENSION_DEP(sdl_mixer, sdl)
|
|
fi
|