File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed
Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ class AACDecoderHelix : public CommonHelix {
6868 return max_pcm_size == 0 ? AAC_MAX_OUTPUT_SIZE : max_pcm_size;
6969 }
7070
71+ // / Used by M3A format
72+ void setAudioInfo (int channels, int samplerate) {
73+ memset (&aacFrameInfo, 0 , sizeof (AACFrameInfo));
74+ aacFrameInfo.nChans = channels;
75+ // aacFrameInfo.bitsPerSample = bits; not used
76+ aacFrameInfo.sampRateCore = samplerate;
77+ aacFrameInfo.profile = AAC_PROFILE_LC;
78+ AACSetRawBlockParams (decoder, 0 , &aacFrameInfo);
79+ }
80+
81+
7182 protected:
7283 HAACDecoder decoder = nullptr ;
7384 AACDataCallback pcmCallback = nullptr ;
@@ -85,7 +96,7 @@ class AACDecoderHelix : public CommonHelix {
8596
8697 // / finds the sync word in the buffer
8798 int findSynchWord (int offset=0 ) override {
88- int result = AACFindSyncWord (frame_buffer+offset, buffer_size)+offset ;
99+ int result = AACFindSyncWord (frame_buffer+offset, buffer_size); ;
89100 return result < 0 ? result : result + offset;
90101 }
91102
Original file line number Diff line number Diff line change @@ -94,17 +94,23 @@ class CommonHelix {
9494 LOG_HELIX (Info," allocating frame_buffer with %zu bytes" , maxFrameSize ());
9595 frame_buffer = new uint8_t [maxFrameSize ()];
9696 }
97- if (pcm_buffer == nullptr ) {
98- LOG_HELIX (Info," allocating pcm_buffer with %zu bytes" , maxPCMSize ());
99- pcm_buffer = new short [maxPCMSize ()];
100- }
10197 memset (frame_buffer,0 , maxFrameSize ());
98+ if (frame_buffer==nullptr ){
99+ LOG_HELIX (Error, " Not enough memory for buffers" );
100+ active = false ;
101+ return ;
102+ }
103+ }
104+
105+ if (pcm_buffer == nullptr ) {
106+ LOG_HELIX (Info," allocating pcm_buffer with %zu bytes" , maxPCMSize ());
107+ pcm_buffer = new short [maxPCMSize ()];
102108 }
103- if (pcm_buffer==nullptr || frame_buffer== nullptr ){
109+ if (pcm_buffer==nullptr ){
104110 LOG_HELIX (Error, " Not enough memory for buffers" );
105111 active = false ;
106112 return ;
107- }
113+ }
108114 memset (pcm_buffer,0 , maxPCMSize ());
109115 active = true ;
110116 }
You can’t perform that action at this time.
0 commit comments