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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
// 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::{ClientInfo, ClientPool, PortInfo, QueueInfo, SystemInfo};
use glib::translate::*;

/// Get the list of clients as the numeric identifier.
///
/// The call of function executes `open(2)``, ``close(2)``, and ``ioctl(2)`` system calls with
/// `SNDRV_SEQ_IOCTL_CLIENT_ID`, `SNDRV_SEQ_IOCTL_SYSTEM_INFO`, and
/// `SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT` command for ALSA sequencer character device.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `entries`
/// The array with elements for numeric identified of
///           client. One of [`SpecificClientId`][crate::SpecificClientId] can be included in result as well as any
///           numeric value.
#[doc(alias = "alsaseq_get_client_id_list")]
#[doc(alias = "get_client_id_list")]
pub fn client_id_list() -> Result<Vec<u8>, glib::Error> {
    unsafe {
        let mut entries = std::ptr::null_mut();
        let mut entry_count = std::mem::MaybeUninit::uninit();
        let mut error = std::ptr::null_mut();
        let is_ok =
            ffi::alsaseq_get_client_id_list(&mut entries, entry_count.as_mut_ptr(), &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(FromGlibContainer::from_glib_full_num(
                entries,
                entry_count.assume_init() as _,
            ))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the information of client according to the numeric ID.
///
/// The call of function executes `open(2)``, ``close(2)``, and ``ioctl(2)`` system calls with
/// `SNDRV_SEQ_IOCTL_GET_CLIENT_INFO` command for ALSA sequencer character device.
/// ## `client_id`
/// The numeric identifier of client to query. One of [`SpecificClientId`][crate::SpecificClientId] is
///             available as well as any numeric value.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `client_info`
/// A [`ClientInfo`][crate::ClientInfo] for the client.
#[doc(alias = "alsaseq_get_client_info")]
#[doc(alias = "get_client_info")]
pub fn client_info(client_id: u8) -> Result<ClientInfo, glib::Error> {
    unsafe {
        let mut client_info = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_client_info(client_id, &mut client_info, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(client_info))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get statistical information of memory pool for the given client.
///
/// The call of function executes `open(2)`, `close(2)`, and `ioctl(2)` system calls with
/// `SNDRV_SEQ_IOCTL_GET_CLIENT_POOL` command for ALSA sequencer character device.
/// ## `client_id`
/// The numeric ID of client to query. One of [`SpecificClientId`][crate::SpecificClientId] is available as
///             well as any numeric value.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `client_pool`
/// The information of memory pool for the client.
#[doc(alias = "alsaseq_get_client_pool")]
#[doc(alias = "get_client_pool")]
pub fn client_pool(client_id: u8) -> Result<ClientPool, glib::Error> {
    unsafe {
        let mut client_pool = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_client_pool(client_id, &mut client_pool, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(client_pool))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the list of numeric identifiers for port added by the client.
///
/// The call of function executes `open(2)``, ``close(2)``, and ``ioctl(2)`` system calls with
/// `SNDRV_SEQ_IOCTL_GET_CLIENT_INFO` and `SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT` commands for ALSA
/// sequencer character device.
/// ## `client_id`
/// The numeric ID of client to query. One of [`SpecificClientId`][crate::SpecificClientId] is available as
///             well as any numeric value.
///
/// # Returns
///
///
/// ## `entries`
/// The array with elements for numeric identifier of
///           port. One of [`SpecificPortId`][crate::SpecificPortId] is available as well as any numeric value.
#[doc(alias = "alsaseq_get_port_id_list")]
#[doc(alias = "get_port_id_list")]
pub fn port_id_list(client_id: u8) -> Result<Vec<u8>, glib::Error> {
    unsafe {
        let mut entries = std::ptr::null_mut();
        let mut entry_count = std::mem::MaybeUninit::uninit();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_port_id_list(
            client_id,
            &mut entries,
            entry_count.as_mut_ptr(),
            &mut error,
        );
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(FromGlibContainer::from_glib_full_num(
                entries,
                entry_count.assume_init() as _,
            ))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the information of port in client.
///
/// The call of function executes `open(2)`, `close(2)`, and `ioctl(2)` system calls with
/// `SNDRV_SEQ_IOCTL_GET_PORT_INFO` command for ALSA sequencer character device.
/// ## `client_id`
/// The numeric identifier of client to query. One of [`SpecificClientId`][crate::SpecificClientId] is
///             available as well as any numerica value.
/// ## `port_id`
/// The numeric identifier of port in the client. One of [`SpecificPortId`][crate::SpecificPortId] is
///           available as well as any numeric value.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `port_info`
/// A [`PortInfo`][crate::PortInfo] for the port.
#[doc(alias = "alsaseq_get_port_info")]
#[doc(alias = "get_port_info")]
pub fn port_info(client_id: u8, port_id: u8) -> Result<PortInfo, glib::Error> {
    unsafe {
        let mut port_info = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_port_info(client_id, port_id, &mut port_info, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(port_info))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the list of queue in ALSA Sequencer.
///
/// The call of function executes `open(2)`, `close(2)`, and `ioctl(2)` system calls with
/// `SNDRV_SEQ_IOCTL_SYSTEM_INFO` and `SNDRV_SEQ_IOCTL_GET_QUEUE_INFO` commands for ALSA
/// sequencer character device.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `entries`
/// The array of elements for numeric identifier of queue.
#[doc(alias = "alsaseq_get_queue_id_list")]
#[doc(alias = "get_queue_id_list")]
pub fn queue_id_list() -> Result<Vec<u8>, glib::Error> {
    unsafe {
        let mut entries = std::ptr::null_mut();
        let mut entry_count = std::mem::MaybeUninit::uninit();
        let mut error = std::ptr::null_mut();
        let is_ok =
            ffi::alsaseq_get_queue_id_list(&mut entries, entry_count.as_mut_ptr(), &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(FromGlibContainer::from_glib_full_num(
                entries,
                entry_count.assume_init() as _,
            ))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the information of queue, according to the numeric ID.
///
/// The call of function executes `open(2)`, `close(2)`, and `ioctl(2)` system calls with
/// `SNDRV_SEQ_IOCTL_GET_QUEUE_INFO` command for ALSA sequencer character device.
/// ## `queue_id`
/// The numeric ID of queue. One of [`SpecificQueueId`][crate::SpecificQueueId] is available as well.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `queue_info`
/// The information of queue.
#[doc(alias = "alsaseq_get_queue_info_by_id")]
#[doc(alias = "get_queue_info_by_id")]
pub fn queue_info_by_id(queue_id: u8) -> Result<QueueInfo, glib::Error> {
    unsafe {
        let mut queue_info = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_queue_info_by_id(queue_id, &mut queue_info, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(queue_info))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get the information of queue, according to the name string.
///
/// The call of function executes `open(2)`, `close(2)`, and `ioctl(2)` system calls with
/// `SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE` command for ALSA sequencer character device.
/// ## `name`
/// The name string of queue to query.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `queue_info`
/// The information of queue.
#[doc(alias = "alsaseq_get_queue_info_by_name")]
#[doc(alias = "get_queue_info_by_name")]
pub fn queue_info_by_name(name: &str) -> Result<QueueInfo, glib::Error> {
    unsafe {
        let mut queue_info = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok =
            ffi::alsaseq_get_queue_info_by_name(name.to_glib_none().0, &mut queue_info, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(queue_info))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Allocate devnode string for ALSA Sequencer and return it when exists.
///
/// Nodes under sound subsystem in sysfs are used to gather the information.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `devnode`
/// The devnode of ALSA Sequencer.
#[doc(alias = "alsaseq_get_seq_devnode")]
#[doc(alias = "get_seq_devnode")]
pub fn seq_devnode() -> Result<glib::GString, glib::Error> {
    unsafe {
        let mut devnode = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_seq_devnode(&mut devnode, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(devnode))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Allocate sysname string for ALSA sequencer and return it when exists.
///
/// Nodes under sound subsystem in sysfs are used to gather the information.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `sysname`
/// The sysname of ALSA Sequencer.
#[doc(alias = "alsaseq_get_seq_sysname")]
#[doc(alias = "get_seq_sysname")]
pub fn seq_sysname() -> Result<glib::GString, glib::Error> {
    unsafe {
        let mut sysname = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_seq_sysname(&mut sysname, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(sysname))
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Get information of ALSA Sequencer.
///
/// The call of function executes `open(2)``, ``close(2)``, and ``ioctl(2)`` system calls with
/// `SNDRV_SEQ_IOCTL_SYSTEM_INFO` command for ALSA sequencer character device.
///
/// # Returns
///
/// [`true`] when the overall operation finishes successfully, else [`false`].
///
/// ## `system_info`
/// The information of ALSA Sequencer.
#[doc(alias = "alsaseq_get_system_info")]
#[doc(alias = "get_system_info")]
pub fn system_info() -> Result<SystemInfo, glib::Error> {
    unsafe {
        let mut system_info = std::ptr::null_mut();
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::alsaseq_get_system_info(&mut system_info, &mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(from_glib_full(system_info))
        } else {
            Err(from_glib_full(error))
        }
    }
}