-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
struct Rav1dState
: Split out the fields of Rav1dContext
that are …
…mutated on the main thread and put them in a `Mutex` (#1179) Our previous code where we passed a `&Rav1dContext` to the worker threads and mutated the `&mut Rav1dContext` through `DAV1D_API`s like `fn rav1d_flush` was unsound, as we were mutating `Rav1dContext` while a `&Rav1dContext` exists. This moves all of those fields mutated on the main thread from the `DAV1D_API`s into `Rav1dState`, and then puts `Rav1dState` into a `Mutex` (`.try_lock()`ed) into `Rav1dContext`. We only need to `.try_lock()` it a few places in the `DAV1D_API`s; otherwise, we can just pass `c: &Rav1dContext, state: &mut Rav1dState` args to most `fn`s. Now `Rav1dContext` is always accessed through a `&` except during its construction in `fn rav1d_open`. This also lets us remove the `Mutex` around `cached_error_props` and the `Atomic` around `frame_flags`, since they are now accessed through a `&mut Rav1dState`.
- Loading branch information
Showing
8 changed files
with
414 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.