ESP32-specific audio input creation function
| 21 | |
| 22 | // ESP32-specific audio input creation function |
| 23 | fl::shared_ptr<audio::IInput> |
| 24 | esp32_create_audio_input(const audio::Config &config, |
| 25 | fl::string *error_message) FL_NOEXCEPT { |
| 26 | if (config.is<audio::ConfigI2S>()) { |
| 27 | #if FASTLED_ESP32_I2S_SUPPORTED |
| 28 | FL_WARN("Creating I2S standard mode audio source"); |
| 29 | audio::ConfigI2S std_config = config.get<audio::ConfigI2S>(); |
| 30 | fl::shared_ptr<audio::IInput> out = |
| 31 | fl::make_shared<fl::I2S_Audio>(std_config); |
| 32 | return out; |
| 33 | #else |
| 34 | const char *ERROR_MESSAGE = |
| 35 | "I2S audio not supported on this ESP32 variant (no I2S hardware)"; |
| 36 | FL_WARN(ERROR_MESSAGE); |
| 37 | if (error_message) { |
| 38 | *error_message = ERROR_MESSAGE; |
| 39 | } |
| 40 | return fl::make_shared<fl::Null_Audio>(); |
| 41 | #endif |
| 42 | } else if (config.is<audio::ConfigPdm>()) { |
| 43 | #if FASTLED_ESP32_PDM_SUPPORTED |
| 44 | FL_WARN("Creating PDM mode audio source"); |
| 45 | audio::ConfigPdm pdm_config = config.get<audio::ConfigPdm>(); |
| 46 | fl::shared_ptr<audio::IInput> out = |
| 47 | fl::make_shared<fl::PDM_Audio>(pdm_config); |
| 48 | return out; |
| 49 | #else |
| 50 | const char *ERROR_MESSAGE = "PDM audio not supported on this ESP32 " |
| 51 | "variant (no PDM RX hardware)"; |
| 52 | FL_WARN(ERROR_MESSAGE); |
| 53 | if (error_message) { |
| 54 | *error_message = ERROR_MESSAGE; |
| 55 | } |
| 56 | return fl::make_shared<fl::Null_Audio>(); |
| 57 | #endif |
| 58 | } |
| 59 | const char *ERROR_MESSAGE = "Unsupported audio configuration"; |
| 60 | FL_WARN(ERROR_MESSAGE); |
| 61 | if (error_message) { |
| 62 | *error_message = ERROR_MESSAGE; |
| 63 | } |
| 64 | return fl::make_shared<fl::Null_Audio>(); |
| 65 | } |
| 66 | |
| 67 | } // namespace fl |
no outgoing calls
no test coverage detected