FastLED 3.10.8
Loading...
Searching...
No Matches

◆ openMp3()

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

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

143 {
144 fl::ifstream file = openRead(path);
145 if (!file.is_open()) {
146 if (error_message) { *error_message = "Failed to open file: "; error_message->append(path); }
147 FL_WARN("Failed to open MP3 file: " << path); return fl::Mp3DecoderPtr();
148 }
149 fl::Mp3DecoderPtr decoder = fl::Mp3::createDecoder(error_message);
150 if (!decoder->begin(file.rdbuf())) {
151 fl::string decoder_error; decoder->hasError(&decoder_error);
152 if (error_message) { *error_message = "Failed to initialize MP3 decoder: "; error_message->append(decoder_error); }
153 FL_WARN("Failed to initialize MP3 decoder for: " << path); return fl::Mp3DecoderPtr();
154 }
155 return decoder;
156}
fl::ifstream openRead(const char *path) FL_NO_EXCEPT
Definition fs.cpp.hpp:170
static Mp3DecoderPtr createDecoder(fl::string *error_message=nullptr) FL_NO_EXCEPT
Definition mp3.cpp.hpp:628
bool hasError(fl::string *msg=nullptr) const FL_NO_EXCEPT
Definition mp3.cpp.hpp:607
bool begin(fl::filebuf_ptr stream) FL_NO_EXCEPT
Definition mp3.cpp.hpp:595
bool is_open() const FL_NO_EXCEPT
Definition fstream.h:111
filebuf_ptr rdbuf() const FL_NO_EXCEPT
Definition fstream.h:143
string & append(const bitset_fixed< N > &bs) FL_NO_EXCEPT
Definition string.h:293
#define FL_WARN(...)
Definition log.h:437
fl::shared_ptr< Mp3Decoder > Mp3DecoderPtr
Definition fs.h:27

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

+ Here is the call graph for this function: