Merge origin/main into better-icons
CI / check (pull_request) Failing after 10s
CI / native (pull_request) Successful in 1m9s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 00:48:27 +00:00
commit 3ac96fea35
16 files changed
+503 -18

No files matched your search

+50 -1
View File
@@ -103,6 +103,18 @@ extern "C" fn ffi_set_default(kind : Int32, id : Int32) -> Int32 = "mm_wp_set_de
///|
extern "C" fn ffi_move_stream(stream : Int32, device : Int32) -> Int32 = "mm_wp_move_stream"
///|
extern "C" fn ffi_meter_start(id : Int32, kind : Int32) -> Int32 = "mm_wp_meter_start"
///|
extern "C" fn ffi_meter_stop(id : Int32) = "mm_wp_meter_stop"
///|
extern "C" fn ffi_meter_stop_all() = "mm_wp_meter_stop_all"
///|
extern "C" fn ffi_meter_take(id : Int32) -> Double = "mm_wp_meter_take"
///|
/// NUL-terminated UTF-8 for C.
fn cstr(s : String) -> Bytes {
@@ -158,7 +170,9 @@ pub fn node_prop(id : Int32, key : String) -> String {
///|
/// Current state of a node as a model node, or None if it is gone.
pub fn read_node(id : Int32) -> @model.Node? {
if ffi_node_exists(id) == 0 {
// Peak-meter streams (ours, pavucontrol's via pipewire-pulse) are not
// something to show or control.
if ffi_node_exists(id) == 0 || node_prop(id, "stream.monitor") == "true" {
return None
}
let nch = ffi_query_volume(id)
@@ -278,3 +292,38 @@ pub fn set_default_source(id : Int32) -> Bool {
pub fn move_stream(stream_id : Int32, device_id : Int32) -> Bool {
ffi_move_stream(stream_id, device_id) != 0
}
///|
/// Start a live peak meter on a sink, source or playback stream (other
/// kinds have nothing to meter). True if one is running for `id`.
pub fn meter_start(id : Int32, kind : @model.NodeKind) -> Bool {
let k = match kind {
Sink => 0
Source => 1
PlaybackStream => 2
RecordStream | Other => return false
}
ffi_meter_start(id, k) != 0
}
///|
pub fn meter_stop(id : Int32) -> Unit {
ffi_meter_stop(id)
}
///|
pub fn meter_stop_all() -> Unit {
ffi_meter_stop_all()
}
///|
/// Linear peak (0..1, may exceed 1 when clipping) since the last call, or
/// None if `id` has no meter.
pub fn meter_take(id : Int32) -> Double? {
let p = ffi_meter_take(id)
if p < 0.0 {
None
} else {
Some(p)
}
}