• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 45465485304

24 Nov 2026 06:59PM UTC coverage: 62.1% (+0.3%) from 61.818%
45465485304

Pull #2302

github

web-flow
Merge 52aaaa0b4 into ef0dd3ce5
Pull Request #2302: Mixer: a console of strips with meters, and the execution reporting back without stopping the audio

268210 of 802082 branches covered (33.44%)

1579 of 2302 new or added lines in 45 files covered. (68.59%)

123 existing lines in 22 files now uncovered.

274219 of 441577 relevant lines covered (62.1%)

766034.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.74
/src/plugins/score-plugin-js/JS/Executor/Component.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "Component.hpp"
4

5
#include <LocalTree/LocalTreeDocumentPlugin.hpp>
6

7
#include "CPUNode.hpp"
8

9
#include <Explorer/DocumentPlugin/DeviceDocumentPlugin.hpp>
10

11
#include <Scenario/Execution/score2OSSIA.hpp>
12
#include <Scenario/Settings/ScenarioSettingsModel.hpp>
13

14
#include <Execution/DocumentPlugin.hpp>
15
#include <JS/JSProcessModel.hpp>
16

17
#include <score/application/GUIApplicationContext.hpp>
18
#include <score/tools/FilePath.hpp>
19

20
#if defined(SCORE_HAS_GPU_JS)
21
#include "GPUNode.hpp"
22

23
#include <Gfx/GfxApplicationPlugin.hpp>
24
#include <Gfx/TexturePort.hpp>
25
#endif
26

27
#include <score/tools/Bind.hpp>
28

29
#include <stdexcept>
30

31
namespace JS
32
{
33
namespace Executor
34
{
35
Component::Component(
23 ✔
36
    JS::ProcessModel& element, const ::Execution::Context& ctx, QObject* parent)
37
    : ::Execution::ProcessComponent_T<JS::ProcessModel, ossia::node_process>{
23 !
38
        element, ctx, "JSComponent", parent}
23 ✔
39
{
23 ✔
40
#if defined(__EMSCRIPTEN__)
41
  // The QML engine runs on the audio thread, which in a browser is an
42
  // AudioWorklet: a Wasm Worker, not a pthread. pthread_self() is null there,
43
  // so Qt cannot tell threads apart and QRecursiveMutex excludes nothing; the
44
  // first contended lock spins forever and takes the page with it.
45
  throw std::runtime_error{"Javascript processes are not supported in the web build"};
46
#endif
47
  const bool isGpu = element.isGpu();
23 ✔
48

49
  if(!isGpu)
23 ✔
50
  {
51
    auto& tree = ctx.doc.plugin<LocalTree::DocumentPlugin>();
8 !
52
    std::shared_ptr<js_node> node
53
        = ossia::make_node<js_node>(*ctx.execState, *ctx.execState, tree.snapshot());
8 !
54
    this->node = node;
8 ✔
55

56
    // The old names go back to the GUI thread to be released
57
    connect(
8 !
58
        &tree, &LocalTree::ScriptableTreeBase::snapshotChanged, this,
8 ✔
59
        [this, node, &tree] {
8 ✔
60
      in_exec([node, names = tree.snapshot(), gcq = weak_gc]() mutable {
×
61
        std::swap(node->m_names, names);
×
62
        node->m_namesChanged = true;
×
63
        if(auto q = gcq.lock())
×
64
          q->enqueue(Execution::gc(std::move(names)));
×
65
      });
×
66
    });
×
67

68
    // FIXME also process in this GPU
69
    node->m_modelState = element.state();
8 !
70
    node->m_uiContext = this;
8 !
71
    node->m_modelContext = &element;
8 !
72
    // Nothing goes to the interface while the execution does not report back.
73
    if(ctx.doc.app.settings<Scenario::Settings::Model>().getExecutionUpdate())
8 !
74
      node->m_messageToUi = [this](const QVariant& v) {
8 ✔
NEW
75
        OSSIA_ENSURE_CURRENT_THREAD_KIND(ossia::thread_type::Ui);
×
NEW
76
        this->process().executionToUi(v);
×
NEW
77
      };
×
78
    connect(
8 !
79
        &element, &JS::ProcessModel::uiToExecution, this,
8 ✔
80
        [this, node](const QVariant& v) {
8 ✔
81
      auto encaps = std::make_unique<QVariant>(v);
×
82
      in_exec([node, vv=std::move(encaps)] { node->uiMessage(*vv); });
×
83
    }, Qt::QueuedConnection);
×
84
    connect(
8 !
85
        &element, &JS::ProcessModel::stateElementChanged, this,
8 ✔
86
        [this, node](const QString& k, const ossia::value& v) {
9 ✔
87
      in_exec([node, k=k, v=v] { node->stateElementChanged(k, v); });
1 !
88
    }, Qt::QueuedConnection);
1 ✔
89

90
    auto proc = std::make_shared<js_process>(node);
8 !
91
    m_ossia_process = proc;
8 ✔
92
    on_scriptChange();
8 !
93
  }
8 ✔
94
  else
95
  {
96
#if defined(SCORE_HAS_GPU_JS)
97
    std::shared_ptr<gpu_exec_node> node = ossia::make_node<gpu_exec_node>(
15 !
98
        *ctx.execState, ctx.doc.plugin<Gfx::DocumentPlugin>().exec);
15 !
99
    this->node = node;
15 ✔
100

101
    m_ossia_process = std::make_shared<ossia::node_process>(node);
15 !
102

103
    on_scriptChange();
15 !
104
#else
105
    throw std::runtime_error(
106
        "GPU Nodes not supported in this build of score, use a distribution with an "
107
        "up-to-date version of Qt.");
108
#endif
109
  }
15 ✔
110

111
  con(element, &JS::ProcessModel::programChanged, this, &Component::on_scriptChange,
46 !
112
      Qt::DirectConnection);
23 ✔
113
}
23 ✔
114

115
Component::~Component() { }
23 ✔
116

117
void Component::cleanup()
42 ✔
118
{
119
#if defined(SCORE_HAS_GPU_JS)
120
  for(auto* outlet : process().outlets())
89 ✔
121
    if(auto out = qobject_cast<Gfx::TextureOutlet*>(outlet))
47 ✔
122
      out->nodeId = score::gfx::invalid_node_index;
27 ✔
123
#endif
124
  Execution::ProcessComponent::cleanup();
42 ✔
125
}
42 ✔
126

127
void Component::on_scriptChange()
23 ✔
128
{
129
  enum Type
130
  {
131
    None,
132
    Cpu,
133
    Gpu
134
  };
135
  Type cur_type{};
23 ✔
136
  Type next_type = process().isGpu() ? Gpu : Cpu;
23 ✔
137

138
  if(!node)
23 !
139
  {
140
    cur_type = None;
×
141
  }
×
142
  else if(auto old_node = std::dynamic_pointer_cast<js_node>(node))
46 ✔
143
  {
144
    cur_type = Cpu;
8 ✔
145
  }
8 ✔
146
  else
147
  {
148
    cur_type = Gpu;
15 ✔
149
  }
150

151
  Execution::Transaction commands{system()};
23 ✔
152

153
  // 0. Unregister all the previous inlets / outlets
154
  auto& setup = system().setup;
23 ✔
155
  setup.unregister_node_soft(process().inlets(), process().outlets(), node, commands);
23 !
156
#if defined(SCORE_HAS_GPU_JS)
157
  for(auto* outlet : process().outlets())
49 !
158
    if(auto out = qobject_cast<Gfx::TextureOutlet*>(outlet))
26 !
159
      out->nodeId = score::gfx::invalid_node_index;
15 ✔
160
#endif
161

162
  std::tuple<ossia::inlets, ossia::outlets, std::vector<Execution::ExecutionCommand>>
163
      new_ports;
23 ✔
164

165
  for(auto ctrl : process().inlets())
31 !
166
    disconnect(ctrl, nullptr, this, nullptr);
8 !
167
  for(auto ctrl : process().outlets())
49 !
168
    disconnect(ctrl, nullptr, this, nullptr);
26 !
169

170
  const auto& script = process().qmlData();
23 !
171
  // 1. Recreate ports & change the script
172
  if(cur_type == next_type)
23 !
173
  {
174
    if(next_type == Cpu)
23 ✔
175
      new_ports = on_cpuScriptChange(script, commands);
8 !
176
    else if(next_type == Gpu)
15 !
177
      new_ports = on_gpuScriptChange(script, commands);
15 !
178
  }
23 ✔
179
  else
180
  {
181
    // FIXME destroy the node
182
    if(next_type == Cpu)
×
183
      new_ports = on_cpuScriptChange(script, commands);
×
184
    else if(next_type == Gpu)
×
185
      new_ports = on_gpuScriptChange(script, commands);
×
186
  }
187

188
  // 3. Register the inlets / outlets
189
  auto& [inls, outls, controlSetups] = new_ports;
23 ✔
190

191
  for(std::size_t i = 0; i < inls.size(); i++)
31 ✔
192
  {
193
    setup.register_inlet(*process().inlets()[i], inls[i], node, commands);
8 !
194
  }
8 ✔
195
  for(std::size_t i = 0; i < outls.size(); i++)
49 ✔
196
  {
197
    setup.register_outlet(*process().outlets()[i], outls[i], node, commands);
26 !
198
  }
26 ✔
199

200
  // Additional commands once the inlets / outlets are set
201
  commands.commands.reserve(commands.commands.size() + controlSetups.size());
23 !
202
  // OPTIMIZEME std::move algorithm
203
  for(auto& cmd : controlSetups)
25 ✔
204
    commands.commands.push_back(std::move(cmd));
2 !
205
  controlSetups.clear();
23 ✔
206

207
  commands.run_all();
23 !
208

209
  m_oldInlets = process().inlets();
23 !
210
  m_oldOutlets = process().outlets();
23 !
211
}
23 ✔
212

213
std::tuple<ossia::inlets, ossia::outlets, std::vector<Execution::ExecutionCommand>>
214
Component::on_gpuScriptChange(const QString& script, Execution::Transaction& commands)
15 ✔
215
{
216
#if defined(SCORE_HAS_GPU_JS)
217
  auto node = std::dynamic_pointer_cast<gpu_exec_node>(this->node);
15 ✔
218
  std::weak_ptr<Gfx::gfx_exec_node> weak_node = node;
15 ✔
219
  int script_index = ++node->script_index;
15 ✔
220

221
  // 1. Create new inlet & outlet arrays
222
  ossia::inlets inls;
15 ✔
223
  ossia::outlets outls;
15 ✔
224
  Gfx::exec_controls controls;
15 ✔
225
  std::vector<Execution::ExecutionCommand> controlSetups;
15 ✔
226

227
  int inlet_idx = 0;
15 ✔
228
  int outlet_idx = 0;
15 ✔
229
  std::size_t control_index = 0;
15 ✔
230
  {
231
    const Execution::Context& ctx = system();
15 ✔
232
    if(auto object = process().currentExecutionObject())
15 !
233
    {
234
      for(auto n : object->children())
39 !
235
      {
236
        auto inlet = qobject_cast<Inlet*>(n);
24 !
237
        auto outlet = qobject_cast<Outlet*>(n);
24 !
238
        if(!inlet && !outlet)
24 !
239
          continue;
×
240

241
        if([[maybe_unused]] auto val_in = qobject_cast<ValueInlet*>(inlet))
24 !
242
        {
243
          // NOTE! we do not use add_control() here as it changes the internal arrays,
244
          // while we will replace them after in ossia::recabler
245

246
          auto inletport = new ossia::value_inlet;
×
247
          auto control = std::make_shared<Gfx::gfx_exec_node::control>();
×
248
          control->port = &**inletport;
×
249
          control->changed = true;
×
250
          controls.push_back(control);
×
251

252
          inls.push_back(inletport);
×
253

254
          control_index++;
×
255
        }
×
256

257
        else if([[maybe_unused]] auto ctrl_in = qobject_cast<JS::ControlInlet*>(inlet))
24 !
258
        {
259
          auto inletport = new ossia::value_inlet;
4 !
260
          auto control = std::make_shared<Gfx::gfx_exec_node::control>();
4 !
261
          control->port = &**inletport;
4 ✔
262
          control->changed = true;
4 ✔
263

264
          // Configure control forwarding
265

266
          {
267
            auto model_port = process().inlets()[inlet_idx];
4 !
268
            auto model_ctrl = safe_cast<Process::ControlInlet*>(model_port);
4 !
269

270
            model_ctrl->setupExecution(*inletport, this);
4 ✔
271
            control->changed = true;
4 ✔
272

273
            // TODO assert that we aren't going to connect UI -> exec twice
274

275
            if(auto ctrl = model_ctrl; qobject_cast<Process::FileChooserBase*>(ctrl))
4 !
276
            {
277
              connect(
×
278
                  ctrl, &Process::ControlInlet::valueChanged, this,
×
279
                  [&ctx, control_index, script_index,
×
280
                   weak_node](const ossia::value& val) {
×
281
                if(auto str = val.target<std::string>())
×
282
                {
283
                  auto path = score::locateFilePath(
×
284
                      QString::fromStdString(*str).trimmed(), ctx.doc);
×
285
                  Gfx::con_unvalidated{ctx, control_index, script_index, weak_node}(
×
286
                      path.toStdString());
×
287
                }
×
288
              });
×
289
              control->value = model_ctrl->value();
×
290
              if(auto str = model_ctrl->value().target<std::string>())
×
291
              {
292
                auto path = score::locateFilePath(
×
293
                    QString::fromStdString(*str).trimmed(), ctx.doc);
×
294
                control->value = path.toStdString();
×
295
              }
×
296
            }
×
297
            else
298
            {
299
              QObject::connect(
4 !
300
                  model_ctrl, &Process::ControlInlet::valueChanged, this,
4 ✔
301
                  Gfx::con_unvalidated{ctx, control_index, script_index, weak_node});
4 ✔
302
              control->value = model_ctrl->value();
4 ✔
303
            }
304
            // FIXME initial control state
305
            // controlSetups.push_back([/* node, val = ctrl->value(), idx */] {
306
            //   // node->setControl(idx, val.apply(ossia::qt::ossia_to_qvariant{}));
307
            // });
308
          }
309

310
          controls.push_back(control);
4 !
311

312
          inls.push_back(inletport);
4 !
313

314
          control_index++;
4 ✔
315
        }
4 ✔
316
        else if([[maybe_unused]] auto tex_in = qobject_cast<TextureInlet*>(inlet))
20 !
317
        {
318
          auto model_port = process().inlets()[inlet_idx];
×
319
          auto p = new ossia::texture_inlet;
×
320
          inls.push_back(p);
×
321
          model_port->setupExecution(*p, this);
×
322
        }
×
323
        /*
324
        if(auto ctrl_in = qobject_cast<ControlInlet*>(n))
325
        {
326
          inls.push_back(new ossia::value_inlet);
327
          inls.back()->target<ossia::value_port>()->is_event = false;
328

329
          ++idx;
330
        }
331
        else if(auto val_in = qobject_cast<ValueInlet*>(n))
332
        {
333
          inls.push_back(new ossia::value_inlet);
334
          auto& vp = *inls.back()->target<ossia::value_port>();
335

336
          vp.is_event = !val_in->isEvent();
337
          if(auto ctrl = qobject_cast<Process::ControlInlet*>(process().inlets()[idx]))
338
          {
339
            vp.type = ctrl->value().get_type();
340
            vp.domain = ctrl->domain().get();
341

342
            disconnect(ctrl, nullptr, this, nullptr);
343
            if(auto impulse = qobject_cast<Process::ImpulseButton*>(ctrl))
344
            {
345
              // connect(
346
              //     ctrl, &Process::ControlInlet::valueChanged, this,
347
              //     [this, node, idx](const ossia::value& val) {
348
              //   this->in_exec([node, idx] { node->impulse(idx); });
349
              //     });
350
            }
351
            else
352
            {
353
              // // Common case
354
              // connect(
355
              //     ctrl, &Process::ControlInlet::valueChanged, this,
356
              //     [this, node, idx](const ossia::value& val) {
357
              //   this->in_exec([node, val, idx] {
358
              //     node->setControl(idx, val.apply(ossia::qt::ossia_to_qvariant{}));
359
              //   });
360
              //     });
361
              // controlSetups.push_back([node, val = ctrl->value(), idx] {
362
              //   node->setControl(idx, val.apply(ossia::qt::ossia_to_qvariant{}));
363
              // });
364
            }
365
          }
366

367
          ++idx;
368
        }
369
        else if(auto aud_in = qobject_cast<AudioInlet*>(n))
370
        {
371
          inls.push_back(new ossia::audio_inlet);
372

373
          ++idx;
374
        }
375
        else if(auto mid_in = qobject_cast<MidiInlet*>(n))
376
        {
377
          inls.push_back(new ossia::midi_inlet);
378

379
          ++idx;
380
        }
381
        else if(auto val_out = qobject_cast<ValueOutlet*>(n))
382
        {
383
          outls.push_back(new ossia::value_outlet);
384
        }
385
        else if(auto aud_out = qobject_cast<AudioOutlet*>(n))
386
        {
387
          outls.push_back(new ossia::audio_outlet);
388
        }
389
        else if(auto mid_out = qobject_cast<MidiOutlet*>(n))
390
        {
391
          outls.push_back(new ossia::midi_outlet);
392
        }
393
*/
394

395
        else if(qobject_cast<ValueOutlet*>(outlet))
20 !
396
        {
397
          outls.push_back(new ossia::value_outlet);
5 !
398
        }
5 ✔
399
        else if([[maybe_unused]] auto tex_out = qobject_cast<TextureOutlet*>(outlet))
15 !
400
        {
401
          outls.push_back(new ossia::texture_outlet);
15 !
402
        }
15 ✔
403

404
        if(inlet)
24 ✔
405
          inlet_idx++;
4 ✔
406
        else if(outlet)
20 !
407
          outlet_idx++;
20 ✔
408
      }
409
    }
15 ✔
410
    else
411
    {
412
      return {};
×
413
    }
414
  }
415

416
  // Send the updates to the node
417
  auto recable = std::shared_ptr<ossia::recabler>(
15 !
418
      new ossia::recabler{node, system().execGraph, inls, outls});
15 !
419
  commands.push_back(
30 !
420
      [node, controls, recable, self = QPointer{this}, weak_node, script_index,
45 !
421
       source = std::make_unique<std::tuple<QString, QString, JS::JSState>>(
15 !
422
           process().rootPath(), script, process().state())]() mutable {
15 !
423
    using namespace std;
424
    // Note: we need to do this because we try to keep the Javascript node around
425
    // because it's slow to recreate.
426
    // But this causes a lot of problems, it'd be better to do like e.g. the faust
427
    // process and entirely recreate a new node, + call update node.
428
    (*recable)();
15 ✔
429

430
    swap(node->controls, controls);
15 ✔
431
    auto& [root, script, state] = *source;
15 ✔
432
    // This runs on the execution thread, while the UI thread may be removing
433
    // the process: build the new GpuNode here, but connect and register it
434
    // from the UI thread, and only if the component (hence its process) is
435
    // still alive and this is still the latest script.
436
    auto box = std::make_shared<std::unique_ptr<score::gfx::Node>>(
15 !
437
        node->prepareScript(root, script, std::move(state)));
15 ✔
438
    QMetaObject::invokeMethod(
15 !
439
        qApp,
15 ✔
440
        [self, weak_node, script_index, box] {
30 ✔
441
      const auto exec = std::dynamic_pointer_cast<gpu_exec_node>(weak_node.lock());
15 ✔
442
      if(!self || !exec || self->node != exec || exec->script_index != script_index
15 !
443
         || !*box)
14 !
444
        return; // dropping the box deletes the unregistered node, here on the UI thread
1 ✔
445
      const int32_t id = exec->attachAndRegister(std::move(*box), self->process());
14 !
446
      self->system().executionQueue.enqueue(
28 !
447
          [exec, id, script_index] { exec->adoptId(id, script_index); });
28 ✔
448
      for(auto* outlet : self->process().outlets())
32 ✔
449
        if(auto out = qobject_cast<Gfx::TextureOutlet*>(outlet))
18 !
450
          out->nodeId = id;
14 ✔
451
    },
15 !
452
        Qt::QueuedConnection);
453
  });
15 ✔
454

455
  SCORE_ASSERT(process().inlets().size() == inls.size());
15 !
456
  SCORE_ASSERT(process().outlets().size() == outls.size());
15 !
457
  return {std::move(inls), std::move(outls), std::move(controlSetups)};
15 ✔
458
#else
459
  return {};
460
#endif
461
}
15 ✔
462

463
std::tuple<ossia::inlets, ossia::outlets, std::vector<Execution::ExecutionCommand>>
464
Component::on_cpuScriptChange(const QString& script, Execution::Transaction& commands)
8 ✔
465
{
466
  [[maybe_unused]] auto& setup = system().setup;
8 ✔
467
  auto node = std::dynamic_pointer_cast<js_node>(this->node);
8 ✔
468

469
  // 1. Create new inlet & outlet arrays
470
  ossia::inlets inls;
8 ✔
471
  ossia::outlets outls;
8 ✔
472
  std::vector<Execution::ExecutionCommand> controlSetups;
8 ✔
473

474
  {
475
    if(auto object = process().currentExecutionObject())
8 !
476
    {
477
      int idx = 0;
8 ✔
478
      auto process_if_control
479
          = [this, &node, &controlSetups](ossia::value_port& vp, int idx) {
12 ✔
480
        if(auto ctrl = qobject_cast<Process::ControlInlet*>(process().inlets()[idx]))
4 ✔
481
        {
482
          vp.type = ctrl->value().get_type();
2 ✔
483
          vp.domain = ctrl->domain().get();
2 ✔
484

485
          if([[maybe_unused]] auto impulse = qobject_cast<Process::ImpulseButton*>(ctrl))
2 !
486
          {
487
            connect(
×
488
                ctrl, &Process::ControlInlet::valueChanged, this,
×
489
                [this, node, idx](const ossia::value& val) {
×
490
              in_exec([node, idx] { node->impulse(idx); });
×
491
            });
×
492
          }
×
493
          else if(
494
              [[maybe_unused]] auto impulse
2 !
495
              = qobject_cast<Process::FileChooserBase*>(ctrl))
2 ✔
496
          {
497
            connect(
×
498
                ctrl, &Process::ControlInlet::valueChanged, this,
×
499
                [&ctx = system().context().doc, node, idx](const ossia::value& val) {
×
500
              if(auto str = val.target<std::string>())
×
501
              {
502
                auto path
503
                    = score::locateFilePath(QString::fromStdString(*str).trimmed(), ctx);
×
504
                node->setControl(idx, path);
×
505
              }
×
506
            });
×
507
            controlSetups.push_back(
×
508
                [&ctx = system().context().doc, node, val = ctrl->value(), idx] {
×
509
              if(auto str = val.target<std::string>())
×
510
              {
511
                auto path
512
                    = score::locateFilePath(QString::fromStdString(*str).trimmed(), ctx);
×
513
                node->setControl(idx, path);
×
514
              }
×
515
            });
×
516
          }
×
517
          else
518
          {
519
            // Common case
520
            connect(
2 !
521
                ctrl, &Process::ControlInlet::valueChanged, this,
2 ✔
522
                [this, node, idx](const ossia::value& val) {
2 ✔
523
              in_exec([node, val, idx] {
×
524
                node->setControl(idx, val.apply(ossia::qt::ossia_to_qvariant{}));
×
525
              });
×
526
            });
×
527
            controlSetups.push_back([node, val = ctrl->value(), idx] {
4 !
528
              node->setControl(idx, val.apply(ossia::qt::ossia_to_qvariant{}));
2 !
529
            });
2 ✔
530
          }
531
        }
2 ✔
532
      };
4 ✔
533
      for(auto n : object->children())
18 !
534
      {
535
        if(qobject_cast<ControlInlet*>(n))
10 !
536
        {
537
          inls.push_back(new ossia::value_inlet);
2 !
538
          auto& vp = *inls.back()->target<ossia::value_port>();
2 ✔
539
          vp.is_event = false;
2 ✔
540

541
          process_if_control(vp, idx);
2 !
542

543
          ++idx;
2 ✔
544
        }
2 ✔
545
        else if(auto val_in = qobject_cast<ValueInlet*>(n))
8 !
546
        {
547
          inls.push_back(new ossia::value_inlet);
2 !
548
          auto& vp = *inls.back()->target<ossia::value_port>();
2 ✔
549
          vp.is_event = !val_in->isEvent();
2 !
550

551
          process_if_control(vp, idx);
2 !
552

553
          ++idx;
2 ✔
554
        }
2 ✔
555
        else if(qobject_cast<AudioInlet*>(n))
6 !
556
        {
557
          inls.push_back(new ossia::audio_inlet);
×
558

559
          ++idx;
×
560
        }
×
561
        else if(qobject_cast<MidiInlet*>(n))
6 !
562
        {
563
          inls.push_back(new ossia::midi_inlet);
×
564

565
          ++idx;
×
566
        }
×
567
        else if(qobject_cast<ValueOutlet*>(n))
6 !
568
        {
569
          outls.push_back(new ossia::value_outlet);
6 !
570
        }
6 ✔
571
        else if(qobject_cast<AudioOutlet*>(n))
×
572
        {
573
          outls.push_back(new ossia::audio_outlet);
×
574
        }
×
575
        else if(qobject_cast<MidiOutlet*>(n))
×
576
        {
577
          outls.push_back(new ossia::midi_outlet);
×
578
        }
×
579
      }
580
    }
8 ✔
581
    else
582
    {
583
      return {};
×
584
    }
585
  }
586

587
  // Send the updates to the node
588
  auto recable = std::shared_ptr<ossia::recabler>(
8 !
589
      new ossia::recabler{node, system().execGraph, inls, outls});
8 !
590
  commands.push_back([node, path = process().rootPath(), script, recable,
24 !
591
                      st = std::make_unique<JS::JSState>(process().state())]() mutable {
8 !
592
    // Note: we need to do this because we try to keep the Javascript node around
593
    // because it's slow to recreate.
594
    // But this causes a lot of problems, it'd be better to do like e.g. the faust
595
    // process and entirely recreate a new node, + call update node.
596
    (*recable)();
8 ✔
597

598
    node->m_modelState = std::move(*st);
8 ✔
599
    node->setScript(path, std::move(script));
8 ✔
600
  });
8 ✔
601

602
  SCORE_ASSERT(process().inlets().size() == inls.size());
8 !
603
  SCORE_ASSERT(process().outlets().size() == outls.size());
8 !
604
  return {std::move(inls), std::move(outls), std::move(controlSetups)};
8 ✔
605
}
8 ✔
606

607
}
608
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc