fix reconnection behavior

This commit is contained in:
Jakob Ketterl 2020-05-02 14:51:00 +02:00
parent 3504c8b54e
commit 6ff1b7d20a
2 changed files with 10 additions and 1 deletions

View File

@ -97,7 +97,7 @@ DemodulatorPanel.prototype.setMode = function(modulation) {
var replace_modulator = current_modulation !== modulation; var replace_modulator = current_modulation !== modulation;
if (replace_modulator) { if (replace_modulator) {
if (this.demodulator) this.demodulator.stop(); this.stopDemodulator();
this.demodulator = new Demodulator(current_offset_frequency, modulation); this.demodulator = new Demodulator(current_offset_frequency, modulation);
var self = this; var self = this;
this.demodulator.on("frequencychange", function(freq) { this.demodulator.on("frequencychange", function(freq) {
@ -144,6 +144,14 @@ DemodulatorPanel.prototype.startDemodulator = function() {
this._apply(params); this._apply(params);
}; };
DemodulatorPanel.prototype.stopDemodulator = function() {
if (!this.demodulator) {
return;
}
this.demodulator.stop();
this.demodulator = false;
}
DemodulatorPanel.prototype._apply = function(params) { DemodulatorPanel.prototype._apply = function(params) {
this.setMode(params.mod); this.setMode(params.mod);
this.getDemodulator().set_offset_frequency(params.offset_frequency); this.getDemodulator().set_offset_frequency(params.offset_frequency);

View File

@ -1241,6 +1241,7 @@ function onAudioStart(success, apiType){
var reconnect_timeout = false; var reconnect_timeout = false;
function on_ws_closed() { function on_ws_closed() {
$("#openwebrx-panel-receiver").demodulatorPanel().stopDemodulator();
if (reconnect_timeout) { if (reconnect_timeout) {
// max value: roundabout 8 and a half minutes // max value: roundabout 8 and a half minutes
reconnect_timeout = Math.min(reconnect_timeout * 2, 512000); reconnect_timeout = Math.min(reconnect_timeout * 2, 512000);