From 0c896d44ee5f3b681e8e5d3b94efc586318172ae Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 5 Jul 2026 00:31:42 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8D=E3=82=A4=E3=83=86=E3=82=A3=E3=83=96?= =?UTF-8?q?=E3=83=AF=E3=83=BC=E3=82=AB=E3=83=BC=E3=81=B8obj.getaudio?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- native/worker.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/native/worker.lua b/native/worker.lua index 1126980..a02276e 100644 --- a/native/worker.lua +++ b/native/worker.lua @@ -98,6 +98,7 @@ local CB_KIND_PIXELSHADER_RUN = 14 local CB_KIND_LOADSCENE = 15 local CB_KIND_LOADBRUSH = 16 local CB_KIND_BRUSH = 17 +local CB_KIND_GETAUDIO = 18 local MAX_PIXEL_BUFFER = 3840 * 2160 * 4 local SHADER_META_DOUBLES = 20 local SHADER_CONSTANTS_MAX = 1024 @@ -690,6 +691,30 @@ function obj.getvalue(target) return 0 end +function obj.getaudio(buf, file, datatype, size) + if type(file) ~= "string" then return 0, 0 end + local payload = file .. "\0" .. tostring(datatype or "pcm") + local len = #payload + if len > CB_TAG_MAX then len = CB_TAG_MAX end + ffi.copy(base + CB_TAG_OFFSET, payload, len) + i32[OFF_CB_TAGLEN] = len + cbResult[0] = tonumber(size) or 0 + i32[OFF_CB_KIND] = CB_KIND_GETAUDIO + i32[OFF_STATUS] = STATUS_CALLBACK + k32.SetEvent(doneEvent) + k32.WaitForSingleObject(workEvent, INFINITE) + local count = math.floor(cbResult[0]) + local rate = math.floor(cbResult[1]) + local out = buf + if type(out) ~= "table" then + if buf ~= nil then return count, rate end + out = {} + end + for i = 0, count - 1 do out[i + 1] = cbTagD[i] end + if buf == nil then return count, rate, out end + return count, rate +end + function obj.getinfo(name) if name == "script_path" then return scriptPath end if name == "filter" then return true end