Same Device Con't
When “Use same device” is enabled, changing that setting now ensures the input device also supports playback, switching to the first bidirectional device if necessary The input device dropdown hides devices lacking playback capability whenever the same-device option is active The device change handlers now call “applyAlsaDevices” with the latest settings to recalculate latency and validation, ensuring UI state matches valid ALSA configurations “applyAlsaDevices” accepts an optional same-device flag so callers can specify when input and output devices should be treated as identica
This commit is contained in:
@@ -162,11 +162,6 @@ function getBestBuffers(
|
||||
{
|
||||
return { bufferSize:bufferSize, numberOfBuffers: numberOfBuffers};
|
||||
}
|
||||
const device = inDevice || outDevice;
|
||||
if (!device)
|
||||
{
|
||||
return { bufferSize:bufferSize, numberOfBuffers:numberOfBuffers};
|
||||
}
|
||||
|
||||
// If the numberOfbuffers is fine as is, don't change the number of Buffers.
|
||||
// set default values. Otherwise, choose the best buffer count from available buffer counts.
|
||||
@@ -286,7 +281,7 @@ const JackServerSettingsDialog = withStyles(
|
||||
});
|
||||
}
|
||||
|
||||
applyAlsaDevices(jackServerSettings: JackServerSettings, alsaDevices?: AlsaDeviceInfo[]) {
|
||||
applyAlsaDevices(jackServerSettings: JackServerSettings, alsaDevices?: AlsaDeviceInfo[], useSameDevice?: boolean) {
|
||||
let result = jackServerSettings.clone();
|
||||
if (!alsaDevices || alsaDevices.length === 0) {
|
||||
result.valid = false;
|
||||
@@ -310,7 +305,8 @@ const JackServerSettingsDialog = withStyles(
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state.useSameDevice) {
|
||||
const sameDevice = useSameDevice !== undefined ? useSameDevice : this.state.useSameDevice;
|
||||
if (sameDevice) {
|
||||
result.alsaOutputDevice = result.alsaInputDevice;
|
||||
outDevice = inDevice;
|
||||
}
|
||||
@@ -437,34 +433,40 @@ const JackServerSettingsDialog = withStyles(
|
||||
if (this.state.useSameDevice) {
|
||||
s.alsaOutputDevice = d;
|
||||
}
|
||||
let settings = this.applyAlsaDevices(s, this.state.alsaDevices);
|
||||
this.setState({
|
||||
jackServerSettings: s,
|
||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
||||
jackServerSettings: settings,
|
||||
latencyText: getLatencyText(settings),
|
||||
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||
});
|
||||
}
|
||||
|
||||
handleOutputDeviceChanged(e: any) {
|
||||
handleOutputDeviceChanged(e: any) {
|
||||
const d = e.target.value as string;
|
||||
let s = this.state.jackServerSettings.clone();
|
||||
s.alsaOutputDevice = d;
|
||||
if (this.state.useSameDevice) {
|
||||
s.alsaInputDevice = d;
|
||||
}
|
||||
let settings = this.applyAlsaDevices(s, this.state.alsaDevices);
|
||||
this.setState({
|
||||
jackServerSettings: s,
|
||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
||||
jackServerSettings: settings,
|
||||
latencyText: getLatencyText(settings),
|
||||
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||
});
|
||||
}
|
||||
handleUseSameDeviceChanged(e: any, checked: boolean) {
|
||||
handleUseSameDeviceChanged(e: any, checked: boolean) {
|
||||
let s = this.state.jackServerSettings.clone();
|
||||
const useSame = checked;
|
||||
if (useSame) {
|
||||
s.alsaOutputDevice = s.alsaInputDevice;
|
||||
}
|
||||
let settings = this.applyAlsaDevices(s, this.state.alsaDevices, useSame);
|
||||
this.setState({
|
||||
useSameDevice: useSame,
|
||||
jackServerSettings: s,
|
||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
||||
jackServerSettings: settings,
|
||||
latencyText: getLatencyText(settings),
|
||||
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||
});
|
||||
}
|
||||
render() {
|
||||
@@ -509,7 +511,7 @@ const JackServerSettingsDialog = withStyles(
|
||||
disabled={!this.state.alsaDevices || this.state.alsaDevices.length === 0}
|
||||
style={{ width: 220 }}
|
||||
>
|
||||
{this.state.alsaDevices?.filter(d => d.supportsCapture).map(d => (
|
||||
{this.state.alsaDevices?.filter(d => d.supportsCapture && (!this.state.useSameDevice || d.supportsPlayback)).map(d => (
|
||||
<MenuItem key={d.id} value={d.id}>{d.name}</MenuItem>
|
||||
)) || <MenuItem value="" disabled>Loading...</MenuItem>}
|
||||
</Select>
|
||||
|
||||
Reference in New Issue
Block a user