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};
|
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.
|
// 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.
|
// 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();
|
let result = jackServerSettings.clone();
|
||||||
if (!alsaDevices || alsaDevices.length === 0) {
|
if (!alsaDevices || alsaDevices.length === 0) {
|
||||||
result.valid = false;
|
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;
|
result.alsaOutputDevice = result.alsaInputDevice;
|
||||||
outDevice = inDevice;
|
outDevice = inDevice;
|
||||||
}
|
}
|
||||||
@@ -437,9 +433,11 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (this.state.useSameDevice) {
|
if (this.state.useSameDevice) {
|
||||||
s.alsaOutputDevice = d;
|
s.alsaOutputDevice = d;
|
||||||
}
|
}
|
||||||
|
let settings = this.applyAlsaDevices(s, this.state.alsaDevices);
|
||||||
this.setState({
|
this.setState({
|
||||||
jackServerSettings: s,
|
jackServerSettings: settings,
|
||||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
latencyText: getLatencyText(settings),
|
||||||
|
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,9 +448,11 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (this.state.useSameDevice) {
|
if (this.state.useSameDevice) {
|
||||||
s.alsaInputDevice = d;
|
s.alsaInputDevice = d;
|
||||||
}
|
}
|
||||||
|
let settings = this.applyAlsaDevices(s, this.state.alsaDevices);
|
||||||
this.setState({
|
this.setState({
|
||||||
jackServerSettings: s,
|
jackServerSettings: settings,
|
||||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
latencyText: getLatencyText(settings),
|
||||||
|
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleUseSameDeviceChanged(e: any, checked: boolean) {
|
handleUseSameDeviceChanged(e: any, checked: boolean) {
|
||||||
@@ -461,10 +461,12 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
if (useSame) {
|
if (useSame) {
|
||||||
s.alsaOutputDevice = s.alsaInputDevice;
|
s.alsaOutputDevice = s.alsaInputDevice;
|
||||||
}
|
}
|
||||||
|
let settings = this.applyAlsaDevices(s, this.state.alsaDevices, useSame);
|
||||||
this.setState({
|
this.setState({
|
||||||
useSameDevice: useSame,
|
useSameDevice: useSame,
|
||||||
jackServerSettings: s,
|
jackServerSettings: settings,
|
||||||
okEnabled: isOkEnabled(s, this.state.alsaDevices)
|
latencyText: getLatencyText(settings),
|
||||||
|
okEnabled: isOkEnabled(settings, this.state.alsaDevices)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
@@ -509,7 +511,7 @@ const JackServerSettingsDialog = withStyles(
|
|||||||
disabled={!this.state.alsaDevices || this.state.alsaDevices.length === 0}
|
disabled={!this.state.alsaDevices || this.state.alsaDevices.length === 0}
|
||||||
style={{ width: 220 }}
|
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 key={d.id} value={d.id}>{d.name}</MenuItem>
|
||||||
)) || <MenuItem value="" disabled>Loading...</MenuItem>}
|
)) || <MenuItem value="" disabled>Loading...</MenuItem>}
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
Reference in New Issue
Block a user