Issue/107 Reuse cached SANE_Parameters in SaneDev_snap instead of a second sane_get_parameters call - #109
Open
carygravel wants to merge 2 commits into
Open
Issue/107 Reuse cached SANE_Parameters in SaneDev_snap instead of a second sane_get_parameters call#109carygravel wants to merge 2 commits into
carygravel wants to merge 2 commits into
Conversation
…_get_parameters call Some SANE backends (e.g. Epson's epsonscan2) return SANE_STATUS_INVAL on a second sane_get_parameters() call after sane_start. The Python wrapper's get_parameters() already retrieves the parameters successfully, but snap() then calls sane_get_parameters() again internally and fails on those backends, raising `_sane.error: Invalid argument`. Cache the parameters from the most recent get_parameters() call in the SaneDevObject and reuse them in SaneDev_snap, falling back to sane_get_parameters() only when the cache is empty (snap called without a prior get_parameters). Invalidate the cache on sane_start() and update it when a subsequent frame is started.
Add a mock libsane backend (tests/mock/libsane_mock.c) that replicates the INVAL-on-second-sane_get_parameters behavior and a regression test that fails without the fix (tests/test_snap_params_cache.py). The test exercises snap() through the cached-params path at depth-8, depth-1, and snap without a prior get_parameters. Wire the test into CI.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some SANE backends (e.g. Epson's epsonscan2) return SANE_STATUS_INVAL on a second sane_get_parameters() call after sane_start. The Python wrapper's get_parameters() already retrieves the parameters successfully, but snap() then calls sane_get_parameters() again internally and fails on those backends, raising
_sane.error: Invalid argument.Cache the parameters from the most recent get_parameters() call in the SaneDevObject and reuse them in SaneDev_snap, falling back to sane_get_parameters() only when the cache is empty (snap called without a prior get_parameters). Invalidate the cache on sane_start() and update it when a subsequent frame is started.