diff --git a/CMakeLists.txt b/CMakeLists.txt index c76c57d..558ac68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ if (WIN32) endif() option(BLAH_NO_FUNCTIONAL "Don't use std::function" OFF) option(BLAH_NO_SHARED_PTR "Don't use std::shared_ptr for Resources" OFF) +option(BLAH_NO_THREADING "Don't use threading" OFF) # tracks which libraries we need to link, depends on Options above set(LIBS "") @@ -109,4 +110,7 @@ endif() if (BLAH_NO_SHARED_PTR) add_compile_definitions(BLAH_NO_SHARED_PTR) endif() +if (BLAH_NO_THREADING) + add_compile_definitions(BLAH_NO_THREADING) +endif() diff --git a/src/blah_app.cpp b/src/blah_app.cpp index eca1cfd..1458315 100644 --- a/src/blah_app.cpp +++ b/src/blah_app.cpp @@ -122,7 +122,7 @@ bool App::run(const Config* c) #ifdef __EMSCRIPTEN__ more_on_emscripten = 4; #endif - Blah::Internal::audio_is_init = Blah::Internal::audio_init(NULL, c->audio_frequency_in_Hz, 1024 * more_on_emscripten); + Blah::Internal::audio_is_init = Blah::Internal::audio_init(c->audio_frequency_in_Hz, 1024 * more_on_emscripten); } } diff --git a/src/blah_audio.cpp b/src/blah_audio.cpp index 295b32d..c028b34 100644 --- a/src/blah_audio.cpp +++ b/src/blah_audio.cpp @@ -1,27 +1,34 @@ #include "blah_audio.h" #include "blah_time.h" +#include "internal/blah_internal.h" #define STB_VORBIS_HEADER_ONLY #include "third_party/stb_vorbis.c" -#define CUTE_SOUND_IMPLEMENTATION +#ifdef BLAH_PLATFORM_SDL2 #define CUTE_SOUND_FORCE_SDL +#endif + +#define CUTE_SOUND_IMPLEMENTATION #include "third_party/cute_sound.h" namespace Blah { namespace Internal { - bool audio_init(void* os_handle, unsigned play_frequency_in_Hz, int buffered_samples) + bool audio_init(unsigned play_frequency_in_Hz, int buffered_samples) { - cs_error_t err = cs_init(os_handle, play_frequency_in_Hz, buffered_samples, NULL); + cs_error_t err = cs_init(Internal::platform->d3d11_get_hwnd(), play_frequency_in_Hz, buffered_samples, NULL); if (err != CUTE_SOUND_ERROR_NONE) { Log::error(cs_error_as_string(err)); return false; } else { return true; } + +#ifndef BLAH_NO_THREADING cs_spawn_mix_thread(); +#endif } void audio_shutdown() diff --git a/src/internal/blah_internal.h b/src/internal/blah_internal.h index 51cda46..2a0bf70 100644 --- a/src/internal/blah_internal.h +++ b/src/internal/blah_internal.h @@ -21,10 +21,9 @@ namespace Blah void input_step_bindings(); void input_shutdown(); - // Pass in NULL for `os_handle`, except for the DirectSound backend this should be hwnd. // play_frequency_in_Hz depends on your audio file, 44100 seems to be fine. // buffered_samples is clamped to be at least 1024. - bool audio_init(void* os_handle, unsigned play_frequency_in_Hz, int buffered_samples); + bool audio_init(unsigned play_frequency_in_Hz, int buffered_samples); void audio_shutdown(); void audio_update(); } diff --git a/src/internal/blah_platform_win32.cpp b/src/internal/blah_platform_win32.cpp index 2408578..e73e457 100644 --- a/src/internal/blah_platform_win32.cpp +++ b/src/internal/blah_platform_win32.cpp @@ -364,7 +364,7 @@ bool Win32_Platform::init(const Config& config) while (*end != 0) end++; FilePath result; - result.append_utf16((u16*)path, (u16*)end); + result.append((u16*)path, (u16*)end); user_directory = Path::join(Path::normalize(result), config.name) + "/"; } @@ -737,7 +737,7 @@ void Win32_Platform::open_url(const char* url) void Win32_Platform::detect_joysticks() { - auto platform = ((Win32_Platform*)App::Internal::platform); + auto platform = ((Win32_Platform*)Internal::platform); // mark all joysticks as unnacounted for for (int i = 0; i < Input::max_controllers; i++) @@ -806,7 +806,7 @@ void Win32_Platform::detect_joysticks() LRESULT CALLBACK Blah::win32_window_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - auto platform = ((Win32_Platform*)App::Internal::platform); + auto platform = ((Win32_Platform*)Internal::platform); auto input_state = platform->input_state; switch (msg)