@@ -46,6 +46,16 @@ class CodecConfig : public codec_config_t {
46
46
i2s.mode = MODE_SLAVE;
47
47
}
48
48
49
+ // / Compare all attributes but ignore sample rate
50
+ bool equalsExRate (CodecConfig alt){
51
+ return (input_device == alt.input_device &&
52
+ output_device == alt.output_device &&
53
+ i2s.bits == alt.i2s .bits &&
54
+ i2s.channels == alt.i2s .channels &&
55
+ i2s.fmt == alt.i2s .fmt &&
56
+ i2s.mode == alt.i2s .mode );
57
+ }
58
+
49
59
// / Returns bits per sample as number
50
60
int getBitsNumeric () {
51
61
switch (i2s.bits ) {
@@ -486,20 +496,18 @@ class AudioDriverCS42448Class : public AudioDriver {
486
496
// setup pins
487
497
pins.begin ();
488
498
// setup ad1938
489
- cs42448.begin (codecCfg , getI2C (), getI2CAddress ());
499
+ cs42448.begin (cfg , getI2C (), getI2CAddress ());
490
500
cs42448.setMute (false );
491
501
return true ;
492
502
}
493
503
virtual bool setConfig (CodecConfig codecCfg) {
494
504
bool result = true ;
495
- if (codecCfg.input_device == cfg.input_device &&
496
- codecCfg.output_device == cfg.output_device &&
497
- codecCfg.i2s .bits == cfg.i2s .bits &&
498
- codecCfg.i2s .channels == cfg.i2s .channels &&
499
- codecCfg.i2s .fmt == cfg.i2s .fmt && codecCfg.i2s .mode == cfg.i2s .mode ) {
505
+ if (codecCfg.equalsExRate (cfg)) {
500
506
// just update the rate
501
507
if (cfg.i2s .rate != cfg.i2s .rate ) {
508
+ cs42448.setMute (true );
502
509
cs42448.setSampleRate (codecCfg.getRateNumeric ());
510
+ cs42448.setMute (false );
503
511
}
504
512
} else {
505
513
result = begin (codecCfg, *p_pins);
0 commit comments