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

◆ resolveDynamicDriver()

FL_NO_INLINE fl::shared_ptr< IChannelDriver > fl::Channel::resolveDynamicDriver ( )
private

Cold slow-path helper for showPixels().

Resolve the driver for this channel.

Handles dynamic ChannelManager::selectDriverForChannel() lookup AND the bus-key-miss diagnostics (#2455 / #2459). This is now the only driver-resolution path.

Marked FL_NO_INLINE to keep showPixels() compact – see #2773 item 2.1. Returns nullptr on a hard miss (caller should silently bail).

Handles dynamic ChannelManager::selectDriverForChannel lookup AND the bus-key-miss diagnostic chain. Hoisted out of showPixels so the hot path stays compact – see #2773 item 2.1. This is the only driver-resolution path; there is no pre-bound fast path.

Marked noinline (via FL_NO_INLINE) so the compiler doesn't fold the cold body back into showPixels.

Definition at line 849 of file channel.cpp.hpp.

849 {
850#if defined(FASTLED_DISABLE_DYNAMIC_DRIVER) && FASTLED_DISABLE_DYNAMIC_DRIVER
851 // Body excluded via FASTLED_DISABLE_DYNAMIC_DRIVER (#2926). The
852 // showPixels call site is also gated so this is unreachable; the
853 // empty body lets the linker dead-strip ChannelManager::findDriverByName
854 // and selectDriverForChannel along with this symbol.
855 return {};
856#else
857 // Build busKey only when we actually need it (mBus != AUTO).
858 fl::string busKey;
859 if (mBus != Bus::AUTO) {
861 }
862
863 fl::shared_ptr<IChannelDriver> driver =
865 if (!mSettings.mWorker.isDefault()) {
866 // Explicit worker isolation must never silently fall back to a
867 // different bus or an engine that ignores the requested affinity.
868 if (!driver || (mBus != Bus::AUTO && driver->getName() != busKey) ||
869 !driver->configureWorker(mSettings.mWorker)) {
870 FL_ERROR("Channel: worker configuration rejected - dropping frame");
871 mDriver.reset();
872 return {};
873 }
874 }
875 mDriver = driver;
876
877 // #2455 / #2459: diagnostic when a typed-Bus request is not honored.
878 // Probe via `findDriverByName` (silent) to tell "not enabled", "disabled"
879 // and "cannot handle this chipset" apart; each names its own fix.
880#if FASTLED_LOG_RUNTIME_ENABLED
881 if (mBus != Bus::AUTO && (!driver || driver->getName() != busKey)) {
882 // Repeats once a second while the requested driver is unavailable, so
883 // the problem stays visible for as long as it lasts.
884 const fl::string using_name = driver ? driver->getName()
885 : fl::string::from_literal("nothing (frame dropped)");
886 auto busDriver = ChannelManager::instance().findDriverByName(busKey);
887 if (!busDriver) {
888 FL_WARN_EVERY(1000, "Channel '" << mName << "': driver '" << busKey
889 << "' is not enabled - falling back to " << using_name
890 << ". Fix: FastLED.enable<fl::Bus::" << busKey
891 << ">() (links only this driver) or FastLED.enableAllDrivers().");
892 } else if (!ChannelManager::instance().isDriverEnabled(*busDriver)) {
893 FL_WARN_EVERY(1000, "Channel '" << mName << "': driver '" << busKey
894 << "' is disabled - falling back to " << using_name
895 << ". Fix: FastLED.setDriverEnabled(\"" << busKey
896 << "\", true), or drop the setExclusiveDriver() that disabled it.");
897 } else {
898 FL_WARN_EVERY(1000, "Channel '" << mName << "': driver '" << busKey
899 << "' cannot handle this chipset (bus/chipset mismatch) - falling back to "
900 << using_name << ". Fix: pick a bus that supports this chipset.");
901 }
902 }
903 if (!driver) {
904 FL_ERROR("Channel '" << mName << "': No compatible driver found - cannot transmit");
905 }
906#endif // FASTLED_LOG_RUNTIME_ENABLED — release skips the per-frame
907 // driver->getName() != busKey compare + the silent
908 // findDriverByName probe (used only to differentiate the
909 // FL_ERROR message). The functional return value below is
910 // preserved in both builds. See #2952.
911 return driver;
912#endif // !FASTLED_DISABLE_DYNAMIC_DRIVER
913}
fl::u8 mBusWhich
Definition channel.h:441
bool isSpi() const FL_NO_EXCEPT
Check if this is an SPI chipset.
Definition channel.h:146
ChannelDataPtr mChannelData
Definition channel.h:454
fl::weak_ptr< IChannelDriver > mDriver
Definition channel.h:435
fl::string mName
Definition channel.h:453
ChannelOptions mSettings
Definition channel.h:456
fl::shared_ptr< IChannelDriver > findDriverByName(const fl::string &name) const FL_NO_EXCEPT
Silent counterpart to getDriverByName().
static ChannelManager & instance() FL_NO_EXCEPT
Get the global singleton instance.
fl::shared_ptr< IChannelDriver > selectDriverForChannel(const ChannelDataPtr &data, const fl::string &affinity) FL_NO_EXCEPT
Select best driver for channel data (used by Channel::showPixels)
static string from_literal(const char *literal) FL_NO_EXCEPT
#define FL_WARN_EVERY(MILLIS,...)
Definition log.h:442
#define FL_ERROR(...)
Definition log.h:373
const char * busDriverName(Bus b, fl::u8 which=0, bool spi=false) FL_NO_EXCEPT
Concrete ChannelManager driver name for a portable bus.
Definition bus.h:193
@ AUTO
Definition bus.h:32
WorkerConfig mWorker
Definition options.h:106
constexpr bool isDefault() const FL_NO_EXCEPT

References fl::AUTO, fl::busDriverName(), fl::ChannelManager::findDriverByName(), FL_ERROR, fl::FL_NO_EXCEPT, FL_WARN_EVERY, fl::string::from_literal(), fl::ChannelManager::instance(), isSpi(), mBus, mBusWhich, mChannelData, mDriver, mName, mSettings, and fl::ChannelManager::selectDriverForChannel().

Referenced by showPixels().

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