Skip to content

Commit 7977e16

Browse files
committed
ContainerM4A write alac config
1 parent 43d8da6 commit 7977e16

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/AudioTools/AudioCodecs/AudioCodecsBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ class AudioDecoder : public AudioWriter, public AudioInfoSource {
6666
}
6767

6868
/// Some decoders need e.g. a magic cookie to provide the relevant info for decoding
69-
virtual bool setCodecInfo(const uint8_t* data, size_t len){
69+
virtual size_t writeCodecInfo(const uint8_t* data, size_t len){
7070
LOGE("not implemented");
71+
return 0;
7172
}
7273

7374
protected:

src/AudioTools/AudioCodecs/ContainerM4A.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ class ContainerM4A : public ContainerDecoder {
2020

2121
ContainerM4A() = default;
2222

23-
ContainerM4A(MultiDecoder& decoder) : p_decoder(&decoder) {}
23+
ContainerM4A(MultiDecoder& decoder) {
24+
p_decoder = &decoder;
25+
p_decoder->addNotifyAudioChange(*this);
26+
}
2427

2528
void setOutput(AudioStream& out_stream) override {
2629
if (p_decoder != nullptr) p_decoder->setOutput(out_stream);
@@ -88,12 +91,15 @@ class ContainerM4A : public ContainerDecoder {
8891

8992
buffer.resize(buffer_size);
9093

94+
if (p_decoder) p_decoder->begin();
95+
9196
return true;
9297
}
9398

9499
void end() override {
95100
TRACED();
96101
is_active = false;
102+
if (p_decoder) p_decoder->end();
97103
}
98104

99105
size_t write(const uint8_t* data, size_t len) override {
@@ -460,6 +466,13 @@ class ContainerM4A : public ContainerDecoder {
460466

461467
LOGI("ALAC: %d Hz, %d bit, %d ch", info.sample_rate, info.bits_per_sample,
462468
info.channels);
469+
470+
// Notify decoder about the codec info if available
471+
if (p_decoder){
472+
if (p_decoder->selectDecoder(mime())){
473+
p_decoder->writeCodecInfo(alac_config, alac_config_size);
474+
}
475+
}
463476
}
464477

465478
// Handler to identify if a track is audio

0 commit comments

Comments
 (0)