@@ -101,25 +101,27 @@ class I2SCodecStream : public AudioStream {
101
101
// / updates the sample rate dynamically
102
102
virtual void setAudioInfo (AudioInfo info) {
103
103
TRACEI ();
104
- // save volume if possible
105
104
AudioStream::setAudioInfo (info);
106
105
i2s.setAudioInfo (info);
107
106
107
+ // return if we we are not ready
108
108
if (!is_active || p_board == nullptr ) {
109
109
return ;
110
110
}
111
111
112
+ // return if there is nothing to do
112
113
if (cfg.sample_rate == info.sample_rate &&
113
114
cfg.bits_per_sample == info.bits_per_sample &&
114
115
cfg.channels == info.channels ) {
115
116
return ;
116
117
}
117
118
119
+ // update cfg
118
120
cfg.sample_rate = info.sample_rate ;
119
121
cfg.bits_per_sample = info.bits_per_sample ;
120
122
cfg.channels = info.channels ;
121
123
122
- // update values in codec
124
+ // update codec_cfg
123
125
codec_cfg.i2s .bits = toCodecBits (cfg.bits_per_sample );
124
126
codec_cfg.i2s .rate = toRate (cfg.sample_rate );
125
127
p_board->setConfig (codec_cfg);
@@ -220,15 +222,7 @@ class I2SCodecStream : public AudioStream {
220
222
}
221
223
}
222
224
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
-
230
225
bool beginCodec (I2SCodecConfig info) {
231
- CodecConfig codec_cfg;
232
226
codec_cfg.sd_active = info.sd_active ;
233
227
codec_cfg.input_device = info.input_device ;
234
228
LOGD (" input: %d" , info.input_device );
0 commit comments