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
199
// 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, ElemId};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// A GObject-derived object to express the container of array for values specific to element type.
///
/// A [`ElemValue`][crate::ElemValue] includes several types of array for values specific to element type. The
/// arrays shares the same internal storage, thus the user application should decide the type of
/// array according to the type of element when accessing to the array. The object is used for the
/// call of [`CardExt::write_elem_value()`][crate::prelude::CardExt::write_elem_value()] and [`CardExtManual::read_elem_value()`][crate::prelude::CardExtManual::read_elem_value()].
///
/// The object wraps `struct snd_ctl_elem_value` in UAPI of Linux sound subsystem.
///
/// ## Properties
///
///
/// #### `elem-id`
/// The identifier of element.
///
/// Readable
///
/// # Implements
///
/// [`ElemValueExt`][trait@crate::prelude::ElemValueExt], [`ElemValueExtManual`][trait@crate::prelude::ElemValueExtManual]
#[doc(alias = "ALSACtlElemValue")]
pub struct ElemValue(Object<ffi::ALSACtlElemValue, ffi::ALSACtlElemValueClass>);
match fn {
type_ => || ffi::alsactl_elem_value_get_type(),
}
}
impl ElemValue {
pub const NONE: Option<&'static ElemValue> = None;
/// Allocate and return an instance of [`ElemValue`][crate::ElemValue].
///
/// # Returns
///
/// An instance of [`ElemValue`][crate::ElemValue].
#[doc(alias = "alsactl_elem_value_new")]
pub fn new() -> ElemValue {
unsafe { from_glib_full(ffi::alsactl_elem_value_new()) }
}
}
impl Default for ElemValue {
fn default() -> Self {
Self::new()
}
}
/// Trait containing the part of [`struct@ElemValue`] methods.
///
/// # Implementors
///
/// [`ElemValue`][struct@crate::ElemValue]
pub trait ElemValueExt: IsA<ElemValue> + 'static {
#[doc(alias = "alsactl_elem_value_equal")]
fn equal(&self, target: &impl IsA<ElemValue>) -> bool {
unsafe {
from_glib(ffi::alsactl_elem_value_equal(
const_override(self.as_ref().to_glib_none().0),
target.as_ref().to_glib_none().0,
))
}
}
/// Copy the array into internal storage for [`ElemType`][crate::ElemType].BYTES element.
/// ## `values`
/// The array for 8 bit unsigned integer values.
#[doc(alias = "alsactl_elem_value_set_bytes")]
fn set_bytes(&self, values: &[u8]) {
let value_count = values.len() as _;
unsafe {
ffi::alsactl_elem_value_set_bytes(
self.as_ref().to_glib_none().0,
values.to_glib_none().0,
value_count,
);
}
}
/// Copy the array into internal storage for [`ElemType`][crate::ElemType].ENUMERATED element.
/// ## `values`
/// The array for enumeration index values.
#[doc(alias = "alsactl_elem_value_set_enum")]
fn set_enum(&self, values: &[u32]) {
let value_count = values.len() as _;
unsafe {
ffi::alsactl_elem_value_set_enum(
self.as_ref().to_glib_none().0,
values.to_glib_none().0,
value_count,
);
}
}
/// Copy the channel status bits into internal storage for [`ElemType`][crate::ElemType].IEC60958 element.
/// ## `status`
/// The array of byte data for channel status bits of IEC 60958.
#[doc(alias = "alsactl_elem_value_set_iec60958_channel_status")]
fn set_iec60958_channel_status(&self, status: &[u8]) {
let length = status.len() as _;
unsafe {
ffi::alsactl_elem_value_set_iec60958_channel_status(
self.as_ref().to_glib_none().0,
status.to_glib_none().0,
length,
);
}
}
/// Copy the user data bits into internal storage for [`ElemType`][crate::ElemType].IEC60958 element.
/// ## `data`
/// The array of byte data for user data bits of IEC 60958.
#[doc(alias = "alsactl_elem_value_set_iec60958_user_data")]
fn set_iec60958_user_data(&self, data: &[u8]) {
let length = data.len() as _;
unsafe {
ffi::alsactl_elem_value_set_iec60958_user_data(
self.as_ref().to_glib_none().0,
data.to_glib_none().0,
length,
);
}
}
/// Copy the array into internal storage for [`ElemType`][crate::ElemType].INTEGER element.
/// ## `values`
/// The array for 32 bit signed integer values.
#[doc(alias = "alsactl_elem_value_set_int")]
fn set_int(&self, values: &[i32]) {
let value_count = values.len() as _;
unsafe {
ffi::alsactl_elem_value_set_int(
self.as_ref().to_glib_none().0,
values.to_glib_none().0,
value_count,
);
}
}
/// Copy the array into internal storage for [`ElemType`][crate::ElemType].INTEGER64 element.
/// ## `values`
/// The array for 64 bit signed integer values.
#[doc(alias = "alsactl_elem_value_set_int64")]
fn set_int64(&self, values: &[i64]) {
let value_count = values.len() as _;
unsafe {
ffi::alsactl_elem_value_set_int64(
self.as_ref().to_glib_none().0,
values.to_glib_none().0,
value_count,
);
}
}
/// The identifier of element.
#[doc(alias = "elem-id")]
fn elem_id(&self) -> Option<ElemId> {
ObjectExt::property(self.as_ref(), "elem-id")
}
#[doc(alias = "elem-id")]
fn connect_elem_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_elem_id_trampoline<P: IsA<ElemValue>, F: Fn(&P) + 'static>(
this: *mut ffi::ALSACtlElemValue,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(ElemValue::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::elem-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_elem_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<ElemValue>> ElemValueExt for O {}