Repository navigation
Razer Barracuda Pro: no charging query for a headset that is off, and a refused write is retried (about 4 s less per poll), unit tests - #133
Merged
Conversation
read_battery sent the charging query even when the battery query got no answer, so a switched-off headset cost a second full set of timeouts (4 x 6 x 150 ms) and held up every other provider on the poll thread. It now returns the offline result as soon as the battery query is empty (remote mode is still switched off again, as before). Session._write ignored write()'s return value; hidapi reports a failed write by returning -1 rather than raising, so remote() always reported success and the wake retries never ran. A negative return now counts as a failure. No frame changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmGsnjgXs8VbKmmxLkPsf6
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.
This change removes a long wait from the poll thread. The poll thread reads all providers in sequence, so a slow provider delays the icons of all other devices. The Razer Barracuda Pro provider waited too long when the headset was off. The change does not add or change a command to a device.
1. Problem
read_batterysent the charging query also when the battery query got no reply. Each query uses 4 attempts of 6 reads of 150 ms. Thus a headset that is off added approximately 3.6 s to each poll.Session._writedid not examine the return value ofwrite(). hidapi returns -1 when a write fails. It does not raise an error. Thusremote()always reported success, and the wake retries did not operate.Failure scenario: The receiver is plugged in. The headset is off. The poll interval is 15 s. Each poll holds all other icons for approximately 7 s instead of 3.6 s.
2. Change
read_batteryreturns("offline", None, False)immediately when the battery query gets no reply. It still sends "remote mode off", as before. The offline icon is the same as before._writereturnsFalsewhenwrite()returns a negative value. The existing retry logic now operates.3. Tests
New tests use fake HID devices. They count reads and writes.
tests/test_barracuda.py:test_headset_on,test_headset_off_skips_the_charging_query,test_headset_off_costs_one_query_of_reads,test_failed_write_is_retried_for_remote_mode,test_receiver_that_rejects_every_write_sends_no_queries,test_failed_query_write_stops_that_query,test_headset_off_shows_the_offline_icon.Suite result: all tests pass.
Mutation check: I broke each line of the fix one at a time. At least one new test failed for each mutation.
write(); remove the early return; remove "remote mode off" on the offline path.Base and other PRs
mainate80dfd1.CHANGELOG.mdconflicts (the same[Unreleased]lines). Tray: device type switches (#96), per-device alert level, time left, percentage icon, quiet while gaming (#76), status file; Audeze stuck dongle and 0% at power-on, unit tests #107 has the same conflicts that it already has withmain.main. I did not test it on hardware.