diff --git a/source/Makefile.deps.mk b/source/Makefile.deps.mk index d576229a1..655b9a046 100644 --- a/source/Makefile.deps.mk +++ b/source/Makefile.deps.mk @@ -394,7 +394,11 @@ QT5_FLAGS = $(shell $(PKG_CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets) QT5_LIBS = $(shell $(PKG_CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets) endif -ifeq ($(HAVE_SDL2),true) +ifeq ($(WASM),true) +HAVE_SDL = true +SDL_FLAGS = -sUSE_SDL=2 +SDL_LIBS = -sUSE_SDL=2 +else ifeq ($(HAVE_SDL2),true) HAVE_SDL = true SDL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sdl2) SDL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sdl2) diff --git a/source/backend/engine/CarlaEngineSDL.cpp b/source/backend/engine/CarlaEngineSDL.cpp index 0925491cf..a9bd638fd 100644 --- a/source/backend/engine/CarlaEngineSDL.cpp +++ b/source/backend/engine/CarlaEngineSDL.cpp @@ -21,16 +21,12 @@ #include "CarlaStringList.hpp" #include "CarlaBackendUtils.hpp" -#include "SDL.h" +#include #ifndef HAVE_SDL2 typedef Uint32 SDL_AudioDeviceID; #endif -#if defined(HAVE_SDL2) && !defined(CARLA_OS_WASM) -# define HAVE_SDL2_CALLS -#endif - CARLA_BACKEND_START_NAMESPACE // ------------------------------------------------------------------------------------------------------------------- @@ -52,12 +48,12 @@ static void initAudioDevicesIfNeeded() #ifdef HAVE_SDL2 SDL_InitSubSystem(SDL_INIT_AUDIO); -# ifdef HAVE_SDL2_CALLS const int numDevices = SDL_GetNumAudioDevices(0); for (int i=0; ioptions.audioDevice != nullptr && pData->options.audioDevice[0] != '\0' ? pData->options.audioDevice : nullptr; @@ -136,7 +136,7 @@ public: if (received.channels == 0) { -#ifdef HAVE_SDL2_CALLS +#ifdef HAVE_SDL2 SDL_CloseAudioDevice(fDeviceId); #else SDL_CloseAudio(); @@ -164,12 +164,14 @@ public: pData->graph.create(0, fAudioOutCount, 0, 0); -#ifdef HAVE_SDL2_CALLS +#ifdef HAVE_SDL2 SDL_PauseAudioDevice(fDeviceId, 0); #else SDL_PauseAudio(0); #endif - carla_stdout("open fAudioOutCount %d %d %d", fAudioOutCount, received.samples, received.freq); + carla_stdout("open fAudioOutCount %d %d %d | %d vs %d", + fAudioOutCount, received.samples, received.freq, + received.format, requested.format); patchbayRefresh(true, false, false); @@ -195,7 +197,7 @@ public: if (fDeviceId != 0) { // SDL_PauseAudioDevice(fDeviceId, 1); -#ifdef HAVE_SDL2_CALLS +#ifdef HAVE_SDL2 SDL_CloseAudioDevice(fDeviceId); #else SDL_CloseAudio(); diff --git a/source/tests/Makefile b/source/tests/Makefile index af01535e2..616bc722b 100644 --- a/source/tests/Makefile +++ b/source/tests/Makefile @@ -146,7 +146,7 @@ carla-engine-sdl$(APP_EXT): $(OBJDIR)/carla-engine-sdl.c.o $(MODULEDIR)/water.a \ $(MODULEDIR)/ysfx.a \ $(MODULEDIR)/zita-resampler.a \ - -lSDL --preload-file foolme.mp3 -sALLOW_MEMORY_GROWTH \ + $(SDL_LIBS) --preload-file foolme.mp3 -sALLOW_MEMORY_GROWTH \ -o $@ # --------------------------------------------------------------------------------------------------------------------- diff --git a/source/tests/carla-engine-sdl.c b/source/tests/carla-engine-sdl.c index ad69227d5..27fa6dc8c 100644 --- a/source/tests/carla-engine-sdl.c +++ b/source/tests/carla-engine-sdl.c @@ -26,10 +26,12 @@ static void engine_idle_loop(void* const arg) { const CarlaHostHandle handle = arg; + carla_engine_idle(handle); + + /* static int counter = 0; if (++counter == 100) { - carla_engine_idle(handle); counter = 0; const uint64_t frame = carla_get_current_transport_frame(handle); printf("engine_idle_loop | play frame %llu | audio peaks %f %f\n", @@ -37,6 +39,7 @@ static void engine_idle_loop(void* const arg) carla_get_output_peak_value(handle, 0, true), carla_get_output_peak_value(handle, 0, false)); } + */ } int main(void) @@ -70,18 +73,26 @@ int main(void) if (!engine_init) return 1; - const bool plugin_added = carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_INTERNAL, NULL, "Music", "audiofile", 0, NULL, PLUGIN_OPTIONS_NULL); + const bool plugin_added = carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_INTERNAL, NULL, "Music", "audiofile", 0, NULL, 0x0); printf("carla_add_plugin: %d\n", plugin_added); if (!plugin_added) goto close; + const bool plugin_added2 = carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_INTERNAL, NULL, "Gain", "audiogain_s", 0, NULL, 0x0); + printf("carla_add_plugin2: %d\n", plugin_added2); + + if (!plugin_added2) + goto close; + const uint32_t current_plugins_count = carla_get_current_plugin_count(handle); printf("carla_get_current_plugin_count: %u\n", current_plugins_count); - if (current_plugins_count != 1) + if (current_plugins_count != 2) goto close; + carla_set_parameter_value(handle, 1, 0, 1.0f); // gain + carla_patchbay_connect(handle, false, 1, 3, 3, 1); carla_patchbay_connect(handle, false, 1, 4, 3, 2);