FastLED 3.10.10
Loading...
Searching...
No Matches

◆ selectDriverForChannel()

fl::shared_ptr< IChannelDriver > fl::ChannelManager::selectDriverForChannel ( const ChannelDataPtr & data,
const fl::string & affinity )

Select best driver for channel data (used by Channel::showPixels)

Parameters
dataChannel data to route (chipset configuration)
affinityEngine affinity name (empty = no affinity, dynamic selection)
Returns
Shared pointer to selected driver, or nullptr if none compatible
Note
Iterates drivers by priority (already sorted descending) and returns first that canHandle()
This is called lazily in Channel::showPixels() if no driver is bound

Definition at line 425 of file manager.cpp.hpp.

425 {
426 if (!data) {
427 FL_ERROR("ChannelManager::selectDriverForChannel() - Null channel data");
428 return fl::shared_ptr<IChannelDriver>();
429 }
430
431 // If affinity is specified, look up by name. Misses fall through to
432 // priority dispatch below — per-frame logging is intentionally silent
433 // here because `Channel::showPixels` now emits a one-shot, actionable
434 // FL_ERROR with the enableDrivers<...>() / enableAllDrivers() hint
435 // (#2455). Use `findDriverByName` (silent) rather than `getDriverByName`
436 // (logs on miss) so the silent fall-through actually IS silent.
437 do {
438 if (affinity.empty()) {
439 break;
440 }
441 auto driver = findDriverByName(affinity);
442 if (!driver) {
443 break; // diagnostic emitted at the channel layer
444 }
445 if (!driver->canHandle(data)) {
446 FL_WARN_ONCE("ChannelManager: Affinity driver '" << affinity << "' cannot handle channel data (chipset/bus mismatch). Falling back to AUTO/priority dispatch.");
447 break;
448 }
449 if (!isDriverEnabled(*driver)) {
450 break; // disabled: fall back to an enabled driver (channel layer warns)
451 }
452 return driver;
453 } while (false);
454
455 auto driver = selectEnabledDriverForChannel(data);
456 if (!driver) {
457 FL_ERROR("ChannelManager: No compatible driver found for channel data");
458 }
459 return driver;
460}
fl::shared_ptr< IChannelDriver > selectEnabledDriverForChannel(const ChannelDataPtr &data) const FL_NO_EXCEPT
Highest-priority enabled driver that can handle data, or null.
fl::shared_ptr< IChannelDriver > findDriverByName(const fl::string &name) const FL_NO_EXCEPT
Silent counterpart to getDriverByName().
bool isDriverEnabled(const char *name) const FL_NO_EXCEPT
Check if a driver is enabled by name.
bool empty() const FL_NO_EXCEPT
#define FL_WARN_ONCE(...)
Definition log.h:439
#define FL_ERROR(...)
Definition log.h:373

References findDriverByName(), FL_ERROR, fl::FL_NO_EXCEPT, FL_WARN_ONCE, isDriverEnabled(), and selectEnabledDriverForChannel().

Referenced by fl::Channel::resolveDynamicDriver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: