google / radioreceiver

An application to listen to broadcast stereo FM and AM radio from your Chrome browser or your ChromeBook computer using a $15 USB digital TV tuner.
https://chrome.google.com/webstore/detail/radio-receiver/miieomcelenidlleokajkghmifldohpo
Apache License 2.0
394 stars 80 forks source link

Multiple tuner support causes crash #2

Open recri opened 9 years ago

recri commented 9 years ago

I've made a first pass of supporting the Elonics 4000 tuner. The modified tuner detect code looks, in part, like this:

com.i2c.open(function() {
R820T.check(com, function(found) {
if (found) {
  tuner = new R820T(com, xtalFreq, throwError);
} else {
  E4K.check(com, function(found) {
if (found) {
      tuner = new E4K(com, xtalFreq, throwError);
}
  });
}
if (!tuner) {
  throwError('Sorry, your USB dongle has an unsupported tuner chip. ' +
             'Only the R820T and E4000 chips are supported.');
  return;
}

So, try R820T, if it fails, try E4K. The problem is that the R820T check, when an E4K tuner is installed, fails with:

USB write failed (value 0x34 index 0x610 data [0x0]), rc=4, lastErrorMessage="Transfer stalled."

an uncatchable error that exits the extension. I don't see any code in rtlcom.js to probe for valid I2C addresses or to catch timeouts caused by operations to invalid I2C addresses.

I've swapped the order of the tests to continue my development.