Separate IO

Initial separation of input and output devices. Assisted by our super friend ChatGpt.
This commit is contained in:
ExtremesecrecyOne
2025-07-22 16:20:30 -07:00
parent 884eb31619
commit d8043d2041
9 changed files with 109 additions and 63 deletions
+9 -6
View File
@@ -25,7 +25,8 @@ export default class JackServerSettings {
this.isOnboarding = input.isOnboarding;
this.isJackAudio = input.isJackAudio;
this.rebootRequired = input.rebootRequired;
this.alsaDevice = input.alsaDevice?? "";
this.alsaInputDevice = input.alsaInputDevice ?? "";
this.alsaOutputDevice = input.alsaOutputDevice ?? "";
this.sampleRate = input.sampleRate;
this.bufferSize = input.bufferSize;
this.numberOfBuffers = input.numberOfBuffers;
@@ -39,7 +40,7 @@ export default class JackServerSettings {
// if (numberOfBuffers) {
// this.valid = true;
// }
// }
// }
clone(): JackServerSettings
{
return new JackServerSettings().deserialize(this);
@@ -48,16 +49,18 @@ export default class JackServerSettings {
isOnboarding: boolean = true;
rebootRequired = false;
isJackAudio = false;
alsaDevice: string = "";
alsaInputDevice: string = "";
alsaOutputDevice: string = "";
sampleRate = 48000;
bufferSize = 64;
numberOfBuffers = 3;
getSummaryText() {
if (this.valid) {
let device = this.alsaDevice;
if (device.startsWith("hw:")) device = device.substring(3);
return device + " - Rate: " + this.sampleRate + " BufferSize: " + this.bufferSize + " Buffers: " + this.numberOfBuffers;
let inDev = this.alsaInputDevice.startsWith("hw:") ? this.alsaInputDevice .substring(3) : this.alsaInputDevice;
let outDev = this.alsaOutputDevice.startsWith("hw:") ? this.alsaOutputDevice.substring(3) : this.alsaOutputDevice;
return "In: "+inDev+" Out: "+outDev+" Rate "+this.sampleRate+", "+this.bufferSize+"×"+this.numberOfBuffers;
} else {
return "Not configured";
}
+52 -28
View File
@@ -15,7 +15,7 @@
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import { Component } from 'react';
@@ -282,7 +282,9 @@ const JackServerSettingsDialog = withStyles(
}
if (!selectedDevice) {
selectedDevice = alsaDevices[0];
result.alsaDevice = selectedDevice.id;
// if nothing selected yet, pick first for both:
if (!result.alsaInputDevice ) result.alsaInputDevice = selectedDevice.id;
if (!result.alsaOutputDevice) result.alsaOutputDevice = selectedDevice.id;
}
if (result.sampleRate === 0) result.sampleRate = 48000;
@@ -292,7 +294,7 @@ const JackServerSettingsDialog = withStyles(
result.bufferSize = bestBuffers.bufferSize;
result.numberOfBuffers = bestBuffers.numberOfBuffers;
result.valid = true;
result.valid = !!result.alsaInputDevice && !!result.alsaOutputDevice;
return result;
}
@@ -399,7 +401,25 @@ const JackServerSettingsDialog = withStyles(
this.props.onApply(this.state.jackServerSettings.clone());
}
};
handleInputDeviceChanged(e: any) {
const d = e.target.value as string;
let s = this.state.jackServerSettings.clone();
s.alsaInputDevice = d;
this.setState({
jackServerSettings: s,
okEnabled: isOkEnabled(s, this.state.alsaDevices)
});
}
handleOutputDeviceChanged(e: any) {
const d = e.target.value as string;
let s = this.state.jackServerSettings.clone();
s.alsaOutputDevice = d;
this.setState({
jackServerSettings: s,
okEnabled: isOkEnabled(s, this.state.alsaDevices)
});
}
render() {
const classes = withStyles.getClasses(this.props);
@@ -433,31 +453,35 @@ const JackServerSettingsDialog = withStyles(
>
<DialogContent>
<div>
{/* Audio Input Device */}
<FormControl className={classes.formControl}>
<InputLabel htmlFor="jsd_device">Device</InputLabel>
<Select variant="standard" onChange={(e) => this.handleDeviceChanged(e)}
value={this.state.jackServerSettings.alsaDevice}
style={{width: 220}}
inputProps={{
name: "Device",
id: "jsd_device",
}}
>
{(noDevices && !waitingForDevices) &&
(
<MenuItem value={INVALID_DEVICE_ID}>No suitable devices.</MenuItem>
)
}
{((!noDevices) && !waitingForDevices) && (
this.state.alsaDevices!.map((device) =>
(
<MenuItem key={device.id} value={device.id}>{device.name}</MenuItem>
)
)
)}
</Select>
</FormControl>
<InputLabel htmlFor="jsd_inputDevice">Input Device</InputLabel>
<Select
id="jsd_inputDevice"
value={this.state.jackServerSettings.alsaInputDevice}
onChange={e => this.handleInputDeviceChanged(e)}
style={{ width: 220 }}
>
{this.state.alsaDevices!.map(d => (
<MenuItem key={d.id} value={d.id}>{d.name}</MenuItem>
))}
</Select>
</FormControl>
{/* Audio Output Device */}
<FormControl className={classes.formControl}>
<InputLabel htmlFor="jsd_outputDevice">Output Device</InputLabel>
<Select
id="jsd_outputDevice"
value={this.state.jackServerSettings.alsaOutputDevice}
onChange={e => this.handleOutputDeviceChanged(e)}
style={{ width: 220 }}
>
{this.state.alsaDevices!.map(d => (
<MenuItem key={d.id} value={d.id}>{d.name}</MenuItem>
))}
</Select>
</FormControl>
</div><div>
<FormControl className={classes.formControl}>
<InputLabel htmlFor="jsd_sampleRate">Sample rate</InputLabel>