mirror of
				https://github.com/NoelFB/blah.git
				synced 2025-11-04 01:41:34 +08:00 
			
		
		
		
	audio tweaks so it still loads on windows w/o sdl2
This commit is contained in:
		@ -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);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user