summaryrefslogtreecommitdiffstats
path: root/meta-pipewire/recipes-multimedia/wireplumber/wireplumber-config-agl/10-default-policy.lua
blob: 333f520fc5f86f68bd71b26c4b5c9fb37ef31977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
-- Default policy config file --

default_policy = {}

default_policy.endpoints = {
  -- [endpoint name] = { endpoint properties }
  ["endpoint.capture"] = {
    ["media.class"] = "Audio/Source",
    ["role"] = "Capture",
  },
  ["endpoint.multimedia"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Multimedia",
  },
  ["endpoint.speech_low"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Speech-Low",
  },
  ["endpoint.custom_low"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Custom-Low",
  },
  ["endpoint.navigation"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Navigation",
  },
  ["endpoint.speech_high"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Speech-High",
  },
  ["endpoint.custom_high"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Custom-High",
  },
  ["endpoint.communication"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Communication",
  },
  ["endpoint.emergency"] = {
    ["media.class"] = "Audio/Sink",
    ["role"] = "Emergency",
  },
}

default_policy.policy = {
  ["move"] = false,  -- moves session items when metadata target.node changes
  ["follow"] = true, -- moves session items to the default device when it has changed

  -- Set to 'true' to disable channel splitting & merging on nodes and enable
  -- passthrough of audio in the same format as the format of the device.
  -- Note that this breaks JACK support; it is generally not recommended
  ["audio.no-dsp"] = false,

  -- how much to lower the volume of lower priority streams when ducking
  -- note that this is a linear volume modifier (not cubic as in the mixer)
  ["duck.level"] = 0.2,

  ["roles"] = {
    ["Capture"] = {
      ["alias"] = { "Multimedia", "Music", "Voice", "Capture" },
      ["priority"] = 25,
      ["action.default"] = "cork",
      ["action.Capture"] = "mix",
      ["media.class"] = "Audio/Source",
    },
    ["Multimedia"] = {
      ["alias"] = { "Movie", "Music", "Game" },
      ["priority"] = 25,
      ["action.default"] = "cork",
    },
    ["Speech-Low"] = {
      ["priority"] = 30,
      ["action.default"] = "cork",
      ["action.Speech-Low"] = "mix",
    },
    ["Custom-Low"] = {
      ["priority"] = 35,
      ["action.default"] = "cork",
      ["action.Custom-Low"] = "mix",
    },
    ["Navigation"] = {
      ["priority"] = 50,
      ["action.default"] = "duck",
      ["action.Navigation"] = "mix",
    },
    ["Speech-High"] = {
      ["priority"] = 60,
      ["action.default"] = "cork",
      ["action.Speech-High"] = "mix",
    },
    ["Custom-High"] = {
      ["priority"] = 65,
      ["action.default"] = "cork",
      ["action.Custom-High"] = "mix",
    },
    ["Communication"] = {
      ["priority"] = 75,
      ["action.default"] = "cork",
      ["action.Communication"] = "mix",
    },
    ["Emergency"] = {
      ["alias"] = { "Alert" },
      ["priority"] = 99,
      ["action.default"] = "cork",
      ["action.Emergency"] = "mix",
    },
  },
}

function default_policy.enable()
  -- Session item factories, building blocks for the session management graph
  -- Do not disable these unless you really know what you are doing
  load_module("si-node")
  load_module("si-audio-adapter")
  load_module("si-standard-link")
  load_module("si-audio-endpoint")

  -- API to access default nodes from scripts
  load_module("default-nodes-api")

  -- API to access mixer controls, needed for volume ducking
  load_module("mixer-api")

  -- Create endpoints statically at startup
  load_script("static-endpoints.lua", default_policy.endpoints)

  -- Create session items for nodes that appear in the graph
  load_script("create-item.lua", default_policy.policy)

  -- Link nodes to each other to make media flow in the graph
  load_script("policy-node.lua", default_policy.policy)

  -- Link client nodes with endpoints to make media flow in the graph
  load_script("policy-endpoint-client.lua", default_policy.policy)
  load_script("policy-endpoint-client-links.lua", default_policy.policy)

  -- Link endpoints with device nodes to make media flow in the graph
  load_script("policy-endpoint-device.lua", default_policy.policy)
end