found and fixed the annoying threading memory bug
This commit is contained in:
parent
ec704e9814
commit
ad099d79b5
@ -1,4 +1,21 @@
|
|||||||
|
AUDIO_THREAD_TEMP_STORAGE_SIZE :: 4096;
|
||||||
|
audio_thread_temp_storage : Temporary_Storage;
|
||||||
|
audio_thread_temp_storage_data : [AUDIO_THREAD_TEMP_STORAGE_SIZE] u8 #align 64;
|
||||||
|
audio_thread_context_ready : bool = false;
|
||||||
|
audio_thread_context : #Context;
|
||||||
|
|
||||||
|
audio_init_thread_context :: () {
|
||||||
|
audio_thread_context = default_context;
|
||||||
|
audio_thread_context.temporary_storage = *audio_thread_temp_storage;
|
||||||
|
audio_thread_temp_storage.data = audio_thread_temp_storage_data.data;
|
||||||
|
audio_thread_temp_storage.size = audio_thread_temp_storage_data.count;
|
||||||
|
audio_thread_temp_storage.original_data = audio_thread_temp_storage_data.data;
|
||||||
|
audio_thread_temp_storage.original_size = audio_thread_temp_storage_data.count;
|
||||||
|
audio_thread_context_ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
sokol_audio_callback :: (buffer: *float, num_frames: s32, num_channels: s32) #c_call {
|
sokol_audio_callback :: (buffer: *float, num_frames: s32, num_channels: s32) #c_call {
|
||||||
push_context,defer_pop default_context;
|
if !audio_thread_context_ready then return;
|
||||||
|
push_context,defer_pop audio_thread_context;
|
||||||
mixer_get_samples(buffer, num_frames, num_channels);
|
mixer_get_samples(buffer, num_frames, num_channels);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,6 +94,8 @@ init :: () {
|
|||||||
logger = .{ func = slog_func },
|
logger = .{ func = slog_func },
|
||||||
}));
|
}));
|
||||||
asset_manager_init();
|
asset_manager_init();
|
||||||
|
Thread.init(*g_mixer.mutex);
|
||||||
|
audio_init_thread_context();
|
||||||
saudio_setup(*(saudio_desc.{
|
saudio_setup(*(saudio_desc.{
|
||||||
logger = .{ func = slog_func },
|
logger = .{ func = slog_func },
|
||||||
stream_cb = sokol_audio_callback,
|
stream_cb = sokol_audio_callback,
|
||||||
|
|||||||
@ -37,7 +37,7 @@ animation_player_tick :: (player: *Animation_Player) {
|
|||||||
|
|
||||||
animation_draw :: (player: *Animation_Player, position: Vector3, flipX: bool = false, flipY: bool = false) {
|
animation_draw :: (player: *Animation_Player, position: Vector3, flipX: bool = false, flipY: bool = false) {
|
||||||
animation_player_tick(player);
|
animation_player_tick(player);
|
||||||
if player.current_animation == null then log_warn("Trying to draw a null animation!!");
|
if player.current_animation == null then return;
|
||||||
create_billboard_rendering_task(position, player.current_animation, player.current_frame, flipX, flipY);
|
create_billboard_rendering_task(position, player.current_animation, player.current_frame, flipX, flipY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +57,7 @@ animation_set_if_not :: (player: *Animation_Player, animation: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
animation_is :: (player: *Animation_Player, animation: string) -> bool {
|
animation_is :: (player: *Animation_Player, animation: string) -> bool {
|
||||||
|
if player.current_animation == null then return false;
|
||||||
_, pack, anim := split_from_left(animation, ".");
|
_, pack, anim := split_from_left(animation, ".");
|
||||||
return player.current_animation.name == anim;
|
return player.current_animation.name == anim;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user