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
// 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::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// A set of basic interfaces to operate isochronous context on 1394 OHCI hardware.
///
/// [`FwIsoCtx`][crate::FwIsoCtx] includes interfaces to operate 1394 OHCI hardware for isochronous communication
/// by any kind of contexts.
///
/// ## Properties
///
///
/// #### `bytes-per-chunk`
/// The number of bytes per chunk in buffer.
///
/// Readable
///
///
/// #### `chunks-per-buffer`
/// The number of chunks per buffer.
///
/// Readable
///
/// ## Signals
///
///
/// #### `stopped`
/// Emitted when isochronous context is stopped.
///
/// Action
///
/// # Implements
///
/// [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual]
#[doc(alias = "HinokoFwIsoCtx")]
pub struct FwIsoCtx(Interface<ffi::HinokoFwIsoCtx, ffi::HinokoFwIsoCtxInterface>);
match fn {
type_ => || ffi::hinoko_fw_iso_ctx_get_type(),
}
}
impl FwIsoCtx {
pub const NONE: Option<&'static FwIsoCtx> = None;
}
/// Trait containing the part of [`struct@FwIsoCtx`] methods.
///
/// # Implementors
///
/// [`FwIsoCtx`][struct@crate::FwIsoCtx], [`FwIsoIrMultiple`][struct@crate::FwIsoIrMultiple], [`FwIsoIrSingle`][struct@crate::FwIsoIrSingle], [`FwIsoIt`][struct@crate::FwIsoIt]
pub trait FwIsoCtxExt: IsA<FwIsoCtx> + 'static {
/// Create [`glib::Source`][crate::glib::Source] for [`gLib::MainContext`][crate::glib::MainContext]
/// to dispatch events for isochronous context.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
///
/// ## `source`
/// A [`glib::Source`][crate::glib::Source].
#[doc(alias = "hinoko_fw_iso_ctx_create_source")]
fn create_source(&self) -> Result<glib::Source, glib::Error> {
unsafe {
let mut source = std::ptr::null_mut();
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinoko_fw_iso_ctx_create_source(
self.as_ref().to_glib_none().0,
&mut source,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(from_glib_full(source))
} else {
Err(from_glib_full(error))
}
}
}
/// Flush isochronous context until recent isochronous cycle. The call of function forces the
/// context to queue any type of interrupt event for the recent isochronous cycle. Application can
/// process the content of isochronous packet without waiting for actual hardware interrupt.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinoko_fw_iso_ctx_flush_completions")]
fn flush_completions(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinoko_fw_iso_ctx_flush_completions(
self.as_ref().to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Release the contest from 1394 OHCI hardware.
#[doc(alias = "hinoko_fw_iso_ctx_release")]
fn release(&self) {
unsafe {
ffi::hinoko_fw_iso_ctx_release(self.as_ref().to_glib_none().0);
}
}
/// Stop isochronous context.
#[doc(alias = "hinoko_fw_iso_ctx_stop")]
fn stop(&self) {
unsafe {
ffi::hinoko_fw_iso_ctx_stop(self.as_ref().to_glib_none().0);
}
}
/// Unmap intermediate buffer shared with 1394 OHCI hardware for the context.
#[doc(alias = "hinoko_fw_iso_ctx_unmap_buffer")]
fn unmap_buffer(&self) {
unsafe {
ffi::hinoko_fw_iso_ctx_unmap_buffer(self.as_ref().to_glib_none().0);
}
}
/// The number of bytes per chunk in buffer.
#[doc(alias = "bytes-per-chunk")]
fn bytes_per_chunk(&self) -> u32 {
ObjectExt::property(self.as_ref(), "bytes-per-chunk")
}
/// The number of chunks per buffer.
#[doc(alias = "chunks-per-buffer")]
fn chunks_per_buffer(&self) -> u32 {
ObjectExt::property(self.as_ref(), "chunks-per-buffer")
}
/// Emitted when isochronous context is stopped.
/// ## `error`
/// A [`glib::Error`][crate::glib::Error].
#[doc(alias = "stopped")]
fn connect_stopped<F: Fn(&Self, Option<&glib::Error>) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn stopped_trampoline<
P: IsA<FwIsoCtx>,
F: Fn(&P, Option<&glib::Error>) + 'static,
>(
this: *mut ffi::HinokoFwIsoCtx,
error: *mut glib::ffi::GError,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
FwIsoCtx::from_glib_borrow(this).unsafe_cast_ref(),
Option::<glib::Error>::from_glib_borrow(error)
.as_ref()
.as_ref(),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"stopped".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
stopped_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_stopped(&self, error: Option<&glib::Error>) {
self.emit_by_name::<()>("stopped", &[&error]);
}
#[doc(alias = "bytes-per-chunk")]
fn connect_bytes_per_chunk_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bytes_per_chunk_trampoline<
P: IsA<FwIsoCtx>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HinokoFwIsoCtx,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwIsoCtx::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::bytes-per-chunk".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_bytes_per_chunk_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "chunks-per-buffer")]
fn connect_chunks_per_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_chunks_per_buffer_trampoline<
P: IsA<FwIsoCtx>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HinokoFwIsoCtx,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwIsoCtx::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::chunks-per-buffer".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_chunks_per_buffer_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<FwIsoCtx>> FwIsoCtxExt for O {}