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
// Copyright The pipewire-rs Contributors.
// SPDX-License-Identifier: MIT
//! SPA interface.
/// Call a method on a spa_interface.
///
/// This needs to be called from within an `unsafe` block.
///
/// The macro always takes at least three arguments:
/// 1. A pointer to a C struct that can be casted to a spa_interface.
/// 2. The type of the interfaces methods struct.
/// 3. The name of the method that should be called.
///
/// All additional arguments are added as arguments to the call in the order they are provided.
///
/// The macro returns whatever the called method returns, for example an `i32`, or `()` if the method returns nothing.
///
/// # Examples
/// Here we call the sync method on a `pipewire_sys::pw_core` object.
/// ```
/// use pipewire_sys as pw_sys;
/// use libspa as spa;
///
/// struct Core {
/// ptr: *mut pw_sys::pw_core
/// }
///
/// impl Core {
/// fn sync(&self, seq: i32) -> i32 {
/// unsafe {
/// spa::spa_interface_call_method!(
/// &self.ptr, pw_sys::pw_core_methods, sync, pipewire::PW_ID_CORE, seq
/// )
/// }
/// }
/// }
/// ```