File tree Expand file tree Collapse file tree 8 files changed +250
-74
lines changed
src/AudioTools/AudioCodecs
tests-cmake/codec/container-m4a Expand file tree Collapse file tree 8 files changed +250
-74
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ class DecoderALAC : public AudioDecoder {
42
42
DecoderALAC (int frameSize = kALACDefaultFrameSize ) {
43
43
// this is used when setCodecConfig() is not called with encoder info
44
44
setFrameSize (frameSize);
45
- setDefaultConfig ();
45
+ // setDefaultConfig();
46
46
}
47
47
48
48
// define ALACSpecificConfig
@@ -86,14 +86,13 @@ class DecoderALAC : public AudioDecoder {
86
86
dec.mConfig .bitDepth = from.bits_per_sample ;
87
87
}
88
88
89
+
89
90
// / we expect the write is called for a complete frame!
90
91
size_t write (const uint8_t * encodedFrame, size_t encodedLen) override {
91
92
LOGD (" DecoderALAC::write: %d" , (int )encodedLen);
92
- // Safety check
93
- if (!is_init) {
94
- LOGE (" Decoder not initialized" );
95
- return 0 ;
96
- }
93
+ // Make sure we have a config: we can't do this in begin because the setConfig()
94
+ // might be called after begin()
95
+ if (!is_init) setDefaultConfig ();
97
96
98
97
// Make sure we have the output buffer set up
99
98
if (result_buffer.size () != outputBufferSize ()) {
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ class CopyDecoder : public AudioDecoder {
36
36
37
37
size_t write (const uint8_t *data, size_t len) {
38
38
TRACED ();
39
+ if (pt_print == nullptr ) {
40
+ LOGE (" No output stream defined for CopyDecoder" );
41
+ return 0 ;
42
+ }
39
43
return pt_print->write ((uint8_t *)data,len);
40
44
}
41
45
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ContainerM4A : public ContainerDecoder {
37
37
* @brief Set the output stream for decoded or raw audio.
38
38
* @param out_stream Output AudioStream.
39
39
*/
40
- void setOutput (AudioStream & out_stream) override {
40
+ void setOutput (Print & out_stream) override {
41
41
if (p_decoder != nullptr ) p_decoder->setOutput (out_stream);
42
42
ContainerDecoder::setOutput (out_stream);
43
43
}
@@ -118,7 +118,9 @@ class ContainerM4A : public ContainerDecoder {
118
118
!self->is_magic_cookie_processed ) {
119
119
auto & magic_cookie = self->demux .getALACMagicCookie ();
120
120
if (magic_cookie.size () > 0 ) {
121
- dec.setCodecConfig (magic_cookie.data (), magic_cookie.size ());
121
+ if (!dec.setCodecConfig (magic_cookie.data (), magic_cookie.size ())){
122
+ LOGE (" Failed to set ALAC magic cookie for decoder: %s" , dec.selectedMime ());
123
+ }
122
124
}
123
125
self->is_magic_cookie_processed = true ;
124
126
}
You can’t perform that action at this time.
0 commit comments