Debian Codegraph @

src/stereo-link.h

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2022-2025 Geoffrey D. Bennett <[email protected]>
2 // SPDX-License-Identifier: GPL-3.0-or-later
3
4 #pragma once
5
6 #include "alsa.h"
7
8 // Maximum length for stereo pair names
9 #define MAX_PAIR_NAME_LEN 32
10
11 // Initialise stereo link elements for all routing sources and sinks
12 // - Creates simulated ALSA boolean elements for link state
13 // - Creates simulated ALSA BYTES elements for pair names
14 // - Loads values from state file
15 // - Registers save callbacks
16 // Must be called after port_enable_init()
17 void stereo_link_init(struct alsa_card *card);
18
19 // Check if a routing source is linked to its partner (forms stereo pair)
20 // Returns 1 if linked, 0 if not linked or no valid partner
21 int is_src_linked(struct routing_src *src);
22
23 // Check if a routing sink is linked to its partner (forms stereo pair)
24 // Returns 1 if linked, 0 if not linked or no valid partner
25 int is_snk_linked(struct routing_snk *snk);
26
27 // Get the partner source for a routing source (adjacent L/R pair)
28 // Returns NULL if no valid partner exists
29 struct routing_src *get_src_partner(struct routing_src *src);
30
31 // Get the partner sink for a routing sink (adjacent L/R pair)
32 // Returns NULL if no valid partner exists
33 struct routing_snk *get_snk_partner(struct routing_snk *snk);
34
35 // Check if a routing source should be displayed (not hidden as R of linked pair)
36 // Returns 1 if should display, 0 if hidden
37 int should_display_src(struct routing_src *src);
38
39 // Check if a routing sink should be displayed (not hidden as R of linked pair)
40 // Returns 1 if should display, 0 if hidden
41 int should_display_snk(struct routing_snk *snk);
42
43 // Get the link element for a routing source pair
44 // Returns NULL if not available (element stored on left channel)
45 struct alsa_elem *get_src_link_elem(struct routing_src *src);
46
47 // Get the link element for a routing sink pair
48 // Returns NULL if not available (element stored on left channel)
49 struct alsa_elem *get_snk_link_elem(struct routing_snk *snk);
50
51 // Get the pair name element for a routing source pair
52 // Returns NULL if not available (element stored on left channel)
53 struct alsa_elem *get_src_pair_name_elem(struct routing_src *src);
54
55 // Get the pair name element for a routing sink pair
56 // Returns NULL if not available (element stored on left channel)
57 struct alsa_elem *get_snk_pair_name_elem(struct routing_snk *snk);
58
59 // Check if source has a valid partner for stereo linking
60 // A valid pair is two adjacent channels of the same type (odd/even)
61 int src_has_valid_partner(struct routing_src *src);
62
63 // Check if sink has a valid partner for stereo linking
64 // A valid pair is two adjacent channels of the same type (odd/even)
65 int snk_has_valid_partner(struct routing_snk *snk);
66
67 // Get the stereo pair display name for a linked source pair
68 // Returns the pair name if set, otherwise "L Name / R Name" format
69 // Returns newly allocated string that must be freed
70 char *get_src_pair_display_name(struct routing_src *src);
71
72 // Get the stereo pair display name for a linked sink pair
73 // Returns the pair name if set, otherwise "L Name / R Name" format
74 // Returns newly allocated string that must be freed
75 char *get_snk_pair_display_name(struct routing_snk *snk);
76
77 // Schedule debounced UI updates for stereo link changes
78 void schedule_stereo_link_ui_update(struct alsa_card *card);
79
80 // Check if source is the left channel of a potential pair (odd lr_num)
81 int is_src_left_channel(struct routing_src *src);
82
83 // Check if sink is the left channel of a potential pair (odd lr_num)
84 int is_snk_left_channel(struct routing_snk *snk);
85
86 // Get the generic/constructed pair name for a source (e.g., "PCM 1–2")
87 // Used for fixed labels in I/O config window
88 // Returns newly allocated string that must be freed
89 char *get_src_generic_pair_name(struct routing_src *src);
90
91 // Get the generic/constructed pair name for a sink (e.g., "PCM 1–2")
92 // Used for fixed labels in I/O config window
93 // Returns newly allocated string that must be freed
94 char *get_snk_generic_pair_name(struct routing_snk *snk);
95
96 // Get default pair name for a source (device-specific or constructed)
97 // Used for display in routing window when no custom name is set
98 // Returns newly allocated string that must be freed
99 char *get_src_default_pair_name(struct routing_src *src);
100
101 // Get default pair name for a sink (device-specific or constructed)
102 // Used for display in routing window when no custom name is set
103 // Returns newly allocated string that must be freed
104 char *get_snk_default_pair_name(struct routing_snk *snk);
105
106 // Register talkback sync callback for a mixer output source
107 // Called from window-routing.c after talkback_elem is set
108 void stereo_link_register_talkback_callback(struct routing_src *src);