diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a214d6..3a778a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ project(gstprojectm VERSION 0.0.1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -find_package(projectM4 REQUIRED) +find_package(projectM4 REQUIRED COMPONENTS Playlist) find_package(GStreamer REQUIRED COMPONENTS gstreamer-audio gstreamer-gl gstreamer-pbutils gstreamer-video) find_package(GLIB2 REQUIRED) @@ -61,6 +61,7 @@ endif() target_link_libraries(gstprojectm PRIVATE libprojectM::projectM + libprojectM::playlist PUBLIC ${GSTREAMER_LIBRARIES} ${GSTREAMER_BASE_LIBRARIES} diff --git a/src/config.h b/src/config.h index 6d736d7..c3d7d77 100644 --- a/src/config.h +++ b/src/config.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS #define DEFAULT_MESH_SIZE "48,32" #define DEFAULT_ASPECT_CORRECTION TRUE #define DEFAULT_EASTER_EGG 0.0 -#define DEFAULT_PRESET_LOCKED TRUE +#define DEFAULT_PRESET_LOCKED FALSE G_END_DECLS diff --git a/src/projectm.c b/src/projectm.c index b86a7fe..b3391e6 100644 --- a/src/projectm.c +++ b/src/projectm.c @@ -5,6 +5,7 @@ #include #include +#include #include "projectm.h" #include "plugin.h" @@ -15,6 +16,7 @@ GST_DEBUG_CATEGORY_STATIC(projectm_debug); projectm_handle projectm_init(GstProjectM *plugin) { projectm_handle handle = NULL; + projectm_playlist_handle playlist = NULL; GST_DEBUG_CATEGORY_INIT(projectm_debug, "projectm", 0, "ProjectM"); @@ -34,6 +36,11 @@ projectm_handle projectm_init(GstProjectM *plugin) GST_DEBUG_OBJECT(plugin, "Created projectM instance!"); } + // initialize preset playlist + playlist = projectm_playlist_create(handle); + projectm_playlist_set_shuffle(playlist, true); + // projectm_playlist_set_preset_switched_event_callback(_playlist, &ProjectMWrapper::PresetSwitchedEvent, static_cast(this)); + // Log properties GST_INFO_OBJECT(plugin, "Using Properties: " "preset=%s, " @@ -63,8 +70,10 @@ projectm_handle projectm_init(GstProjectM *plugin) plugin->preset_locked); // Load preset file if path is provided - if (plugin->preset_path != NULL) - projectm_load_preset_file(handle, plugin->preset_path, false); + if (plugin->preset_path != NULL) { + int added_count = projectm_playlist_add_path(playlist, plugin->preset_path, true, false); + GST_INFO("Loaded preset path: %s, presets found: %d", plugin->preset_path, added_count); + } // Set texture search path if directory path is provided if (plugin->texture_dir_path != NULL) @@ -84,6 +93,10 @@ projectm_handle projectm_init(GstProjectM *plugin) if (plugin->preset_duration > 0.0) { projectm_set_preset_duration(handle, plugin->preset_duration); + + // kick off the first preset + if (projectm_playlist_size(playlist) > 0 && ! plugin->preset_locked) + projectm_playlist_play_next(playlist, true); } else {