@@ -157,15 +157,24 @@ void process_uaol_feedback(struct comp_dev *dev, struct dai_data *dd)
157157 return ;
158158 }
159159
160- /* Let's limit the maximum drift to a reasonable value to prevent significant
161- * audio distortion when, for some reason, the reported drift is quite big.
160+ /* Let's do a sanity check first to see if the received value looks valid.
161+ * Then limit the maximum drift to a reasonable value to prevent significant
162+ * audio distortion when, for some reason, the reported drift is quite large.
162163 */
163- #define MAX_UAOL_DRIFT_HZ 6
164+ #define REJECT_DRIFT_HZ 1000
165+ #define CLIP_DRIFT_HZ 6
164166
165167 int drift = freq - dd -> ipc_config .sampling_frequency ;
166- if (drift < - MAX_UAOL_DRIFT_HZ || drift > MAX_UAOL_DRIFT_HZ ) {
167- comp_warn (dev , "Unreasonable UAOL feedback freq value: %d, drift: %d" , freq , drift );
168- drift = MAX (- MAX_UAOL_DRIFT_HZ , MIN (drift , MAX_UAOL_DRIFT_HZ ));
168+
169+ if (drift < - REJECT_DRIFT_HZ || drift > REJECT_DRIFT_HZ ) {
170+ comp_err (dev , "Weird UAOL feedback freq value: %d, drift: %d. Rejected!" ,
171+ freq , drift );
172+ return ;
173+ }
174+ if (drift < - CLIP_DRIFT_HZ || drift > CLIP_DRIFT_HZ ) {
175+ comp_warn (dev , "Unreasonable UAOL feedback freq value: %d, drift: %d. Clipped!" ,
176+ freq , drift );
177+ drift = MAX (- CLIP_DRIFT_HZ , MIN (drift , CLIP_DRIFT_HZ ));
169178 }
170179
171180 dd -> uaol .feedback_drift = drift ;
0 commit comments