FastLED 3.9.15
Loading...
Searching...
No Matches

◆ openMp3()

fl::Mp3DecoderPtr fl::FileSystem::openMp3 ( const char * path,
fl::string * error_message = nullptr )

Definition at line 142 of file file_system_codecs.cpp.hpp.

142 {
143 fl::ifstream file = openRead(path);
144 if (!file.is_open()) {
145 if (error_message) { *error_message = "Failed to open file: "; error_message->append(path); }
146 FL_WARN("Failed to open MP3 file: " << path); return fl::Mp3DecoderPtr();
147 }
148 fl::Mp3DecoderPtr decoder = fl::Mp3::createDecoder(error_message);
149 if (!decoder->begin(file.rdbuf())) {
150 fl::string decoder_error; decoder->hasError(&decoder_error);
151 if (error_message) { *error_message = "Failed to initialize MP3 decoder: "; error_message->append(decoder_error); }
152 FL_WARN("Failed to initialize MP3 decoder for: " << path); return fl::Mp3DecoderPtr();
153 }
154 return decoder;
155}
fl::ifstream openRead(const char *path)
static Mp3DecoderPtr createDecoder(fl::string *error_message=nullptr)
Definition mp3.cpp.hpp:400
bool begin(fl::filebuf_ptr stream)
Definition mp3.cpp.hpp:367
bool hasError(fl::string *msg=nullptr) const
Definition mp3.cpp.hpp:379
bool is_open() const
Definition fstream.h:111
filebuf_ptr rdbuf() const
Definition fstream.h:143
string & append(const bitset_fixed< N > &bs) FL_NOEXCEPT
Definition string.h:284
#define FL_WARN(X)
Definition log.h:276
fl::shared_ptr< Mp3Decoder > Mp3DecoderPtr
Definition file_system.h:19

References fl::string::append(), fl::Mp3Decoder::begin(), fl::Mp3::createDecoder(), FL_WARN, fl::Mp3Decoder::hasError(), fl::ifstream::is_open(), openRead(), and fl::ifstream::rdbuf().

+ Here is the call graph for this function: