@@ -212,6 +212,12 @@ inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int f
212
212
// update source output's reference count
213
213
it->fromComponent ->_DecRefs ( it->fromOutput );
214
214
215
+ // clear input
216
+ for ( auto & inputBus : _inputBuses )
217
+ {
218
+ inputBus.ClearValue ( toInput );
219
+ }
220
+
215
221
// replace wire
216
222
it->fromComponent = fromComponent.get ();
217
223
it->fromOutput = fromOutput;
@@ -238,6 +244,13 @@ inline void Component::DisconnectInput( int inputNo )
238
244
// update source output's reference count
239
245
it->fromComponent ->_DecRefs ( it->fromOutput );
240
246
247
+ // clear input
248
+ for ( auto & inputBus : _inputBuses )
249
+ {
250
+ inputBus.ClearValue ( inputNo );
251
+ }
252
+
253
+ // remove wire
241
254
_inputWires.erase ( it );
242
255
}
243
256
}
@@ -253,19 +266,32 @@ inline void Component::DisconnectInput( const Component::SPtr& fromComponent )
253
266
// update source output's reference count
254
267
fromComponent->_DecRefs ( it->fromOutput );
255
268
269
+ // clear input
270
+ for ( auto & inputBus : _inputBuses )
271
+ {
272
+ inputBus.ClearValue ( it->toInput );
273
+ }
274
+
275
+ // remove wire
256
276
it = _inputWires.erase ( it );
257
277
}
258
278
}
259
279
260
280
inline void Component::DisconnectAllInputs ()
261
281
{
262
- // remove all wires from _inputWires
282
+ // update all source output reference counts
263
283
for ( const auto & wire : _inputWires )
264
284
{
265
- // update source output's reference count
266
285
wire.fromComponent ->_DecRefs ( wire.fromOutput );
267
286
}
268
287
288
+ // clear all inputs
289
+ for ( auto & inputBus : _inputBuses )
290
+ {
291
+ inputBus.ClearAllValues ();
292
+ }
293
+
294
+ // remove a;; wires
269
295
_inputWires.clear ();
270
296
}
271
297
@@ -359,46 +385,34 @@ inline int Component::GetBufferCount() const
359
385
inline void Component::Tick ( int bufferNo )
360
386
{
361
387
auto & inputBus = _inputBuses[bufferNo];
362
- auto & outputBus = _outputBuses[bufferNo];
363
-
364
- // clear inputs
365
- inputBus.ClearAllValues ();
366
388
367
389
for ( const auto & wire : _inputWires )
368
390
{
369
391
// get new inputs from incoming components
370
392
wire.fromComponent ->_GetOutput ( bufferNo, wire.fromOutput , wire.toInput , inputBus );
371
393
}
372
394
373
- // clear outputs
374
- outputBus.ClearAllValues ();
375
-
376
395
if ( _bufferCount != 1 && _processOrder == ProcessOrder::InOrder )
377
396
{
378
397
// wait for our turn to process
379
398
_WaitForRelease ( bufferNo );
380
399
381
400
// call Process_() with newly aquired inputs
382
- Process_ ( inputBus, outputBus );
401
+ Process_ ( inputBus, _outputBuses[bufferNo] );
383
402
384
403
// signal that we're done processing
385
404
_ReleaseNextBuffer ( bufferNo );
386
405
}
387
406
else
388
407
{
389
408
// call Process_() with newly aquired inputs
390
- Process_ ( inputBus, outputBus );
409
+ Process_ ( inputBus, _outputBuses[bufferNo] );
391
410
}
392
411
}
393
412
394
413
inline void Component::TickParallel ( int bufferNo )
395
414
{
396
415
auto & inputBus = _inputBuses[bufferNo];
397
- auto & outputBus = _outputBuses[bufferNo];
398
-
399
- // clear inputs and outputs
400
- inputBus.ClearAllValues ();
401
- outputBus.ClearAllValues ();
402
416
403
417
for ( const auto & wire : _inputWires )
404
418
{
@@ -412,15 +426,15 @@ inline void Component::TickParallel( int bufferNo )
412
426
_WaitForRelease ( bufferNo );
413
427
414
428
// call Process_() with newly aquired inputs
415
- Process_ ( inputBus, outputBus );
429
+ Process_ ( inputBus, _outputBuses[bufferNo] );
416
430
417
431
// signal that we're done processing
418
432
_ReleaseNextBuffer ( bufferNo );
419
433
}
420
434
else
421
435
{
422
436
// call Process_() with newly aquired inputs
423
- Process_ ( inputBus, outputBus );
437
+ Process_ ( inputBus, _outputBuses[bufferNo] );
424
438
}
425
439
426
440
// signal that our outputs are ready
@@ -542,6 +556,7 @@ inline void Component::_GetOutput( int bufferNo, int fromOutput, int toInput, DS
542
556
543
557
if ( !signal.has_value () )
544
558
{
559
+ toBus.ClearValue ( toInput );
545
560
return ;
546
561
}
547
562
@@ -575,6 +590,7 @@ inline void Component::_GetOutputParallel( int bufferNo, int fromOutput, int toI
575
590
576
591
if ( !signal.has_value () )
577
592
{
593
+ toBus.ClearValue ( toInput );
578
594
return ;
579
595
}
580
596
0 commit comments