@@ -62,6 +62,7 @@ class MimeDetector : public MimeSource {
6262 public:
6363 MimeDetector (bool setupDefault = true ) {
6464 if (setupDefault) {
65+ setCheck (" audio/vnd.wave; codecs=ms-adpcm" , checkWAV_ADPCM);
6566 setCheck (" audio/vnd.wave" , checkWAV);
6667 setCheck (" audio/flac" , checkFLAC);
6768 setCheck (" audio/ogg; codecs=flac" , checkOggFLAC);
@@ -83,12 +84,11 @@ class MimeDetector : public MimeSource {
8384 }
8485
8586 // / Clears the actual mime and resets the state
86- void end (){
87+ void end () {
8788 actual_mime = nullptr ;
8889 is_first = true ;
8990 }
9091
91-
9292 // / write the header to determine the mime
9393 size_t write (uint8_t * data, size_t len) {
9494 actual_mime = default_mime;
@@ -97,7 +97,8 @@ class MimeDetector : public MimeSource {
9797 }
9898
9999 // / adds/updates the checking logic for the indicated mime
100- void setCheck (const char * mime, bool (*check)(uint8_t * start, size_t len), bool isActvie = true) {
100+ void setCheck (const char * mime, bool (*check)(uint8_t * start, size_t len),
101+ bool isActvie = true) {
101102 StrView mime_str{mime};
102103 for (int j = 0 ; j < checks.size (); j++) {
103104 Check l_check = checks[j];
@@ -157,6 +158,17 @@ class MimeDetector : public MimeSource {
157158 return mp3.isValid (start, len);
158159 }
159160
161+ static bool checkWAV_ADPCM (uint8_t * start, size_t len) {
162+ if (memcmp (start, " RIFF" , 4 ) != 0 ) return false ;
163+ WAVHeader header;
164+ header.write (start, len);
165+ if (!header.parse ()) return false ;
166+ if (header.audioInfo ().format == AudioFormat::ADPCM) {
167+ return true ;
168+ }
169+ return false ;
170+ }
171+
160172 static bool checkWAV (uint8_t * start, size_t len) {
161173 return memcmp (start, " RIFF" , 4 ) == 0 ;
162174 }
@@ -292,7 +304,8 @@ class MimeDetector : public MimeSource {
292304 for (auto & check : checks) {
293305 if (StrView (check.mime ).startsWith (mimePrefix)) {
294306 check.is_active = active;
295- LOGI (" MimeDetector for %s: %s" , check.mime , check.is_active ? " active" : " inactive" );
307+ LOGI (" MimeDetector for %s: %s" , check.mime ,
308+ check.is_active ? " active" : " inactive" );
296309 result++;
297310 }
298311 }
0 commit comments