Skip to content

Commit

Permalink
缺少fmod库不再会直接无法启动
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed May 15, 2024
1 parent 44eed47 commit 934b1a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Zenitha
Submodule Zenitha updated 1 files
+12 −1 mathExtend.lua
23 changes: 13 additions & 10 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ local M=require("master")
-- search for fmod shared libraries in package.cpath
local fmodPath=package.searchpath("fmod",package.cpath)
local fmodstudioPath=package.searchpath("fmodstudio",package.cpath)
assert(fmodPath and fmodstudioPath,"FMOD shared libraries not found!")

-- pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi
-- package.loadlib(fmodPath,"")

M.C=ffi.load(fmodPath)
M.C2=ffi.load(fmodstudioPath)
if false and fmodPath and fmodstudioPath then
-- pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi
-- package.loadlib(fmodPath,"")
M.C=ffi.load(fmodPath)
M.C2=ffi.load(fmodstudioPath)
require("enums")
require("constants")
require("wrap")
require("errors")
else
MSG.new('error',"FMOD shared libraries not found!")
end

require("enums")
require("constants")
require("wrap")
require("errors")

--------------------------------------------------------------

Expand All @@ -29,6 +31,7 @@ local core ---@type FMOD.Core.System?

---@param args {maxChannel:number, DSPBufferLength:number, DSPBufferCount:number, studioFlag:FMOD.Const, coreFlag:FMOD.Const}
function M.init(args)
if not (M.C and M.C2) then return end
local firstTime=true
if M.studio then
M.studio:release()
Expand Down
16 changes: 9 additions & 7 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,15 @@ LANG.add{
LANG.setDefault('en')

function FMODLoadFunc() -- Will be called again when applying advanced options
FMOD.init{
maxChannel=math.min(SETTINGS.system.fmod_maxChannel,256),
DSPBufferCount=math.min(SETTINGS.system.fmod_DSPBufferCount,16),
DSPBufferLength=math.min(SETTINGS.system.fmod_DSPBufferLength,65536),
studioFlag=bit.bxor(FMOD.FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE,FMOD.FMOD_INIT_STREAM_FROM_UPDATE,FMOD.FMOD_INIT_MIX_FROM_UPDATE),
coreFlag=FMOD.FMOD_INIT_NORMAL,
}
if FMOD.C then
FMOD.init{
maxChannel=math.min(SETTINGS.system.fmod_maxChannel,256),
DSPBufferCount=math.min(SETTINGS.system.fmod_DSPBufferCount,16),
DSPBufferLength=math.min(SETTINGS.system.fmod_DSPBufferLength,65536),
studioFlag=bit.bxor(FMOD.FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE,FMOD.FMOD_INIT_STREAM_FROM_UPDATE,FMOD.FMOD_INIT_MIX_FROM_UPDATE),
coreFlag=FMOD.FMOD_INIT_NORMAL,
}
end
if not FMOD.loadBank(love.filesystem.getSaveDirectory().."/soundbank/Master.strings.bank") then
MSG.new('warn',"Strings bank file load failed")
end
Expand Down

0 comments on commit 934b1a2

Please sign in to comment.