mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-28 16:58:57 +08:00
audio tweaks so it still loads on windows w/o sdl2
This commit is contained in:
parent
c89535e328
commit
1b41632991
|
@ -45,6 +45,7 @@ if (WIN32)
|
||||||
endif()
|
endif()
|
||||||
option(BLAH_NO_FUNCTIONAL "Don't use std::function" OFF)
|
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_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
|
# tracks which libraries we need to link, depends on Options above
|
||||||
set(LIBS "")
|
set(LIBS "")
|
||||||
|
@ -109,4 +110,7 @@ endif()
|
||||||
if (BLAH_NO_SHARED_PTR)
|
if (BLAH_NO_SHARED_PTR)
|
||||||
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
||||||
endif()
|
endif()
|
||||||
|
if (BLAH_NO_THREADING)
|
||||||
|
add_compile_definitions(BLAH_NO_THREADING)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ bool App::run(const Config* c)
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
more_on_emscripten = 4;
|
more_on_emscripten = 4;
|
||||||
#endif
|
#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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
#include "blah_audio.h"
|
#include "blah_audio.h"
|
||||||
#include "blah_time.h"
|
#include "blah_time.h"
|
||||||
|
#include "internal/blah_internal.h"
|
||||||
|
|
||||||
#define STB_VORBIS_HEADER_ONLY
|
#define STB_VORBIS_HEADER_ONLY
|
||||||
#include "third_party/stb_vorbis.c"
|
#include "third_party/stb_vorbis.c"
|
||||||
|
|
||||||
#define CUTE_SOUND_IMPLEMENTATION
|
#ifdef BLAH_PLATFORM_SDL2
|
||||||
#define CUTE_SOUND_FORCE_SDL
|
#define CUTE_SOUND_FORCE_SDL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CUTE_SOUND_IMPLEMENTATION
|
||||||
#include "third_party/cute_sound.h"
|
#include "third_party/cute_sound.h"
|
||||||
|
|
||||||
namespace Blah
|
namespace Blah
|
||||||
{
|
{
|
||||||
namespace Internal
|
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) {
|
if (err != CUTE_SOUND_ERROR_NONE) {
|
||||||
Log::error(cs_error_as_string(err));
|
Log::error(cs_error_as_string(err));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef BLAH_NO_THREADING
|
||||||
cs_spawn_mix_thread();
|
cs_spawn_mix_thread();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_shutdown()
|
void audio_shutdown()
|
||||||
|
|
|
@ -21,10 +21,9 @@ namespace Blah
|
||||||
void input_step_bindings();
|
void input_step_bindings();
|
||||||
void input_shutdown();
|
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.
|
// play_frequency_in_Hz depends on your audio file, 44100 seems to be fine.
|
||||||
// buffered_samples is clamped to be at least 1024.
|
// 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_shutdown();
|
||||||
void audio_update();
|
void audio_update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,7 +364,7 @@ bool Win32_Platform::init(const Config& config)
|
||||||
while (*end != 0) end++;
|
while (*end != 0) end++;
|
||||||
|
|
||||||
FilePath result;
|
FilePath result;
|
||||||
result.append_utf16((u16*)path, (u16*)end);
|
result.append((u16*)path, (u16*)end);
|
||||||
|
|
||||||
user_directory = Path::join(Path::normalize(result), config.name) + "/";
|
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()
|
void Win32_Platform::detect_joysticks()
|
||||||
{
|
{
|
||||||
auto platform = ((Win32_Platform*)App::Internal::platform);
|
auto platform = ((Win32_Platform*)Internal::platform);
|
||||||
|
|
||||||
// mark all joysticks as unnacounted for
|
// mark all joysticks as unnacounted for
|
||||||
for (int i = 0; i < Input::max_controllers; i++)
|
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)
|
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;
|
auto input_state = platform->input_state;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user