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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, ElemIfaceType};
use glib::translate::*;
glib::wrapper! {
/// A boxed object to express the identifier of element.
///
/// A [`ElemId`][crate::ElemId] is a boxed object to express the identifier of element. It points to a
/// element by two ways; by the numeric identifier, or by the combination of the type of interface,
/// the numeric identifier of device, the numeric identifier of subdevice, the name, and the index.
///
/// The object wraps `struct snd_ctl_elem_id` in UAPI of Linux sound subsystem.
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct ElemId(Boxed<ffi::ALSACtlElemId>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::alsactl_elem_id_get_type(), ptr as *mut _) as *mut ffi::ALSACtlElemId,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::alsactl_elem_id_get_type(), ptr as *mut _),
type_ => || ffi::alsactl_elem_id_get_type(),
}
}
impl ElemId {
/// Allocates and return an instance of [`ElemId`][crate::ElemId] by the name.
/// ## `iface`
/// The interface of element, one of ALSACtlElemIfaceType.
/// ## `device_id`
/// The numeric identifier of device to which the element belongs.
/// ## `subdevice_id`
/// The numeric identifier of subdevice to which the element belongs.
/// ## `name`
/// The name of element, up to 44 byte (=`SNDRV_CTL_ELEM_ID_NAME_MAXLEN`) including
/// terminator.
/// ## `index`
/// The index of element in a set of elements with the same name.
///
/// # Returns
///
/// A [`ElemId`][crate::ElemId].
#[doc(alias = "alsactl_elem_id_new_by_name")]
pub fn new_by_name(
iface: ElemIfaceType,
device_id: u32,
subdevice_id: u32,
name: &str,
index: u32,
) -> ElemId {
unsafe {
from_glib_full(ffi::alsactl_elem_id_new_by_name(
iface.into_glib(),
device_id,
subdevice_id,
name.to_glib_none().0,
index,
))
}
}
/// Allocates and return an instance of [`ElemId`][crate::ElemId] by the numeric identifier.
/// ## `numid`
/// The numeric identifier of the element.
///
/// # Returns
///
/// A [`ElemId`][crate::ElemId].
#[doc(alias = "alsactl_elem_id_new_by_numid")]
pub fn new_by_numid(numid: u32) -> ElemId {
unsafe { from_glib_full(ffi::alsactl_elem_id_new_by_numid(numid)) }
}
#[doc(alias = "alsactl_elem_id_equal")]
fn equal(&self, target: &ElemId) -> bool {
unsafe {
from_glib(ffi::alsactl_elem_id_equal(
self.to_glib_none().0,
target.to_glib_none().0,
))
}
}
/// Get the numeric identifier of device to which the element belongs.
///
/// # Returns
///
///
/// ## `device_id`
/// The numeric identifier of device to which the element belongs.
#[doc(alias = "alsactl_elem_id_get_device_id")]
#[doc(alias = "get_device_id")]
pub fn device_id(&self) -> u32 {
unsafe {
let mut device_id = std::mem::MaybeUninit::uninit();
ffi::alsactl_elem_id_get_device_id(self.to_glib_none().0, device_id.as_mut_ptr());
device_id.assume_init()
}
}
/// Get the interface of element.
///
/// # Returns
///
///
/// ## `iface`
/// The interface of element.
#[doc(alias = "alsactl_elem_id_get_iface")]
#[doc(alias = "get_iface")]
pub fn iface(&self) -> ElemIfaceType {
unsafe {
let mut iface = std::mem::MaybeUninit::uninit();
ffi::alsactl_elem_id_get_iface(self.to_glib_none().0, iface.as_mut_ptr());
from_glib(iface.assume_init())
}
}
/// Get the index of element.
///
/// # Returns
///
///
/// ## `index`
/// The index of element.
#[doc(alias = "alsactl_elem_id_get_index")]
#[doc(alias = "get_index")]
pub fn index(&self) -> u32 {
unsafe {
let mut index = std::mem::MaybeUninit::uninit();
ffi::alsactl_elem_id_get_index(self.to_glib_none().0, index.as_mut_ptr());
index.assume_init()
}
}
/// Get the name of element.
///
/// # Returns
///
///
/// ## `name`
/// The name of element.
#[doc(alias = "alsactl_elem_id_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> glib::GString {
unsafe {
let mut name = std::ptr::null();
ffi::alsactl_elem_id_get_name(self.to_glib_none().0, &mut name);
from_glib_none(name)
}
}
/// Get the numeric identifier of element.
///
/// # Returns
///
///
/// ## `numid`
/// The numeric identifier of element.
#[doc(alias = "alsactl_elem_id_get_numid")]
#[doc(alias = "get_numid")]
pub fn numid(&self) -> u32 {
unsafe {
let mut numid = std::mem::MaybeUninit::uninit();
ffi::alsactl_elem_id_get_numid(self.to_glib_none().0, numid.as_mut_ptr());
numid.assume_init()
}
}
/// Get the numeric identifier of element.
///
/// # Returns
///
///
/// ## `subdevice_id`
/// The numeric identifier of subdevice to which the element belongs.
#[doc(alias = "alsactl_elem_id_get_subdevice_id")]
#[doc(alias = "get_subdevice_id")]
pub fn subdevice_id(&self) -> u32 {
unsafe {
let mut subdevice_id = std::mem::MaybeUninit::uninit();
ffi::alsactl_elem_id_get_subdevice_id(self.to_glib_none().0, subdevice_id.as_mut_ptr());
subdevice_id.assume_init()
}
}
}
impl PartialEq for ElemId {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for ElemId {}
unsafe impl Send for ElemId {}
unsafe impl Sync for ElemId {}