Skip to content

Commit 01b6e9c

Browse files
committed
I2SCodecstream cleanup
1 parent 0e64e78 commit 01b6e9c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/AudioLibs/I2SCodecStream.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,27 @@ class I2SCodecStream : public AudioStream {
101101
/// updates the sample rate dynamically
102102
virtual void setAudioInfo(AudioInfo info) {
103103
TRACEI();
104-
// save volume if possible
105104
AudioStream::setAudioInfo(info);
106105
i2s.setAudioInfo(info);
107106

107+
// return if we we are not ready
108108
if (!is_active || p_board == nullptr) {
109109
return;
110110
}
111111

112+
// return if there is nothing to do
112113
if (cfg.sample_rate == info.sample_rate &&
113114
cfg.bits_per_sample == info.bits_per_sample &&
114115
cfg.channels == info.channels) {
115116
return;
116117
}
117118

119+
// update cfg
118120
cfg.sample_rate = info.sample_rate;
119121
cfg.bits_per_sample = info.bits_per_sample;
120122
cfg.channels = info.channels;
121123

122-
// update values in codec
124+
// update codec_cfg
123125
codec_cfg.i2s.bits = toCodecBits(cfg.bits_per_sample);
124126
codec_cfg.i2s.rate = toRate(cfg.sample_rate);
125127
p_board->setConfig(codec_cfg);
@@ -220,15 +222,7 @@ class I2SCodecStream : public AudioStream {
220222
}
221223
}
222224

223-
bool beginCodec(AudioInfo info) {
224-
cfg.sample_rate = info.sample_rate;
225-
cfg.bits_per_sample = info.bits_per_sample;
226-
cfg.channels = info.channels;
227-
return beginCodec(cfg);
228-
}
229-
230225
bool beginCodec(I2SCodecConfig info) {
231-
CodecConfig codec_cfg;
232226
codec_cfg.sd_active = info.sd_active;
233227
codec_cfg.input_device = info.input_device;
234228
LOGD("input: %d", info.input_device);

0 commit comments

Comments
 (0)