@@ -9,22 +9,24 @@ namespace audio_tools {
9
9
10
10
/* *
11
11
* @brief Manage multiple decoders: the actual decoder is only opened when it
12
- * has been selected.
12
+ * has been selected. The relevant decoder is determined dynamically at the first
13
+ * write from the determined mime type. You can add your own custom mime type
14
+ * determination logic.
13
15
* @ingroup codecs
14
16
* @ingroup decoder
15
17
* @author Phil Schatzmann
16
18
* @copyright GPLv3
17
19
*/
18
20
class MultiDecoder : public AudioDecoder {
19
- //
20
- bool begin () {
21
+ // / Enables the automatic mime type determination
22
+ bool begin () override {
21
23
mime_detector.begin ();
22
24
is_first = true ;
23
25
return true ;
24
26
}
25
27
26
28
// / closes the actual decoder
27
- void end () {
29
+ void end () override {
28
30
if (actual_decoder.decoder != nullptr && actual_decoder.is_open ) {
29
31
actual_decoder.decoder ->end ();
30
32
}
@@ -40,7 +42,7 @@ class MultiDecoder : public AudioDecoder {
40
42
decoders.push_back (info);
41
43
}
42
44
43
- // selects the actual decoder by mime type
45
+ // / selects the actual decoder by mime type - this is usually called automatically from the determined mime type
44
46
bool selectDecoder (const char * mime) {
45
47
bool result = false ;
46
48
// do nothing if no change
@@ -63,7 +65,7 @@ class MultiDecoder : public AudioDecoder {
63
65
return result;
64
66
}
65
67
66
- virtual size_t write (const uint8_t * data, size_t len) {
68
+ size_t write (const uint8_t * data, size_t len) override {
67
69
if (is_first) {
68
70
// select the decoder based on the detemined mime type
69
71
mime_detector.write ((uint8_t *)data, len);
0 commit comments