From: Steinar H. Gunderson Date: Wed, 7 Oct 2015 22:00:54 +0000 (+0200) Subject: Hook up the cut button to Lua, so that it actually does something. X-Git-Tag: 1.0.0~281 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1e4d9085b0fd09607c8da23008cbee3be8ff119d;p=nageru Hook up the cut button to Lua, so that it actually does something. --- diff --git a/mainwindow.cpp b/mainwindow.cpp index ad0808c..f3c674d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -23,6 +23,5 @@ MainWindow::MainWindow() void MainWindow::cut() { - static int i = 0; - global_mixer->cut(Mixer::Source((++i) % 3)); + global_mixer->transition_clicked(0, 0.0f); // FIXME: real values } diff --git a/mixer.cpp b/mixer.cpp index 83bb7a5..99aa33c 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -271,6 +271,7 @@ void Mixer::thread_func() while (!should_quit) { ++frame; +#if 0 //int width0 = lrintf(848 * (1.0 + 0.2 * sin(frame * 0.02))); int width0 = 848; int height0 = lrintf(width0 * 9.0 / 16.0); @@ -327,7 +328,6 @@ void Mixer::thread_func() right1 = right1 * scale0 + tx0; } -#if 0 place_rectangle(resample_effect, padding_effect, left0, top0, right0, bottom0); place_rectangle(resample2_effect, padding2_effect, left1, top1, right1, bottom1); #endif @@ -531,9 +531,9 @@ void Mixer::quit() mixer_thread.join(); } -void Mixer::cut(Source source) +void Mixer::transition_clicked(int transition_num, float t) { - current_source = source; + theme->transition_clicked(transition_num, t); } void Mixer::OutputChannel::output_frame(DisplayFrame frame) diff --git a/mixer.h b/mixer.h index 80d18ff..b4eaad9 100644 --- a/mixer.h +++ b/mixer.h @@ -32,12 +32,7 @@ public: void start(); void quit(); - enum Source { - SOURCE_INPUT1, - SOURCE_INPUT2, - SOURCE_SBS, - }; - void cut(Source source); + void transition_clicked(int transition_num, float t); enum Output { OUTPUT_LIVE = 0, @@ -98,7 +93,6 @@ private: // Effects part of . Owned by . movit::FlatInput *display_input; - Source current_source = SOURCE_INPUT1; int frame = 0; std::mutex bmusb_mutex; diff --git a/theme.cpp b/theme.cpp index 26f7937..5d42c3d 100644 --- a/theme.cpp +++ b/theme.cpp @@ -248,3 +248,16 @@ void Theme::connect_signal(YCbCrInput *input, int signal_num) input->set_texture_num(0, input_textures[signal_num].tex_y); input->set_texture_num(1, input_textures[signal_num].tex_cbcr); } + +void Theme::transition_clicked(int transition_num, float t) +{ + unique_lock lock(m); + lua_getglobal(L, "transition_clicked"); + lua_pushnumber(L, transition_num); + lua_pushnumber(L, t); + + if (lua_pcall(L, 2, 0, 0) != 0) { + fprintf(stderr, "error running function `transition_clicked': %s", lua_tostring(L, -1)); + exit(1); + } +} diff --git a/theme.h b/theme.h index 2e06347..f58681d 100644 --- a/theme.h +++ b/theme.h @@ -26,6 +26,7 @@ public: } void connect_signal(movit::YCbCrInput *input, int signal_num); + void transition_clicked(int transition_num, float t); private: std::mutex m; diff --git a/theme.lua b/theme.lua index 95a765b..fbe2cbf 100644 --- a/theme.lua +++ b/theme.lua @@ -8,12 +8,14 @@ -- C++ side and you generally just build chains. io.write("hello from lua\n"); +local live_signal_num = 0; +local preview_signal_num = 1; + -- The main live chain. Currently just about input 0 with some color correction. local main_chain = EffectChain.new(16, 9); local input0 = main_chain:add_live_input(); input0:connect_signal(0); local wb_effect = main_chain:add_effect(WhiteBalanceEffect.new(), input0); -wb_effect:set_float("output_color_temperature", 1234.0); main_chain:finalize(true); -- local input1 = main_chain.add_input(Inputs.create(1)); -- local resample_effect = main_chain.add_effect(ResampleEffect.new(), input0); @@ -37,8 +39,10 @@ function get_transitions() end function transition_clicked(num, t) - -- Presumably do some sort of transition here. - io.write("STUB: transition_clicked\n"); + -- Only a cut for now. + local temp = live_signal_num; + live_signal_num = preview_signal_num; + preview_signal_num = temp; end function channel_clicked(num, t) @@ -60,14 +64,14 @@ end function get_chain(num, t, width, height) if num == 0 then -- Live. prepare = function() - input0:connect_signal(1); + input0:connect_signal(live_signal_num); wb_effect:set_float("output_color_temperature", 3500.0 + t * 100.0); end return main_chain, prepare; end if num == 1 then -- Preview. prepare = function() - simple_chain_input:connect_signal(0); + simple_chain_input:connect_signal(preview_signal_num); end return simple_chain, prepare; end