From 32d01dd21605f024e96f6e9094597e075750935f Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jan 19 2019 09:35:10 +0000 Subject: remove SDL, use synfig::SoundProcessor instead --- diff --git a/autobuild/default-nixpkgs.nix b/autobuild/default-nixpkgs.nix index a53ffb4..9b4c141 100644 --- a/autobuild/default-nixpkgs.nix +++ b/autobuild/default-nixpkgs.nix @@ -68,7 +68,7 @@ stdenv.mkDerivation rec { buildInputs = [ ETL boost cairo fftw glibmm gnome3.defaultIconTheme gtk3 gtkmm3 imagemagick intltool libjack2 libsigcxx libxmlxx makeWrapper mlt - synfig which SDL2 SDL2_mixer + synfig which ]; postInstall = '' diff --git a/autobuild/default.nix b/autobuild/default.nix index 9faeae6..30aba3e 100644 --- a/autobuild/default.nix +++ b/autobuild/default.nix @@ -30,7 +30,7 @@ stdenv.mkDerivation rec { buildInputs = [ boost cairo ffmpeg fftw intltool glibmm gnome3.defaultIconTheme gtk3 gtkmm3 imagemagick intltool libjpeg libjack2 libsigcxx libxmlxx mlt - pango which SDL2 SDL2_mixer + pango which ]; preConfigure = ""; diff --git a/synfig-studio/configure.ac b/synfig-studio/configure.ac index 749e89f..3bf8bf1 100755 --- a/synfig-studio/configure.ac +++ b/synfig-studio/configure.ac @@ -95,26 +95,6 @@ esac # -- L I B R A R I E S ---------------------------------------- -#AC_INIT -#m4_include([m4/sdl.m4]) -m4_include([m4/sdl2.m4]) -AC_CONFIG_MACRO_DIR([m4]) - -dnl Check for SDL -#SDL_VERSION=1.2.0 -#AM_PATH_SDL($SDL_VERSION,:,AC_MSG_ERROR([*** SDL version $SDL_VERSION not found! ***])) -#SDL_CFLAGS=$(sdl-config --cflags) -#SDL_LIBS=$(sdl-config --libs) - -SDL_VERSION=2.0 -AM_PATH_SDL2($SDL_VERSION,:,AC_MSG_ERROR([*** SDL version $SDL_VERSION not found! ***])) - -SDL_CFLAGS=$(sdl2-config --cflags) -SDL_LIBS=$(sdl2-config --libs) - -CFLAGS="$CFLAGS $SDL_CFLAGS" -LIBS="$LIBS $SDL_LIBS -lSDL2_mixer" - # Gtk compatibility hacks: # Since 3.14 some our hacks for GUI decorations works in other way # Since 3.14 for checkboxes STATE_FLAG_ACTIVE replaced with STATE_FLAG_CHECKED @@ -249,8 +229,6 @@ Build images ---------------------> $with_images "'$'"CXX ------------------------------> '$CXX' "'$'"CXXFLAGS -------------------------> '$CXXFLAGS' "'$'"LDFLAGS --------------------------> '$LDFLAGS' -"'$'"SDL_CFLAGS -----------------------> '$SDL_CFLAGS' -"'$'"SDL_LIBS -------------------------> '$SDL_LIBS' "'$'"SYNFIG_CFLAGS --------------------> '$SYNFIG_CFLAGS' "'$'"SYNFIG_LIBS ----------------------> '$SYNFIG_LIBS' "'$'"GTKMM_CFLAGS ---------------------> '$GTKMM_CFLAGS' diff --git a/synfig-studio/m4/sdl2.m4 b/synfig-studio/m4/sdl2.m4 deleted file mode 100644 index b915f99..0000000 --- a/synfig-studio/m4/sdl2.m4 +++ /dev/null @@ -1,234 +0,0 @@ -# Configure paths for SDL -# Sam Lantinga 9/21/99 -# stolen from Manish Singh -# stolen back from Frank Belew -# stolen from Manish Singh -# Shamelessly stolen from Owen Taylor -# -# Changelog: -# * also look for SDL2.framework under Mac OS X - -# serial 1 - -dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS -dnl -AC_DEFUN([AM_PATH_SDL2], -[dnl -dnl Get the cflags and libraries from the sdl2-config script -dnl -AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], - sdl_prefix="$withval", sdl_prefix="") -AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], - sdl_exec_prefix="$withval", sdl_exec_prefix="") -AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], - , enable_sdltest=yes) -AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL2.framework], - , search_sdl_framework=yes) - -AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) - - min_sdl_version=ifelse([$1], ,2.0.0,$1) - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], - [sdl_pc=yes], - [sdl_pc=no]) - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL2_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) - PATH="$as_save_PATH" - no_sdl="" - - if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then - AC_MSG_CHECKING(for SDL2.framework) - if test "x$SDL2_FRAMEWORK" != x; then - sdl_framework=$SDL2_FRAMEWORK - else - for d in / ~/ /System/; do - if test -d "$dLibrary/Frameworks/SDL2.framework"; then - sdl_framework="$dLibrary/Frameworks/SDL2.framework" - fi - done - fi - - if test -d $sdl_framework; then - AC_MSG_RESULT($sdl_framework) - sdl_framework_dir=`dirname $sdl_framework` - SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" - SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2" - else - no_sdl=yes - fi - fi - - if test "$SDL2_CONFIG" != "no"; then - if test "x$sdl_pc" = "xno"; then - AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) - SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` - SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` - fi - - sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x$enable_sdltest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" -dnl -dnl Now check if the installed SDL is sufficiently new. (Also sanity -dnl checks the results of sdl2-config to some extent -dnl - rm -f conf.sdltest - AC_TRY_RUN([ -#include -#include -#include -#include "SDL.h" - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main (int argc, char *argv[]) -{ - int major, minor, micro; - char *tmp_version; - - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_sdl_version"); - exit(1); - } - - if (($sdl_major_version > major) || - (($sdl_major_version == major) && ($sdl_minor_version > minor)) || - (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - - fi - if test "x$sdl_pc" = "xno"; then - if test "x$no_sdl" = "xyes"; then - AC_MSG_RESULT(no) - else - AC_MSG_RESULT(yes) - fi - fi - fi - fi - if test "x$no_sdl" = x ; then - ifelse([$2], , :, [$2]) - else - if test "$SDL2_CONFIG" = "no" ; then - echo "*** The sdl2-config script installed by SDL could not be found" - echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL2_CONFIG environment variable to the" - echo "*** full path to sdl2-config." - else - if test -f conf.sdltest ; then - : - else - echo "*** Could not run SDL test program, checking why..." - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ -#include -#include "SDL.h" - -int main(int argc, char *argv[]) -{ return 0; } -#undef main -#define main K_and_R_C_main -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding SDL or finding the wrong" - echo "*** version of SDL. If it is not finding SDL, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means SDL was incorrectly installed" - echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - SDL_CFLAGS="" - SDL_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(SDL_CFLAGS) - AC_SUBST(SDL_LIBS) - rm -f conf.sdltest -]) diff --git a/synfig-studio/sounds/Makefile.am b/synfig-studio/sounds/Makefile.am index 243a550..a85f5bf 100644 --- a/synfig-studio/sounds/Makefile.am +++ b/synfig-studio/sounds/Makefile.am @@ -5,5 +5,4 @@ MAINTAINERCLEANFILES = Makefile.in SOUNDS = readme.txt \ renderdone.wav -#sounddir = ${datadir}/synfig/sounds sound_DATA = $(SOUNDS) diff --git a/synfig-studio/src/CMakeLists.txt b/synfig-studio/src/CMakeLists.txt index 4a39268..4e680aa 100644 --- a/synfig-studio/src/CMakeLists.txt +++ b/synfig-studio/src/CMakeLists.txt @@ -19,8 +19,6 @@ include(FindPkgConfig) pkg_check_modules(SIGCPP REQUIRED sigc++-2.0) pkg_check_modules(GTKMM REQUIRED gtkmm-3.0) pkg_check_modules(LIBXML REQUIRED libxml++-2.6) -pkg_check_modules(SDL2 REQUIRED sdl2) -pkg_check_modules(SDL2MIXER REQUIRED SDL2_mixer) ## ## Config diff --git a/synfig-studio/src/gui/CMakeLists.txt b/synfig-studio/src/gui/CMakeLists.txt index 634ca13..a0a9e6a 100644 --- a/synfig-studio/src/gui/CMakeLists.txt +++ b/synfig-studio/src/gui/CMakeLists.txt @@ -68,8 +68,6 @@ include(workarearenderer/CMakeLists.txt) target_link_libraries(synfigstudio ${GTKMM_LIBRARIES} ${Gettext_LIBRARIES} - ${SDL2_LIBRARIES} - ${SDL2MIXER_LIBRARIES} synfig synfigapp ) diff --git a/synfig-studio/src/gui/Makefile.am b/synfig-studio/src/gui/Makefile.am index 55f4f98..7dc635c 100644 --- a/synfig-studio/src/gui/Makefile.am +++ b/synfig-studio/src/gui/Makefile.am @@ -112,8 +112,7 @@ synfigstudio_LDADD = \ ../synfigapp/libsynfigapp.la \ @SYNFIG_LIBS@ \ @GTKMM_LIBS@ \ - @JACK_LIBS@ \ - @SDL_LIBS@ + @JACK_LIBS@ synfigstudio_LDFLAGS = \ -dlopen self @@ -122,7 +121,6 @@ synfigstudio_CXXFLAGS = \ @SYNFIG_CFLAGS@ \ @GTKMM_CFLAGS@ \ @JACK_CFLAGS@ \ - @SDL_CFLAGS@ \ -DIMAGE_DIR=\"$(imagedir)\" \ -DIMAGE_EXT=\"$(imageext)\" \ -DPLUGIN_DIR=\"$(plugindir)\" \ diff --git a/synfig-studio/src/gui/app.cpp b/synfig-studio/src/gui/app.cpp index 9b3f8ec..caf9907 100644 --- a/synfig-studio/src/gui/app.cpp +++ b/synfig-studio/src/gui/app.cpp @@ -84,6 +84,7 @@ #include #include #include +#include #include "app.h" #include "splash.h" @@ -153,9 +154,6 @@ #include -#include -#include - #endif /* === U S I N G =========================================================== */ @@ -358,8 +356,8 @@ delete_widget(Gtk::Widget *widget) } //Static members need to be initialized outside of class declaration -Mix_Chunk* App::gRenderDone = NULL; -bool App::use_render_done_sound = true; +SoundProcessor *App::sound_render_done = NULL; +bool App::use_render_done_sound = true; }; // END of namespace studio studio::StateManager* state_manager; @@ -1451,24 +1449,42 @@ App::App(const synfig::String& basepath, int *argc, char ***argv): Glib::setenv ("LANGUAGE", App::ui_language.c_str(), 1); } - std::string path_to_icons; + // paths #ifdef _WIN32 - path_to_icons=basepath+ETL_DIRECTORY_SEPARATOR+".."+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR; + String path_to_icons = get_base_path() + + ETL_DIRECTORY_SEPARATOR + ".." + + ETL_DIRECTORY_SEPARATOR + IMAGE_DIR; + String path_to_plugins = get_base_path() + + ETL_DIRECTORY_SEPARATOR + PLUGIN_DIR; + String path_to_sounds = get_base_path() + + ETL_DIRECTORY_SEPARATOR + ".." + + ETL_DIRECTORY_SEPARATOR + SOUND_DIR; #else - path_to_icons=IMAGE_DIR; + String path_to_icons = IMAGE_DIR; + String path_to_plugins = PLUGIN_DIR; + String path_to_sounds = SOUND_DIR; #endif - char* synfig_root=getenv("SYNFIG_ROOT"); - if(synfig_root) { - path_to_icons=synfig_root; - path_to_icons+=ETL_DIRECTORY_SEPARATOR; - path_to_icons+="share"; - path_to_icons+=ETL_DIRECTORY_SEPARATOR; - path_to_icons+="pixmaps"; - path_to_icons+=ETL_DIRECTORY_SEPARATOR; - path_to_icons+="synfigstudio"; + + if (char* synfig_root = getenv("SYNFIG_ROOT")) { + path_to_icons = String(synfig_root) + + ETL_DIRECTORY_SEPARATOR + "share" + + ETL_DIRECTORY_SEPARATOR + "pixmaps" + + ETL_DIRECTORY_SEPARATOR + "synfigstudio"; + path_to_plugins = String(synfig_root) + + ETL_DIRECTORY_SEPARATOR + "share" + + ETL_DIRECTORY_SEPARATOR + "synfig" + + ETL_DIRECTORY_SEPARATOR + "plugins"; + path_to_sounds = String(synfig_root) + + ETL_DIRECTORY_SEPARATOR + "share" + + ETL_DIRECTORY_SEPARATOR + "synfig" + + ETL_DIRECTORY_SEPARATOR + "sounds"; } - path_to_icons+=ETL_DIRECTORY_SEPARATOR; - init_icons(path_to_icons); + + String path_to_user_plugins = synfigapp::Main::get_user_app_directory() + + ETL_DIRECTORY_SEPARATOR + "plugins"; + + // icons + init_icons(path_to_icons + ETL_DIRECTORY_SEPARATOR); ui_interface_=new GlobalUIInterface(); @@ -1556,27 +1572,8 @@ App::App(const synfig::String& basepath, int *argc, char ***argv): load_settings("pref.preview_background_color"); studio_init_cb.task(_("Loading Plugins...")); - - std::string pluginsprefix; - - // system plugins path -#ifdef _WIN32 - pluginsprefix=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+PLUGIN_DIR; -#else - pluginsprefix=PLUGIN_DIR; -#endif - char* synfig_root=getenv("SYNFIG_ROOT"); - if(synfig_root) { - pluginsprefix=std::string(synfig_root) - +ETL_DIRECTORY_SEPARATOR+"share" - +ETL_DIRECTORY_SEPARATOR+"synfig" - +ETL_DIRECTORY_SEPARATOR+"plugins"; - } - plugin_manager.load_dir(pluginsprefix); - - // user plugins path - pluginsprefix=Glib::build_filename(synfigapp::Main::get_user_app_directory(),"plugins"); - plugin_manager.load_dir(pluginsprefix); + plugin_manager.load_dir(path_to_plugins); + plugin_manager.load_dir(path_to_user_plugins); studio_init_cb.task(_("Init UI Manager...")); App::ui_manager_=studio::UIManager::create(); @@ -1840,49 +1837,13 @@ App::App(const synfig::String& basepath, int *argc, char ***argv): get_ui_interface()->error(_("Unknown exception caught when constructing App.\nThis software may be unstable.")); } - // + // Load sound effects + sound_render_done = new SoundProcessor(); + sound_render_done->addSound( + SoundProcessor::PlayOptions(), + SoundProcessor::Sound(path_to_sounds + ETL_DIRECTORY_SEPARATOR + "renderdone.wav") ); App::dock_info_ = dock_info; - } StateManager* App::get_state_manager() { return state_manager; } @@ -1925,15 +1886,8 @@ App::~App() instance_list.clear(); - // + if (sound_render_done) delete sound_render_done; + sound_render_done = NULL; } synfig::String diff --git a/synfig-studio/src/gui/app.h b/synfig-studio/src/gui/app.h index cb80d36..96a39ed 100644 --- a/synfig-studio/src/gui/app.h +++ b/synfig-studio/src/gui/app.h @@ -51,9 +51,6 @@ #include "iconcontroller.h" #include "mainwindow.h" -#include -#include - /* === M A C R O S ========================================================= */ #define MISC_DIR_PREFERENCE "misc_dir" @@ -77,6 +74,11 @@ namespace Gtk class ActionGroup; }; +namespace synfig +{ + class SoundProcessor; +}; + namespace synfigapp { class UIInterface; @@ -245,8 +247,8 @@ public: static synfig::Color preview_background_color; //The sound effects that will be used - static Mix_Chunk* gRenderDone; - static bool use_render_done_sound; + static synfig::SoundProcessor* sound_render_done; + static bool use_render_done_sound; static Dock_Info* dock_info_; //For Render ProgressBar diff --git a/synfig-studio/src/gui/render.cpp b/synfig-studio/src/gui/render.cpp index e30e468..e0efe16 100644 --- a/synfig-studio/src/gui/render.cpp +++ b/synfig-studio/src/gui/render.cpp @@ -30,29 +30,30 @@ # include #endif -#include +#include + +#include -#include "render.h" -#include "app.h" #include #include -#include + +#include + +#include #include #include +#include + +#include "app.h" #include "asyncrenderer.h" +#include "docks/dockmanager.h" +#include "docks/dock_info.h" #include "dialogs/dialog_ffmpegparam.h" #include "dialogs/dialog_spritesheetparam.h" -#include - -#include -#include - -#include -#include +#include "render.h" -#include "docks/dockmanager.h" -#include "docks/dock_info.h" +#include #endif @@ -446,9 +447,11 @@ RenderSettings::on_finished() submit_next_render_pass(); - if (really_finished) { //Because of multi-pass render - //Sound effect - RenderDone (-1 : play on first free channel, 0 : no repeat) - if (App::use_render_done_sound) Mix_PlayChannel( -1, App::gRenderDone, 0 ); + if (really_finished) { // Because of multi-pass render + if (App::use_render_done_sound && App::sound_render_done) { + App::sound_render_done->set_position(Time()); + App::sound_render_done->set_playing(true); + } App::dock_info_->set_render_progress(1.0); } }