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 {
4242 DecoderALAC (int frameSize = kALACDefaultFrameSize ) {
4343 // this is used when setCodecConfig() is not called with encoder info
4444 setFrameSize (frameSize);
45- setDefaultConfig ();
45+ // setDefaultConfig();
4646 }
4747
4848 // define ALACSpecificConfig
@@ -86,14 +86,13 @@ class DecoderALAC : public AudioDecoder {
8686 dec.mConfig .bitDepth = from.bits_per_sample ;
8787 }
8888
89+
8990 // / we expect the write is called for a complete frame!
9091 size_t write (const uint8_t * encodedFrame, size_t encodedLen) override {
9192 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 ();
9796
9897 // Make sure we have the output buffer set up
9998 if (result_buffer.size () != outputBufferSize ()) {
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ class CopyDecoder : public AudioDecoder {
3636
3737 size_t write (const uint8_t *data, size_t len) {
3838 TRACED ();
39+ if (pt_print == nullptr ) {
40+ LOGE (" No output stream defined for CopyDecoder" );
41+ return 0 ;
42+ }
3943 return pt_print->write ((uint8_t *)data,len);
4044 }
4145
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ContainerM4A : public ContainerDecoder {
3737 * @brief Set the output stream for decoded or raw audio.
3838 * @param out_stream Output AudioStream.
3939 */
40- void setOutput (AudioStream & out_stream) override {
40+ void setOutput (Print & out_stream) override {
4141 if (p_decoder != nullptr ) p_decoder->setOutput (out_stream);
4242 ContainerDecoder::setOutput (out_stream);
4343 }
@@ -118,7 +118,9 @@ class ContainerM4A : public ContainerDecoder {
118118 !self->is_magic_cookie_processed ) {
119119 auto & magic_cookie = self->demux .getALACMagicCookie ();
120120 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+ }
122124 }
123125 self->is_magic_cookie_processed = true ;
124126 }
You can’t perform that action at this time.
0 commit comments