From 5a65cbe07128a149dba7d44bbd69154da871d6c8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 1 Nov 2025 22:04:39 +0300 Subject: [PATCH] move PCMStream to audio --- res/scripts/hud.lua | 4 ++-- src/logic/scripting/lua/lua_engine.cpp | 8 +++++++- src/logic/scripting/lua/usertypes/lua_type_pcmstream.hpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/res/scripts/hud.lua b/res/scripts/hud.lua index 73355ddf..db6f9b79 100644 --- a/res/scripts/hud.lua +++ b/res/scripts/hud.lua @@ -119,12 +119,12 @@ function on_hud_open() hud.default_hand_controller = update_hand - stream = PCMStream(44100, 1, 16) + stream = audio.PCMStream(44100, 1, 16) stream:share("test-stream") streamid = audio.play_stream_2d("test-stream", 2.0, 1.0, "ui") - s = PCMStream(44100, 1, 8) + s = audio.PCMStream(44100, 1, 8) local buffer = Bytearray(44100) for i=1, #buffer do buffer[i] = math.random(1, 8) diff --git a/src/logic/scripting/lua/lua_engine.cpp b/src/logic/scripting/lua/lua_engine.cpp index c4507bb1..80e2cff7 100644 --- a/src/logic/scripting/lua/lua_engine.cpp +++ b/src/logic/scripting/lua/lua_engine.cpp @@ -131,7 +131,6 @@ void lua::init_state(State* L, StateType stateType) { newusertype(L); newusertype(L); newusertype(L); - newusertype(L); } void lua::initialize(const EnginePaths& paths, const CoreParameters& params) { @@ -186,5 +185,12 @@ State* lua::create_state(const EnginePaths& paths, StateType stateType) { } pop(L); } + newusertype(L); + if (getglobal(L, "audio")) { + if (getglobal(L, "__vc_PCMStream")) { + setfield(L, "PCMStream"); + } + pop(L); + } return L; } diff --git a/src/logic/scripting/lua/usertypes/lua_type_pcmstream.hpp b/src/logic/scripting/lua/usertypes/lua_type_pcmstream.hpp index 47979693..524c7169 100644 --- a/src/logic/scripting/lua/usertypes/lua_type_pcmstream.hpp +++ b/src/logic/scripting/lua/usertypes/lua_type_pcmstream.hpp @@ -18,7 +18,7 @@ namespace lua { return TYPENAME; } static int createMetatable(lua::State*); - inline static std::string TYPENAME = "PCMStream"; + inline static std::string TYPENAME = "__vc_PCMStream"; private: std::shared_ptr stream; };