diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a610b78..5ed67e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,7 @@ jobs: AUDIO_TEST_OMARCHY_SHELL: "${{ github.workspace }}/omarchy/shell" run: | python test/integration/text_rendering.py + python test/integration/panel_lifecycle.py cargo build --locked --manifest-path backend/Cargo.toml python test/integration/runtime.py backend/target/debug/omarchy-audio-service python test/integration/routed_audio.py backend/target/debug/omarchy-audio-service diff --git a/backend-release.json b/backend-release.json index d8ba484..af364e8 100644 --- a/backend-release.json +++ b/backend-release.json @@ -1,7 +1,7 @@ { - "buildId": "0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b", + "buildId": "18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb", "target": "x86_64-unknown-linux-gnu", "version": "0.1.0", "protocolVersion": 1, - "sha256": "10aadcd9529362cdadc3a1529de79540f6f36015b825f3031b7cf1200f9cf04d" + "sha256": "ce8dd41267eb065d9c2e6bc1db06ff9b3114c0280a7b970a98946d9436cc15c9" } diff --git a/backend/src/automation.rs b/backend/src/automation.rs index cd696ab..04fd8d8 100644 --- a/backend/src/automation.rs +++ b/backend/src/automation.rs @@ -58,7 +58,24 @@ pub fn group_signature(graph: &Graph, rules: &Value) -> String { }) .map(|n| json!([n.id, n.serial, n.name, !n.state.is_empty()])) .collect(); - json!([graph.generation, nodes, rules["outputGroups"]]).to_string() + // An orphan may still be the default or have applications linked to it. + // Reconsider deferred removal when its use changes without replacing nodes. + let default = crate::routing::default_name(graph, crate::routing::Direction::Playback); + let usage: Vec<_> = graph + .nodes + .values() + .filter(|n| storage::group_sink(&n.name)) + .map(|n| { + let consumers: Vec<_> = graph + .links + .values() + .filter(|l| l.input_node == n.id && matches!(l.state.as_str(), "Active" | "Paused")) + .map(|l| l.output_node) + .collect(); + json!([n.id, default.as_deref() == Some(&n.name), consumers]) + }) + .collect(); + json!([graph.generation, nodes, rules["outputGroups"], usage]).to_string() } pub fn routes(graph: &Graph, rules: &Value) -> Vec<(String, crate::routing::Set)> { let mut result = Vec::new(); diff --git a/backend/src/file_watch.rs b/backend/src/file_watch.rs index 8ea3dcc..4b44164 100644 --- a/backend/src/file_watch.rs +++ b/backend/src/file_watch.rs @@ -42,6 +42,7 @@ impl Watcher { path.as_ptr(), libc::IN_CLOSE_WRITE | libc::IN_MOVED_TO + | libc::IN_MOVED_FROM | libc::IN_DELETE | libc::IN_CREATE | libc::IN_DELETE_SELF diff --git a/backend/src/service/automation.rs b/backend/src/service/automation.rs index d4de0e1..799a951 100644 --- a/backend/src/service/automation.rs +++ b/backend/src/service/automation.rs @@ -68,7 +68,9 @@ impl Service { continue; } let next = crate::automation::signature(&graph, &snapshot["stores"]["rules"]); - if next == signature { + let next_groups = + crate::automation::group_signature(&graph, &snapshot["stores"]["rules"]); + if next == signature && next_groups == groups { continue; } let _transaction = service.mutation.lock().await; diff --git a/backend/src/service/state.rs b/backend/src/service/state.rs index 9d2b42e..42560fb 100644 --- a/backend/src/service/state.rs +++ b/backend/src/service/state.rs @@ -1,7 +1,7 @@ //! Snapshot publication and persisted-store observation. use super::{Busy, Service}; use crate::native; -use crate::protocol::{Failure, Request, Result}; +use crate::protocol::{self, Failure, MAX_FRAME_BYTES, Request, Response, Result}; use crate::storage::{self, Kind}; use serde_json::{Value, json}; use std::sync::Arc; @@ -168,8 +168,8 @@ impl Service { }; self.set_busy(true); let _busy = Busy(self); - let request = request.clone(); - let result = tokio::task::spawn_blocking(move || storage.handle(&request)) + let command = request.clone(); + let result = tokio::task::spawn_blocking(move || storage.handle(&command)) .await .map_err(|_| Failure::unknown("Store operation stopped unexpectedly"))?; self.reload_stores().await?; @@ -185,6 +185,20 @@ impl Service { .await; } } - result?.ok_or_else(|| Failure::new("method_not_found", "Unknown store method")) + let value = + result?.ok_or_else(|| Failure::new("method_not_found", "Unknown store method"))?; + // Stores can exceed a single response frame. Subscribers receive the + // updated document through bounded snapshot chunks before completion. + if request.method != "store.read" { + return Ok(json!({"outcome": "applied"})); + } + let response = Response::new(Some(&request.id), Ok(value.clone())); + if protocol::encode(&response)?.len() + 1 > MAX_FRAME_BYTES { + return Err(Failure::new( + "response_too_large", + "Audio store is too large for one reply; use state.subscribe", + )); + } + Ok(value) } } diff --git a/bin/omarchy-audio-service b/bin/omarchy-audio-service index 4dfec10..58ba8b6 100755 Binary files a/bin/omarchy-audio-service and b/bin/omarchy-audio-service differ diff --git a/manifest.json b/manifest.json index 60e482c..e5bef35 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "ssupt.audio-control", "name": "Advanced Audio Control", - "version": "0.9.0-dev.27", + "version": "0.9.1", "author": "ssupt", "description": "Advanced PipeWire and WirePlumber audio mixer for Omarchy: devices, multi-output groups, Bluetooth codecs, safety policies, microphone privacy, audio scenes, persistent routing rules, graph and service diagnostics, channel tests, support reports, and guarded recovery", "kinds": [ @@ -11,9 +11,9 @@ "service" ], "entryPoints": { - "barWidget": "runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/Panel.qml", - "panel": "runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/AdvancedAudio.qml", - "service": "runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Service.qml" + "barWidget": "runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/Panel.qml", + "panel": "runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/AdvancedAudio.qml", + "service": "runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Service.qml" }, "barWidget": { "displayName": "Advanced Audio Control", diff --git a/packaging/manifest.template.json b/packaging/manifest.template.json index d0d95a5..25f3d03 100644 --- a/packaging/manifest.template.json +++ b/packaging/manifest.template.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "ssupt.audio-control", "name": "Advanced Audio Control", - "version": "0.9.0-dev.27", + "version": "0.9.1", "author": "ssupt", "description": "Advanced PipeWire and WirePlumber audio mixer for Omarchy: devices, multi-output groups, Bluetooth codecs, safety policies, microphone privacy, audio scenes, persistent routing rules, graph and service diagnostics, channel tests, support reports, and guarded recovery", "kinds": [ diff --git a/qml/core/Service.qml b/qml/core/Service.qml index 8ec4578..0855650 100644 --- a/qml/core/Service.qml +++ b/qml/core/Service.qml @@ -36,6 +36,9 @@ Item { property var client: null property bool destroying: false + // The quick mixer and advanced window share one audio control session. + signal quickPanelOpened() + // Capture events belong to the shared service, not each monitor's panel. readonly property bool captureNotifications: !stores.settings || stores.settings.captureNotifications !== false property bool notificationsAvailable: false diff --git a/qml/panels/AdvancedAudio.qml b/qml/panels/AdvancedAudio.qml index 41cb8ff..50def86 100644 --- a/qml/panels/AdvancedAudio.qml +++ b/qml/panels/AdvancedAudio.qml @@ -364,6 +364,12 @@ Item { target: root.service function onProfilesChanged() { root.refreshDeviceCatalog() } function onPortsChanged() { root.refreshDeviceCatalog() } + function onQuickPanelOpened() { + // A quick-panel summon can arrive through this window's proxy. Close + // only the advanced surface, without toggling the newly opened mixer. + root.quickPanelProxyOpen = false + root.close() + } } function policyToggleAtCursor() { diff --git a/qml/panels/Panel.qml b/qml/panels/Panel.qml index e5b4df9..19e5865 100644 --- a/qml/panels/Panel.qml +++ b/qml/panels/Panel.qml @@ -604,6 +604,8 @@ Panel { onOpenedChanged: { if (opened) { + if (audioService && typeof audioService.quickPanelOpened === "function") + audioService.quickPanelOpened() if (appLibrary && typeof appLibrary.refreshIcons === "function") appLibrary.refreshIcons() // Populate through the debounced refresh: assigning the display models // synchronously inside this signal regenerates every Repeater while diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioBalanceRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioBalanceRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioBalanceRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioBalanceRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioBarIcon.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioBarIcon.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioBarIcon.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioBarIcon.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioDropdown.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioDropdown.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioDropdown.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioDropdown.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSinkRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSinkRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSinkRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSinkRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSlider.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSlider.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSlider.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSlider.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSourceRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSourceRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioSourceRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioSourceRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioStreamRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioStreamRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/components/AudioStreamRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/components/AudioStreamRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioNodeModel.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioNodeModel.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioNodeModel.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioNodeModel.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioProtocol.js b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioProtocol.js similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioProtocol.js rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioProtocol.js diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioRuntime.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioRuntime.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/AudioRuntime.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/AudioRuntime.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Model.js b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Model.js similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Model.js rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Model.js diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/ReleasePaths.js b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/ReleasePaths.js similarity index 50% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/ReleasePaths.js rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/ReleasePaths.js index 7bc15e9..137aab2 100644 --- a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/ReleasePaths.js +++ b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/ReleasePaths.js @@ -1,3 +1,3 @@ // Generated release paths; edit the qml sources instead. var root = "../../../../" -var buildId = "0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b" +var buildId = "18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb" diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Service.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Service.qml similarity index 99% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Service.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Service.qml index 8ec4578..0855650 100644 --- a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/core/Service.qml +++ b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/core/Service.qml @@ -36,6 +36,9 @@ Item { property var client: null property bool destroying: false + // The quick mixer and advanced window share one audio control session. + signal quickPanelOpened() + // Capture events belong to the shared service, not each monitor's panel. readonly property bool captureNotifications: !stores.settings || stores.settings.captureNotifications !== false property bool notificationsAvailable: false diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioBluetoothPreferenceRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioBluetoothPreferenceRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioBluetoothPreferenceRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioBluetoothPreferenceRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioDevicePrefRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioDevicePrefRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioDevicePrefRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioDevicePrefRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioPortRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioPortRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioPortRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioPortRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioProfileRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioProfileRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/devices/AudioProfileRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/devices/AudioProfileRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticActionRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticActionRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticActionRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticActionRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticsController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticsController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticsController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticsController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticsView.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticsView.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/diagnostics/AudioDiagnosticsView.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/diagnostics/AudioDiagnosticsView.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/microphone/AudioMicrophoneTestController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/microphone/AudioMicrophoneTestController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/microphone/AudioMicrophoneTestController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/microphone/AudioMicrophoneTestController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/microphone/MicrophoneTestRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/microphone/MicrophoneTestRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/microphone/MicrophoneTestRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/microphone/MicrophoneTestRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/AdvancedAudio.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/AdvancedAudio.qml similarity index 99% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/AdvancedAudio.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/AdvancedAudio.qml index 41cb8ff..50def86 100644 --- a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/AdvancedAudio.qml +++ b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/AdvancedAudio.qml @@ -364,6 +364,12 @@ Item { target: root.service function onProfilesChanged() { root.refreshDeviceCatalog() } function onPortsChanged() { root.refreshDeviceCatalog() } + function onQuickPanelOpened() { + // A quick-panel summon can arrive through this window's proxy. Close + // only the advanced surface, without toggling the newly opened mixer. + root.quickPanelProxyOpen = false + root.close() + } } function policyToggleAtCursor() { diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/Panel.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/Panel.qml similarity index 99% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/Panel.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/Panel.qml index e5b4df9..19e5865 100644 --- a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/panels/Panel.qml +++ b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/panels/Panel.qml @@ -604,6 +604,8 @@ Panel { onOpenedChanged: { if (opened) { + if (audioService && typeof audioService.quickPanelOpened === "function") + audioService.quickPanelOpened() if (appLibrary && typeof appLibrary.refreshIcons === "function") appLibrary.refreshIcons() // Populate through the debounced refresh: assigning the display models // synchronously inside this signal regenerates every Repeater while diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyToggleRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyToggleRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyToggleRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyToggleRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyVolumeRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyVolumeRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/policy/AudioPolicyVolumeRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/policy/AudioPolicyVolumeRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioAppRuleRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioAppRuleRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioAppRuleRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioAppRuleRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupCreateRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupCreateRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupCreateRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupCreateRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupMemberLevel.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupMemberLevel.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupMemberLevel.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupMemberLevel.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupRow.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupsController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupsController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioOutputGroupsController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioOutputGroupsController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioRulesController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioRulesController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/routing/AudioRulesController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/routing/AudioRulesController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/scenes/AudioSceneController.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/scenes/AudioSceneController.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/scenes/AudioSceneController.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/scenes/AudioSceneController.qml diff --git a/runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/scenes/AudioSceneRow.qml b/runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/scenes/AudioSceneRow.qml similarity index 100% rename from runtime/0443e050952000d914a0d8e2abe7ff41f5d4c5f4328adc02b4333ac834f76d8b/qml/scenes/AudioSceneRow.qml rename to runtime/18ee1133b1582667287109a96c741a74c436683a7ddabc0058049cf83ebddaeb/qml/scenes/AudioSceneRow.qml diff --git a/scripts/audio-bluetooth-default-compat b/scripts/audio-bluetooth-default-compat index bb29c82..7441260 100755 --- a/scripts/audio-bluetooth-default-compat +++ b/scripts/audio-bluetooth-default-compat @@ -22,5 +22,5 @@ fi params=$(jq -cn --arg direction "$direction" --argjson id "$node_id" \ --arg name "$node_name" --arg previous "$previous" \ '{direction:$direction,id:$id,name:$name,previous:$previous}') -"$script_dir/../bin/omarchy-audio-service" --socket "$socket" \ +"$script_dir/audio-service" --socket "$socket" \ --request default.compat "$params" >/dev/null diff --git a/test/fixtures/panel-lifecycle.qml b/test/fixtures/panel-lifecycle.qml new file mode 100644 index 0000000..da5a3fe --- /dev/null +++ b/test/fixtures/panel-lifecycle.qml @@ -0,0 +1,105 @@ +import QtQuick +import Quickshell + +ShellRoot { + id: root + property var service: null + property bool mixerOpen: false + property var advanced: null + property var advancedWindow: null + property var dropdown: null + property int phase: 0 + property int hostCloses: 0 + property bool failed: false + + function check(condition, message) { + if (condition) return true + failed = true + console.log("PANEL_LIFECYCLE_FAILURE", message) + Qt.callLater(Qt.quit) + return false + } + function create(path, properties) { + var component = Qt.createComponent(ROOT_URL + path) + if (!check(component.status === Component.Ready, component.errorString())) return null + var item = component.createObject(root, properties) + check(!!item, "Could not create " + path) + return item + } + function descendants(item) { + var found = [], pending = [item] + while (pending.length) { + var next = pending.pop() + if (!next || found.indexOf(next) !== -1) continue + found.push(next) + var children = next.data || next.children || [] + for (var i = 0; i < children.length; i++) pending.push(children[i]) + if (next.contentItem) pending.push(next.contentItem) + } + return found + } + QtObject { + id: host + property var bar: testBar + function hide(id) { root.hostCloses++; root.advanced.close() } + } + QtObject { + id: testBar + function isBarWidgetOpen(id) { return root.mixerOpen } + function summonBarWidget(id) { + root.mixerOpen = true + root.service.quickPanelOpened() + return true + } + function hideBarWidget(id) { root.mixerOpen = false; return true } + } + Component.onCompleted: { + // Exercise the shared service signal and the real advanced window/menu + // without audio commands or a compositor for the mixer's layer surface. + service = create("qml/core/Service.qml", { backendPreparationCommand: ["/bin/false"] }) + if (!service) return + advanced = create("qml/panels/AdvancedAudio.qml", { service: service, shell: host }) + if (!advanced) return + advancedWindow = descendants(advanced).find(function(item) { + return item.title === "Advanced Audio Control" + }) + if (!check(!!advancedWindow, "Advanced window missing")) return + advanced.activeTab = 1 + dropdown = descendants(advanced).find(function(item) { + return item.popupOpen !== undefined && typeof item.toggle === "function" + && item.options && item.options.some(function(option) { return option.value === "quality" }) + }) + if (!check(!!dropdown, "Advanced preference menu missing")) return + } + Timer { + interval: 100; running: !root.failed; repeat: true + onTriggered: { + if (root.phase === 0) { + root.advanced.openRequested = true + root.advancedWindow.visible = true + root.dropdown.enabled = true + root.dropdown.toggle() + } else if (root.phase === 1) { + if (!root.check(root.advanced.opened && root.dropdown.popupOpen, + "Advanced window and menu did not open")) return + // A stale proxy flag must not close the mixer that is replacing it. + root.advanced.quickPanelProxyOpen = true + testBar.summonBarWidget("ssupt.audio-control") + } else if (root.phase === 2) { + if (!root.check(root.mixerOpen && !root.advanced.opened + && !root.dropdown.popupOpen && root.advanced.profileMenuCount === 0 + && root.hostCloses === 0, "Opening the mixer left an advanced window or menu active")) return + root.mixerOpen = false + root.advancedWindow.visible = true + root.advanced.open("{}") + } else { + if (!root.check(root.mixerOpen && !root.advanced.opened && root.hostCloses === 0, + "The advanced quick-panel proxy hid the new mixer")) return + console.log("PANEL_LIFECYCLE_SUCCESS") + Qt.quit() + } + root.phase++ + } + } + Timer { interval: 5000; running: true; onTriggered: root.check(false, "Window lifecycle timed out") } +} diff --git a/test/fixtures/ui-controls.qml b/test/fixtures/ui-controls.qml index a821b1c..79b27b3 100644 --- a/test/fixtures/ui-controls.qml +++ b/test/fixtures/ui-controls.qml @@ -80,7 +80,14 @@ Item { if (!root.check(root.managedRows().length === 0, "unused routing tab created device rows")) return root.advanced.newOutputGroupName = "Unfinished group" root.advanced.selectTab(4) + var advancedWindow = root.descendants(root.advanced).find(function(item) { + return item.title === "Advanced Audio Control" + }) + if (!root.check(!!advancedWindow, "Advanced window missing")) return + advancedWindow.visible = true root.panel.open() + if (!root.check(!root.advanced.opened && root.panel.opened, + "Opening the mixer left the advanced window active")) return root.phase++ break case 1: diff --git a/test/integration/native_backend.py b/test/integration/native_backend.py index 086a504..e0cb10e 100644 --- a/test/integration/native_backend.py +++ b/test/integration/native_backend.py @@ -89,6 +89,37 @@ def test_foreign_bundle_is_never_executed_and_native_cache_is_reused(self): self.assertNotIn(bundled, self.inspected) self.assertEqual(bundled.read_bytes(), original) + def test_bluetooth_helpers_use_native_launcher(self): + scripts = self.root/'scripts' + scripts.mkdir() + for name in ('audio-bluetooth-default-compat', 'audio-output-set-default', 'audio-input-set-default'): + helper = scripts/name + helper.write_bytes((ROOT/'scripts'/name).read_bytes()) + helper.chmod(0o755) + # A foreign bundled ELF must never be executed, even by compatibility + # helpers after the UI has already prepared its cached native backend. + self.write_binary(self.root/'bin/omarchy-audio-service', 'x86_64') + native_launcher = scripts/'audio-service' + native_launcher.write_text('#!/bin/sh\nprintf "%s\\n" "$@" > "$AUDIO_NATIVE_ARGUMENTS"\n') + native_launcher.chmod(0o755) + build_id = self.source_id(self.root) + (self.root/'backend-release.json').write_text(json.dumps(dict(buildId=build_id))) + arguments = self.root/'arguments' + env = dict(os.environ, XDG_RUNTIME_DIR=self.temporary.name, + AUDIO_NATIVE_ARGUMENTS=str(arguments)) + for direction in ('output', 'input'): + with self.subTest(direction=direction): + run_process([str(scripts/('audio-'+direction+'-set-default')), '42', + 'Endpoint with spaces', 'Previous endpoint'], + env=env, check=True, capture_output=True, text=True) + socket_flag, socket, request_flag, method, params = arguments.read_text().splitlines() + self.assertEqual((socket_flag, request_flag, method), + ('--socket', '--request', 'default.compat')) + self.assertEqual(socket, str(Path(self.temporary.name)/'omarchy-audio-control'/ + ('backend-'+build_id[:24]+'.sock'))) + self.assertEqual(json.loads(params), dict(direction=direction, id=42, + name='Endpoint with spaces', previous='Previous endpoint')) + def test_plugin_update_rebuilds_for_the_new_identity(self): old = self.prepare() self.source.write_text('release two with changed QML') diff --git a/test/integration/output_groups.py b/test/integration/output_groups.py index 09d285f..50a95fe 100644 --- a/test/integration/output_groups.py +++ b/test/integration/output_groups.py @@ -80,10 +80,10 @@ def member(name): 'device.class=sound priority.session=2000', '--playback-props=target.object=audio_test_output node.name='+name+'_render']) - def player_sink(): + def player_sink(app='Group Test Player'): streams = json.loads(run('pactl', '-f', 'json', 'list', 'sink-inputs')) return next((s['sink'] for s in streams - if s['properties'].get('application.name') == 'Group Test Player'), None) + if s['properties'].get('application.name') == app), None) def group_inputs(group_name): group = next(s for s in sinks() if s['name'] == group_name) @@ -271,6 +271,44 @@ def rejected(action, **params): assert group_name not in final_rules['devices']['favorites'] assert group_name not in final_rules['devices']['hidden'] + for use in ('default', 'stream'): + deferred_id = until(lambda: change('create', name='Deferred cleanup', + members=['audio_test_left', 'audio_test_right'])) + deferred_name = 'omarchy_audio_group_'+deferred_id + deferred_sink = until(lambda: next((s for s in sinks() if s['name'] == deferred_name), None)) + if use == 'default': + run('pactl', 'set-default-sink', deferred_name) + until(lambda: run('pactl', 'get-default-sink').strip() == deferred_name) + else: + pinned = launch(['pw-play', '--raw', '--rate=48000', '--channels=2', '--format=s16', + '--target='+deferred_name, + '--properties=application.name="Orphan Test Player" node.name=audio_test_orphan_player', + '-'], stdin=zero) + until(lambda: player_sink('Orphan Test Player') == deferred_sink['index']) + # External edits and Bluetooth forget can remove a definition while + # the module is in use. The first cleanup must leave playback alone. + rules_path.write_text(json.dumps(final_rules)) + client.wait_state(lambda s: s['stores']['rules']['outputGroups'] == []) + time.sleep(1.5) + assert any(s['name'] == deferred_name for s in sinks()) + if use == 'default': + run('pactl', 'set-default-sink', 'audio_test_left') + until(lambda: run('pactl', 'get-default-sink').strip() == 'audio_test_left') + else: + client.request('health') + stream = next(n for n in client.state['nodes'] if n['name'] == 'audio_test_orphan_player') + target = next(n for n in client.state['nodes'] if n['name'] == 'audio_test_right') + def identity(node): + return dict(generation=client.state['generation'], id=node['id'], serial=node['serial']) + client.request('route.set', dict(identity=identity(stream), target=identity(target), mode='override')) + until(lambda: player_sink('Orphan Test Player') == next(s['index'] for s in sinks() + if s['name'] == 'audio_test_right')) + until(lambda: all(s['name'] != deferred_name for s in sinks())) + if use == 'stream': + assert pinned.poll() is None, 'Cleanup stopped the rerouted player' + stop(pinned) + print('PASS: orphan cleanup retries after default changes and stream moves without replacing nodes', flush=True) + foreign_id = 'ffffffffffffffff' foreign_name = 'omarchy_audio_group_'+foreign_id foreign_module = run('pactl', 'load-module', 'module-null-sink', 'sink_name='+foreign_name).strip() diff --git a/test/integration/panel_lifecycle.py b/test/integration/panel_lifecycle.py new file mode 100644 index 0000000..63babe7 --- /dev/null +++ b/test/integration/panel_lifecycle.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +"""Dismiss the advanced window and its menu when the shared mixer signal fires.""" +import json +import os +from pathlib import Path +import subprocess +import tempfile + +ROOT = Path(__file__).resolve().parents[2] +SHELL = Path(os.environ.get('AUDIO_TEST_OMARCHY_SHELL', '/usr/share/omarchy/shell')) +assert all((SHELL/name).is_dir() for name in ('Ui', 'Commons')), 'Set AUDIO_TEST_OMARCHY_SHELL to an Omarchy shell checkout' + +with tempfile.TemporaryDirectory(prefix='audio-panel-lifecycle-') as temporary: + work = Path(temporary) + for name in ('Ui', 'Commons'): + (work/name).symlink_to(SHELL/name, target_is_directory=True) + source = (ROOT/'test/fixtures/panel-lifecycle.qml').read_text() + fixture = work/'shell.qml' + fixture.write_text(source.replace('ROOT_URL', json.dumps(ROOT.as_uri()+'/'))) + env = {key: os.environ[key] for key in ('PATH', 'LANG') if key in os.environ} + env.update(HOME=temporary, XDG_RUNTIME_DIR=temporary, PIPEWIRE_RUNTIME_DIR=temporary, + PIPEWIRE_REMOTE='absent-panel-test', PULSE_SERVER='unix:'+str(work/'absent-pulse'), + XDG_CONFIG_HOME=str(work/'config'), XDG_STATE_HOME=str(work/'state'), + XDG_CACHE_HOME=str(work/'cache'), QT_QPA_PLATFORM='offscreen', + QT_QUICK_BACKEND='software', DBUS_SYSTEM_BUS_ADDRESS='unix:path='+str(work/'absent-bus')) + result = subprocess.run(['dbus-run-session', '--', 'quickshell', '--no-color', '--path', str(fixture)], + env=env, capture_output=True, text=True, timeout=10) + output = result.stdout+result.stderr + assert result.returncode == 0 and 'PANEL_LIFECYCLE_SUCCESS' in output, output + assert not any(error in output for error in ('PANEL_LIFECYCLE_FAILURE', 'ReferenceError:', 'TypeError:', 'Binding loop')), output +print('PASS: opening the quick mixer closes the advanced window and menus, including proxy summons') diff --git a/test/integration/runtime.py b/test/integration/runtime.py index 6b3367d..b6d27d7 100644 --- a/test/integration/runtime.py +++ b/test/integration/runtime.py @@ -154,12 +154,47 @@ def pipewire(): assert failure['error']['code'] == 'invalid_store' and settings.read_text() == '{broken' settings.write_text('{"version":1,"outputOverdrive":false}') a.wait_state(lambda s: 'settings' not in s['storeErrors']) + b.request('settings.set', dict(key='outputOverdrive', value=True)) + a.wait_state(lambda s: s['stores']['settings']['outputOverdrive'] is True) + backup = settings.with_suffix('.backup') + settings.rename(backup) + a.wait_state(lambda s: s['stores']['settings']['outputOverdrive'] is False) + backup.rename(settings) + a.wait_state(lambda s: s['stores']['settings']['outputOverdrive'] is True) + b.request('settings.set', dict(key='outputOverdrive', value=False)) + print('PASS: moving a store away resets its state; moving it back reloads it', flush=True) scene = dict(name='Privacy', devices=[dict(name='audio_test_output',direction='output',volume=.4,balance=.5,muted=True)]) result = b.request('scene.apply',dict(scene=scene)) assert result['applied'] == 1 and not result['errors'], result captured = b.request('scene.capture',dict(name='Captured')) device = next(d for d in captured['devices'] if d['name'] == 'audio_test_output') assert device['muted'] is False and abs(device['balance']-.5)<.02, device + # Each command fits one frame, while the resulting valid store needs + # snapshot chunks. Saving/deleting must acknowledge without echoing it. + large_scene = dict( + devices=[dict(name=('output_'+str(i)+'_').ljust(160, 'x'), + direction='output', volume=.5) for i in range(64)], + ports=[dict(endpoint=('output_'+str(i)+'_').ljust(160, 'x'), + value=('port_'+str(i)+'_').ljust(160, 'p'), + direction='output') for i in range(64)], + profiles=[dict(card=('card_'+str(i)+'_').ljust(160, 'c'), + profile=('profile_'+str(i)+'_').ljust(160, 'p')) for i in range(64)]) + for i in range(6): + assert b.request('scenes.save', dict(name='Large '+str(i), scene=large_scene)) == dict(outcome='applied') + a.wait_state(lambda s: len(s['stores']['scenes']['scenes']) == i+1) + assert len(json.dumps(a.state['stores']['scenes'])) > 262144 + assert a.state['stores']['scenes']['scenes'][-1]['profiles'] == large_scene['profiles'] + assert b.request('scenes.delete', dict(name='Large 0')) == dict(outcome='applied') + a.wait_state(lambda s: len(s['stores']['scenes']['scenes']) == 5) + assert len(json.dumps(a.state['stores']['scenes'])) > 262144 + reply = b.response(b.send('store.read', dict(store='scenes'))) + assert reply['error']['code'] == 'response_too_large', reply + assert b.request('health')['status'] == 'ok', 'Large store reads must preserve the connection' + for i in range(1, 6): + b.request('scenes.delete', dict(name='Large '+str(i))) + a.wait_state(lambda s: len(s['stores']['scenes']['scenes']) == 5-i) + assert b.request('store.read', dict(store='scenes')) == dict(version=1, scenes=[]) + print('PASS: large scene saves/deletes use bounded replies and complete chunked snapshots', flush=True) # A private source identity exercises job ownership with fake sample # producers. No real microphone or speaker is opened by this test. source = next(n for n in a.state['nodes'] if n['name'] == 'audio_test_input')