File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -768,12 +768,16 @@ class ContainerM4A : public ContainerDecoder {
768768 // write the result to the decoder or to the final output
769769 size_t writeResult (uint8_t * data, size_t len) {
770770 // if we have a decoder we only decode the supported type
771+ const char * original_mime = p_decoder->selectedMime ();
771772 if (p_decoder != nullptr ) {
772773 if (!p_decoder->selectDecoder (mime ())) {
773774 LOGE (" Unsupported mime type %s" , mime ());
774775 return 0 ;
775776 }
776- return p_decoder->write (data, len);
777+ size_t result = p_decoder->write (data, len);
778+ // restore original decoder
779+ p_decoder->selectDecoder (original_mime);
780+ return result;
777781 }
778782 // No decoder, just return any result
779783 return p_print->write (data, len);
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ class MultiDecoder : public AudioDecoder {
7272 // / automatically from the determined mime type
7373 bool selectDecoder (const char * mime) {
7474 bool result = false ;
75+ if (mime = nullptr ) return false ;
7576 // do nothing if no change
7677 if (StrView (mime).equals (actual_decoder.mime )) {
7778 is_first = false ;
@@ -81,6 +82,7 @@ class MultiDecoder : public AudioDecoder {
8182 end ();
8283
8384 // find the corresponding decoder
85+ selected_mime = nullptr ;
8486 for (int j = 0 ; j < decoders.size (); j++) {
8587 DecoderInfo info = decoders[j];
8688 if (StrView (info.mime ).equals (mime)) {
@@ -93,12 +95,17 @@ class MultiDecoder : public AudioDecoder {
9395 }
9496 actual_decoder.decoder ->begin ();
9597 result = true ;
98+ selected_mime = mime;
9699 }
97100 }
98101 is_first = false ;
99102 return result;
100103 }
101104
105+ const char * selectedMime () {
106+ return selected_mime;
107+ }
108+
102109 size_t write (const uint8_t * data, size_t len) override {
103110 if (is_first) {
104111 const char * mime = nullptr ;
@@ -150,6 +157,7 @@ class MultiDecoder : public AudioDecoder {
150157 CodecNOP nop;
151158 AbstractURLStream* p_url_stream = nullptr ;
152159 bool is_first = true ;
160+ const char * selected_mime = nullptr ;
153161};
154162
155163} // namespace audio_tools
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ class MimeDetector {
2828 setCheck (" video/MP2T" , checkMP2T);
2929 setCheck (" audio/prs.sid" , checkSID);
3030 setCheck (" audio/mpeg" , checkMP3Ext);
31- setCheck (" audio/aac" , checkAACExt);
3231 setCheck (" audio/m4a" , checkM4A);
32+ setCheck (" audio/aac" , checkAACExt);
3333 }
3434
3535 bool begin () {
You can’t perform that action at this time.
0 commit comments