Re-order service startup (Jack Server Settings)

This commit is contained in:
Robin Davies
2021-08-29 21:20:42 -04:00
parent 5ec349f17b
commit 57ecc0d9ef
14 changed files with 239 additions and 124 deletions
+1 -2
View File
@@ -33,7 +33,6 @@ import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
import DialogContent from '@material-ui/core/DialogContent';
import MenuItem from '@material-ui/core/MenuItem';
import { nullCast } from './Utility';
import Typography from '@material-ui/core/Typography';
import { PiPedalModel, PiPedalModelFactory } from './PiPedalModel';
@@ -178,7 +177,7 @@ const JackServerSettingsDialog = withStyles(styles)(
let settings = this.state.jackServerSettings.clone();
settings.alsaDevice = device;
settings.sampleRate = selectedDevice.closestSampleRate(settings.sampleRate);
settings.bufferSize = selectedDevice.closestSampleRate(settings.bufferSize);
settings.bufferSize = selectedDevice.closestBufferSize(settings.bufferSize);
this.setState({
jackServerSettings: settings,
+16 -2
View File
@@ -20,7 +20,7 @@
import React, { SyntheticEvent, Component } from 'react';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import { PiPedalModel, PiPedalModelFactory } from './PiPedalModel';
import { PiPedalModel, PiPedalModelFactory, State } from './PiPedalModel';
import ButtonBase from "@material-ui/core/ButtonBase";
import { TransitionProps } from '@material-ui/core/transitions/transition';
import Slide from '@material-ui/core/Slide';
@@ -159,9 +159,20 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.handleJackSettingsChanged = this.handleJackSettingsChanged.bind(this);
this.handleJackServerSettingsChanged = this.handleJackServerSettingsChanged.bind(this);
this.handleWifiConfigSettingsChanged = this.handleWifiConfigSettingsChanged.bind(this);
this.handleConnectionStateChanged = this.handleConnectionStateChanged.bind(this);
}
handleConnectionStateChanged() : void {
if (this.model.state.get() === State.Ready)
{
if (this.state.shuttingDown || this.state.restarting)
{
this.setState({shuttingDown: false, restarting: false});
}
}
}
handleApplyWifiConfig(wifiConfigSettings: WifiConfigSettings): void {
this.setState({showWifiConfigDialog: false});
this.model.setWifiConfigSettings(wifiConfigSettings)
@@ -218,6 +229,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
if (active !== this.active) {
this.active = active;
if (active) {
this.model.state.addOnChangedHandler(this.handleConnectionStateChanged);
this.model.jackSettings.addOnChangedHandler(this.handleJackSettingsChanged);
this.model.jackConfiguration.addOnChangedHandler(this.handleJackConfigurationChanged);
this.model.jackServerSettings.addOnChangedHandler(this.handleJackServerSettingsChanged);
@@ -235,15 +247,17 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
jackStatus: undefined
})
});
this.handleConnectionStateChanged();
this.handleJackConfigurationChanged();
this.handleJackSettingsChanged();
this.handleJackServerSettingsChanged();
this.handleWifiConfigSettingsChanged();
// xxx UNCOMMENT ME! this.timerHandle = setInterval(() => this.tick(), 1000);
this.timerHandle = setInterval(() => this.tick(), 1000);
} else {
if (this.timerHandle) {
clearInterval(this.timerHandle);
}
this.model.state.removeOnChangedHandler(this.handleConnectionStateChanged);
this.model.jackConfiguration.removeOnChangedHandler(this.handleJackConfigurationChanged);
this.model.jackSettings.removeOnChangedHandler(this.handleJackSettingsChanged);
this.model.jackServerSettings.removeOnChangedHandler(this.handleJackServerSettingsChanged);