Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions backend-release.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion backend/src/automation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions backend/src/file_watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion backend/src/service/automation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 18 additions & 4 deletions backend/src/service/state.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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?;
Expand All @@ -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)
}
}
Binary file modified bin/omarchy-audio-service
Binary file not shown.
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packaging/manifest.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 3 additions & 0 deletions qml/core/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions qml/panels/AdvancedAudio.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions qml/panels/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/audio-bluetooth-default-compat
Original file line number Diff line number Diff line change
Expand Up @@ -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
105 changes: 105 additions & 0 deletions test/fixtures/panel-lifecycle.qml
Original file line number Diff line number Diff line change
@@ -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") }
}
7 changes: 7 additions & 0 deletions test/fixtures/ui-controls.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 31 additions & 0 deletions test/integration/native_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading
Loading