ieatlint / MagRead

Reads magnetic stripe cards on Maemo, Symbian, Windows, OS X and Linux
http://blog.tehinterweb.com/
GNU General Public License v3.0
111 stars 55 forks source link

Create timeout between swipes #9

Closed ieatlint closed 13 years ago

ieatlint commented 13 years ago

In the event that a stream of bad audio ends up feeding into the application, an issue can occur where the program will endlessly do this:

  1. Read audio data
  2. Reach a limit (of about 20ms) in which the program decides it's taking too long and cuts off to prevent the audio data buffer from exploding
  3. Attempts to decode the data and fails
  4. Puts up a notification of the failure And repeats.

Since the notifications can be modal, it can prevent the user from even being able to easily close the application. I've only run into this bug once, but it was rather annoying.

ieatlint commented 13 years ago

There's a very simple fix in place that is not tied directly to time.

A timeOut is created whenever a card is swiped. While the variable contains a positive integer, data from the audio device will not be processed. Instead, it will simply decrement timeOut by one on each call. A timeOut of 10 data blocks seems to reasonably solve this problem, but I'll increase it if needed.

This will be a user-configurable delay once a settings deliague is in place.