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
// 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;
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// An interface for Fireworks Protocol.
///
/// Echo Audio Fireworks devices listen to specific address space for specific request frame. When
/// accepting and handling the request frame, it transfers response frame to specific address in
/// requester. The [`EfwProtocol`][crate::EfwProtocol] is an object interface for the Fireworks protocol.
///
/// ## Signals
///
///
/// #### `responded`
/// Emitted when the unit transfers asynchronous packet as response of Echo Audio Efw
/// transaction and the process successfully reads the content of response from ALSA Efw
/// driver.
///
/// Action
///
/// # Implements
///
/// [`EfwProtocolExt`][trait@crate::prelude::EfwProtocolExt], [`EfwProtocolExtManual`][trait@crate::prelude::EfwProtocolExtManual]
#[doc(alias = "HitakiEfwProtocol")]
pub struct EfwProtocol(Interface<ffi::HitakiEfwProtocol, ffi::HitakiEfwProtocolInterface>);
match fn {
type_ => || ffi::hitaki_efw_protocol_get_type(),
}
}
impl EfwProtocol {
pub const NONE: Option<&'static EfwProtocol> = None;
}
/// Trait containing the part of [`struct@EfwProtocol`] methods.
///
/// # Implementors
///
/// [`EfwProtocol`][struct@crate::EfwProtocol], [`SndEfw`][struct@crate::SndEfw]
pub trait EfwProtocolExt: IsA<EfwProtocol> + 'static {
/// Parse the given buffer for response frame of Fireworks transaction. The buffer should includes
/// one response frames at least. It results in [`responded`][struct@crate::EfwProtocol#responded] per response frame.
/// It's expected that the function is used by any implementation of [`EfwProtocol`][crate::EfwProtocol].
/// ## `buffer`
/// The buffer for transaction frames.
#[doc(alias = "hitaki_efw_protocol_receive_response")]
fn receive_response(&self, buffer: &[u8]) {
let length = buffer.len() as _;
unsafe {
ffi::hitaki_efw_protocol_receive_response(
self.as_ref().to_glib_none().0,
buffer.to_glib_none().0,
length,
);
}
}
/// Transfer asynchronous transaction for request frame of Fireworks transaction. It calls
/// `vfunc::EfwProtocol::transmit_request` internally after composing request frame. It results in
/// [`responded`][struct@crate::EfwProtocol#responded] signal with response parameters when receiving response for the
/// transaction.
/// ## `category`
/// One of category for the transaction.
/// ## `command`
/// One of commands for the transaction.
/// ## `args`
/// An array with elements of quadlet data for
/// arguments of command.
///
/// # Returns
///
/// TRUE if the overall operation finished successfully, else FALSE.
///
/// ## `resp_seqnum`
/// The sequence number to match response.
#[doc(alias = "hitaki_efw_protocol_transmit_request")]
fn transmit_request(
&self,
category: u32,
command: u32,
args: &[u32],
) -> Result<u32, glib::Error> {
let arg_count = args.len() as _;
unsafe {
let mut resp_seqnum = std::mem::MaybeUninit::uninit();
let mut error = std::ptr::null_mut();
let is_ok = ffi::hitaki_efw_protocol_transmit_request(
self.as_ref().to_glib_none().0,
category,
command,
args.to_glib_none().0,
arg_count,
resp_seqnum.as_mut_ptr(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(resp_seqnum.assume_init())
} else {
Err(from_glib_full(error))
}
}
}
}
impl<O: IsA<EfwProtocol>> EfwProtocolExt for O {}