AmpliPi icon indicating copy to clipboard operation
AmpliPi copied to clipboard

Source state isn't being set properly during stream close / preset invocation

Open SteveMicroNova opened this issue 1 year ago • 2 comments

In #980 and #979 I found that closing a stream doesn't always set that source.input to a valid option, figure out why state isn't being set properly in different cases involving presets and stream closures

SteveMicroNova avatar Oct 14 '24 20:10 SteveMicroNova

I'm not sure there's enough information here for someone other than yourself to solve this issue; can you elaborate on the problem as you've witnessed it and perhaps create a repro case?

rtertiaer avatar Oct 15 '24 15:10 rtertiaer

I'm not sure there's enough information here for someone other than yourself to solve this issue; can you elaborate on the problem as you've witnessed it and perhaps create a repro case?

For some reason this solved the issue I was having, and illuminated this one. When streams are closed manually or via an empty preset on streamer, sometimes they get set to an invalid state that allows them to path through the "unknown" path of this function:

export const getSourceInputType = (source) => {
    // can return:
    // none, rca, digital, unknown
    if (!source || !source.input || source.input == undefined) return "unknown";
    const input = source.input.toLowerCase();

    if (input === "none" || input === "" || input === "local") {
        return "none";
    }

    const split = input.split("=");
    if (split.length !== 2) {
        console.log(`WARNING: unknown source input: ${input}`);
        return "unknown";
    }

    if (split[1] < 1000) {
        return "rca";
    } else {
        return "digital";
    }
};

I didn't get very far into it myself, to witness this you'll just have to keep an eye on the state of the various sources while closing stuff on the streamer at minimum, I haven't been able to look at a main unit yet

SteveMicroNova avatar Oct 15 '24 15:10 SteveMicroNova