Skip to content

Commit

Permalink
Reset rate estimator whenever iodev is opened
Browse files Browse the repository at this point in the history
Rate estimator is not cleaned up when iodev is closed. This may result
in certain sample rate estimation using stale data.

To solve the issue, always reset the rate estimator whenever iodev is
opened.

BUG=b:315782367
TEST=unit tests

Change-Id: I30cccca08102105e50d8bfefe5cdceb2e03f1919
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5138639
Reviewed-by: Li-Yu Yu <aaronyu@google.com>
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com>
Auto-Submit: Baili Deng <bailideng@google.com>
  • Loading branch information
baili0411 authored and Chromeos LUCI committed Dec 20, 2023
1 parent 1bf3750 commit 0f6d8f0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cras/src/server/cras_iodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,8 @@ int cras_iodev_open(struct cras_iodev* iodev,
return rc;
}
}
// Always reset rate_est to ensure rate estimation correctness.
rate_estimator_reset_rate(iodev->rate_est, iodev->format->frame_rate);

clock_gettime(CLOCK_MONOTONIC_RAW, &beg);
rc = iodev->configure_dev(iodev);
Expand Down

0 comments on commit 0f6d8f0

Please sign in to comment.