fp: Switch to sokol audio to fix audio bugs
This commit is contained in:
parent
9ba6071f9b
commit
0522e842c4
2
External/tely
vendored
2
External/tely
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d82244653e856bbf4f83c6338207405aa4595e46
|
Subproject commit 07b3737cf4e5e68be355630228375c5b5873513f
|
@ -4429,7 +4429,6 @@ TELY_OS_DLL_FUNCTION
|
|||||||
void TELY_OS_DLLFrameUpdate(TELY_OS *os)
|
void TELY_OS_DLLFrameUpdate(TELY_OS *os)
|
||||||
{
|
{
|
||||||
TELY_OSInput *input = &os->input;
|
TELY_OSInput *input = &os->input;
|
||||||
TELY_Assets *assets = &os->assets;
|
|
||||||
TELY_Renderer *renderer = &os->renderer;
|
TELY_Renderer *renderer = &os->renderer;
|
||||||
FP_Game *game = DQN_CAST(FP_Game *) os->user_data;
|
FP_Game *game = DQN_CAST(FP_Game *) os->user_data;
|
||||||
|
|
||||||
@ -4491,6 +4490,4 @@ void TELY_OS_DLLFrameUpdate(TELY_OS *os)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FP_Render(game, os, renderer, audio);
|
FP_Render(game, os, renderer, audio);
|
||||||
|
|
||||||
TELY_Audio_MixPlaybackSamples(audio, assets);
|
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,38 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: sokol_audio ================================================================================
|
||||||
|
Dqn_Str8 sokol_audio_source_code_file = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/sokol/sokol_audio.c", DQN_STR_FMT(tely_dir));
|
||||||
|
uint64_t sokol_audio_pc_timings[2] = {};
|
||||||
|
Dqn_List<Dqn_Str8> sokol_audio_pc_output_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
||||||
|
{
|
||||||
|
sokol_audio_pc_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
|
DQN_DEFER { sokol_audio_pc_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
|
Dqn_CPPBuildContext build_context = {};
|
||||||
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
|
Dqn_CPPBuildCompileFile{
|
||||||
|
{}, // Args
|
||||||
|
sokol_audio_source_code_file,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Dqn_List_Add(&sokol_audio_pc_output_files, DQN_STR8("sokol_audio.obj"));
|
||||||
|
|
||||||
|
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 16, common_compile_flags);
|
||||||
|
Dqn_List_Add(&compile_flags, DQN_STR8("/c"));
|
||||||
|
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
|
build_context.build_dir = build_dir;
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: QOI Converter =========================================================================
|
// NOTE: QOI Converter =========================================================================
|
||||||
uint64_t qoi_converter_timings[2] = {};
|
uint64_t qoi_converter_timings[2] = {};
|
||||||
{
|
{
|
||||||
@ -286,6 +318,8 @@ int main(int argc, char const **argv)
|
|||||||
{
|
{
|
||||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
|
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
|
||||||
Dqn_List_Add(&link_flags, *it.data);
|
Dqn_List_Add(&link_flags, *it.data);
|
||||||
|
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&sokol_audio_pc_output_files, &it, 0); )
|
||||||
|
Dqn_List_Add(&link_flags, *it.data);
|
||||||
Dqn_List_Add(&link_flags, DQN_STR8("gdi32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STR8("gdi32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STR8("opengl32.lib"));
|
Dqn_List_Add(&link_flags, DQN_STR8("opengl32.lib"));
|
||||||
Dqn_List_Add(&link_flags, DQN_STR8("winmm.lib"));
|
Dqn_List_Add(&link_flags, DQN_STR8("winmm.lib"));
|
||||||
@ -434,7 +468,7 @@ int main(int argc, char const **argv)
|
|||||||
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
|
|
||||||
// NOTE: Setup build context ===========================================================
|
// NOTE: Setup build context ===========================================================
|
||||||
Dqn_List<Dqn_Str8> raylib_emscripten_output_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
Dqn_List<Dqn_Str8> emscripten_obj_files = Dqn_List_Init<Dqn_Str8>(scratch.arena, 16);
|
||||||
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
|
||||||
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
|
||||||
|
|
||||||
@ -461,7 +495,7 @@ int main(int argc, char const **argv)
|
|||||||
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
raylib_emscripten_build_context.build_dir = build_dir;
|
raylib_emscripten_build_context.build_dir = build_dir;
|
||||||
Dqn_List_Add(&raylib_emscripten_output_files, build_file.output_file_path);
|
Dqn_List_Add(&emscripten_obj_files, build_file.output_file_path);
|
||||||
|
|
||||||
if (dry_run) {
|
if (dry_run) {
|
||||||
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
@ -471,13 +505,45 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Build the wasm raylib library =================================================
|
{
|
||||||
|
Dqn_Str8 base_file = sokol_audio_source_code_file;
|
||||||
|
Dqn_Str8 file_stem = Dqn_Str8_FileNameNoExtension(base_file);
|
||||||
|
|
||||||
|
// NOTE: Append "emscripten" suffix to the object files
|
||||||
|
Dqn_CPPBuildCompileFile build_file = {};
|
||||||
|
build_file.input_file_path = base_file;
|
||||||
|
build_file.output_file_path = Dqn_Str8_InitF(scratch.allocator, "sokol_audio_emscripten.o");
|
||||||
|
|
||||||
|
Dqn_List<Dqn_Str8> compile_flags = Dqn_List_InitCArrayCopy(scratch.arena, 32, {
|
||||||
|
DQN_STR8("cmd"),
|
||||||
|
DQN_STR8("/C"),
|
||||||
|
DQN_STR8("emcc.bat"),
|
||||||
|
DQN_STR8("-c"), // Compile and assemble, but do not link
|
||||||
|
DQN_STR8("-Wall"),
|
||||||
|
DQN_STR8("-Os"), // Optimize for size
|
||||||
|
});
|
||||||
|
Dqn_List_AddList(&compile_flags, build_specific_compile_flags);
|
||||||
|
|
||||||
|
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
|
||||||
|
raylib_emscripten_build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
|
||||||
|
raylib_emscripten_build_context.build_dir = build_dir;
|
||||||
|
Dqn_List_Add(&emscripten_obj_files, build_file.output_file_path);
|
||||||
|
|
||||||
|
if (dry_run) {
|
||||||
|
Dqn_Str8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STR_FMT(cmd));
|
||||||
|
} else {
|
||||||
|
Dqn_CPPBuild_ExecOrAbort(raylib_emscripten_build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Build the wasm raylib+sokol_audio library =====================================
|
||||||
{
|
{
|
||||||
Dqn_Str8Builder builder = {};
|
Dqn_Str8Builder builder = {};
|
||||||
builder.allocator = scratch.allocator;
|
builder.allocator = scratch.allocator;
|
||||||
Dqn_Str8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STR_FMT(raylib_emscripten_lib_name));
|
Dqn_Str8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STR_FMT(raylib_emscripten_lib_name));
|
||||||
|
|
||||||
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&raylib_emscripten_output_files, &it, 0); )
|
for (Dqn_ListIterator<Dqn_Str8> it = {}; Dqn_List_Iterate(&emscripten_obj_files, &it, 0); )
|
||||||
Dqn_Str8Builder_AppendF(&builder, " %.*s", DQN_STR_FMT(*it.data));
|
Dqn_Str8Builder_AppendF(&builder, " %.*s", DQN_STR_FMT(*it.data));
|
||||||
|
|
||||||
Dqn_Str8 cmd = Dqn_Str8Builder_Build(&builder, scratch.allocator);
|
Dqn_Str8 cmd = Dqn_Str8Builder_Build(&builder, scratch.allocator);
|
||||||
@ -603,6 +669,7 @@ int main(int argc, char const **argv)
|
|||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
|
||||||
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " sokol_audio: %.2fms", Dqn_OS_PerfCounterMs(sokol_audio_pc_timings[0], sokol_audio_pc_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
|
||||||
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
|
||||||
|
Loading…
Reference in New Issue
Block a user