| 447 | } |
| 448 | |
| 449 | void Channel::showPixels(PixelController<RGB, 1, 0xFFFFFFFF> &pixels) { |
| 450 | FL_SCOPED_TRACE; |
| 451 | |
| 452 | // Safety check: don't modify buffer if driver is currently transmitting it |
| 453 | if (mChannelData->isInUse()) { |
| 454 | FL_WARN("Channel '" << mName << "': showPixels() called while mChannelData is in use by driver, attempting to wait"); |
| 455 | auto driver = mDriver.lock(); |
| 456 | if (!driver) { |
| 457 | FL_ERROR("Channel '" << mName << "': No driver bound yet the mChannelData is in use - cannot transmit"); |
| 458 | return; |
| 459 | } |
| 460 | // wait until the driver is in a READY state. |
| 461 | bool ok = driver->waitForReady(); |
| 462 | if (!ok) { |
| 463 | FL_ERROR("Channel '" << mName << "': Timeout occurred while waiting for driver to become READY"); |
| 464 | return; |
| 465 | } |
| 466 | FL_WARN("Channel '" << mName << "': Engine became READY after waiting"); |
| 467 | } |
| 468 | |
| 469 | // Phase 5b of #2428: if the driver was pre-bound via setDriver() (legacy |
| 470 | // addLeds<>-style controllers naming BusTraits<Bus::X>::instancePtr() in |
| 471 | // their constructor), bypass ChannelManager entirely. Channels created via |
| 472 | // the manager-based API (Channel::create(cfg) without affinity) keep their |
| 473 | // existing per-frame re-selection so users can swap drivers at runtime. |
| 474 | // |
| 475 | // **Fast path (#2773 item 2.1):** the legacy `addLeds<NEOPIXEL>` flow is |
| 476 | // by far the hot per-frame path on stock Blink. It needs no busKey |
| 477 | // construction, no dynamic driver lookup, no busKey-miss diagnostics, |
| 478 | // and no fallback `FL_ERROR` reporting — the driver was already pre-bound |
| 479 | // in the controller's constructor. Pulling all of that boilerplate out |
| 480 | // of `showPixels` lets the compiler keep the hot path compact and lets |
| 481 | // the slow path's `fl::string` ops / `ChannelManager::selectDriverForChannel` |
| 482 | // / diagnostic literals tree-shake on the slow-path branch's coldness. |
| 483 | fl::shared_ptr<IChannelDriver> driver; |
| 484 | if (mDriverPreBound) { |
| 485 | driver = mDriver.lock(); |
| 486 | if (!driver) { |
| 487 | // Pre-bound driver got destroyed (singleton shutdown, etc.). Silent |
| 488 | // bail — this is unrecoverable from showPixels. |
| 489 | return; |
| 490 | } |
| 491 | } else { |
| 492 | #if !defined(FASTLED_DISABLE_DYNAMIC_DRIVER) || !FASTLED_DISABLE_DYNAMIC_DRIVER |
| 493 | driver = resolveDynamicDriver(); |
| 494 | if (!driver) { |
| 495 | return; |
| 496 | } |
| 497 | #else |
| 498 | // Dynamic-driver lookup gated out via FASTLED_DISABLE_DYNAMIC_DRIVER |
| 499 | // (#2926). The else branch is dead at runtime for every legacy |
| 500 | // `addLeds<>` flavor — those pre-bind their driver in the ctor. The |
| 501 | // gate lets `--gc-sections` drop the resolveDynamicDriver body plus |
| 502 | // the ChannelManager::findDriverByName / selectDriverForChannel |
| 503 | // chain (~400-900 B). Channels created via `Channel::create(cfg)` |
| 504 | // without a pre-bound driver silently emit nothing under this flag — |
| 505 | // user accepts the constraint. |
| 506 | return; |
nothing calls this directly
no test coverage detected