@@ -187,6 +187,7 @@ class CodecConfig : public codec_config_t {
187
187
*/
188
188
class AudioDriver {
189
189
public:
190
+ // / Starts the processing
190
191
virtual bool begin (CodecConfig codecCfg, DriverPins &pins) {
191
192
AD_LOGD (" AudioDriver::begin:pins" );
192
193
p_pins = &pins;
@@ -201,6 +202,7 @@ class AudioDriver {
201
202
setVolume (DRIVER_DEFAULT_VOLUME);
202
203
return result;
203
204
}
205
+ // / changes the configuration
204
206
virtual bool setConfig (CodecConfig codecCfg) {
205
207
codec_cfg = codecCfg;
206
208
if (!init (codec_cfg)) {
@@ -225,7 +227,9 @@ class AudioDriver {
225
227
}
226
228
return result;
227
229
}
230
+ // / Ends the processing: shut down dac and adc
228
231
virtual bool end (void ) { return deinit (); }
232
+ // / Mutes all output lines
229
233
virtual bool setMute (bool enable) = 0;
230
234
// / Mute individual lines: only supported for some rare DACs
231
235
virtual bool setMute (bool mute, int line) {
@@ -235,11 +239,15 @@ class AudioDriver {
235
239
236
240
// / Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
237
241
virtual bool setVolume (int volume) = 0;
242
+ // / Determines the actual volume (range: 0-100)
238
243
virtual int getVolume () = 0;
244
+ // / Defines the input volume (range: 0-100) if supported
239
245
virtual bool setInputVolume (int volume) { return false ; }
246
+ // / Determines if setVolume() is suppored
240
247
virtual bool isVolumeSupported () { return true ; }
248
+ // / Determines if setInputVolume() is supported
241
249
virtual bool isInputVolumeSupported () { return false ; }
242
-
250
+ // / Provides the pin information
243
251
DriverPins &pins () { return *p_pins; }
244
252
245
253
// / Sets the PA Power pin to active or inactive
@@ -1085,14 +1093,24 @@ class AudioDriverWM8978Class : public AudioDriver {
1085
1093
1086
1094
bool begin (CodecConfig codecCfg, DriverPins &pins) override {
1087
1095
bool rc = true ;
1088
- codec_cfg = codecCfg;
1089
1096
auto i2c = pins.getI2CPins (PinFunction::CODEC);
1090
1097
if (!i2c) {
1091
1098
rc = wm8078.begin ();
1092
1099
} else {
1093
1100
auto i2c_pins = i2c.value ();
1094
1101
rc = wm8078.begin (i2c_pins.sda , i2c_pins.scl , i2c_pins.frequency );
1095
1102
}
1103
+
1104
+ setConfig (codecCfg);
1105
+
1106
+ // setup initial default volume
1107
+ setVolume (DRIVER_DEFAULT_VOLUME);
1108
+
1109
+ return rc;
1110
+ }
1111
+
1112
+ bool setConfig (CodecConfig codecCfg) override {
1113
+ codec_cfg = codecCfg;
1096
1114
bool is_dac = codec_cfg.output_device != DAC_OUTPUT_NONE;
1097
1115
bool is_adc = codec_cfg.input_device != ADC_INPUT_NONE;
1098
1116
wm8078.cfgADDA (is_dac, is_adc);
@@ -1111,11 +1129,7 @@ class AudioDriverWM8978Class : public AudioDriver {
1111
1129
int i2s = toI2S (codecCfg.i2s .fmt );
1112
1130
if (i2s < 0 ) return false ;
1113
1131
wm8078.cfgI2S (i2s, bits);
1114
-
1115
- // setup initial default volume
1116
- setVolume (DRIVER_DEFAULT_VOLUME);
1117
-
1118
- return rc;
1132
+ return true ;
1119
1133
}
1120
1134
1121
1135
bool end () override {
0 commit comments