import QtQuick Item { property real volume: 0.4 property int volumeWrites: 0 property int muteWrites: 0 // Writes that asked for the volume overlay: keys and IPC, never the open panel. property int osdRequests: 0 property int externalUpdates: 0 property bool manyDevices: false property bool pipewireReady: true property bool noDevices: false readonly property bool hasDevices: pipewireReady && !noDevices property var osdService: null property bool micActive: false // Adversarial input: a node with only its ALSA name, no description. property bool machineNames: false function sinkRow() { return { "id": "sink-fixture", "name": "fixture output", "glyph": "", "role": "ui.accent", "muted": false, "percent": Math.round(volume * 100), "isDefault": true }; } readonly property var sinks: hasDevices ? [sinkRow()].concat(manyDevices ? Array.from({ length: 12 }, (_, i) => Object.assign({}, sinkRow(), { id: `sink-${i}`, name: `additional output ${i}`, isDefault: false })) : []) : [] readonly property var sources: hasDevices && machineNames ? [ { "id": "source-alsa", "name": "alsa_input.pci-0000_00_1f.3.analog-stereo", "glyph": "\uF130", "role": "ui.accent", "muted": false, "percent": 60, "isDefault": true } ] : [] readonly property var streams: [] function stateJson() { return JSON.stringify({ "pipewireReady": pipewireReady, "sinks": sinks, "sources": sources, "streams": streams }); } function setMachineNames(value) { machineNames = value === true; } function setVolume(id, ratio, quiet) { volume = Number(ratio); volumeWrites++; if (!quiet) osdRequests++; return stateJson(); } function toggleMute(id, quiet) { muteWrites++; if (!quiet) osdRequests++; return stateJson(); } function setDefaultSink(id) { return stateJson(); } function setDefaultSource(id) { return stateJson(); } readonly property bool microphoneInUse: micActive readonly property bool cameraInUse: false readonly property bool privacyActive: microphoneInUse || cameraInUse // Fixture surface for `features/audio/fixtures/suite.mjs` and the shared task fixture. function fixtureState() { return { "volume": volume, "volumeWrites": volumeWrites, "muteWrites": muteWrites, "osdRequests": osdRequests, "externalUpdates": externalUpdates, "pipewireReady": pipewireReady, "hasDevices": hasDevices }; } function showManyDevices() { manyDevices = true; } function setNoDevices(value) { noDevices = value === true; } function setPipewireReady(value) { pipewireReady = value === true; } function setMicActive(active) { micActive = active === true; } function externalUpdate() { volume = 0.8; externalUpdates++; } }