Skip to content

Commit e937240

Browse files
committed
M4A Support
1 parent bfff22b commit e937240

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/AACDecoderHelix.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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

src/CommonHelix.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)