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
use super::*;

extern "C" {
    #[link_name = "libspa_rs_types"]
    pub static spa_types: *const spa_type_info;
    #[link_name = "libspa_rs_type_direction"]
    pub static spa_type_direction: *const spa_type_info;
    #[link_name = "libspa_rs_type_choice"]
    pub static spa_type_choice: *const spa_type_info;
    #[link_name = "libspa_rs_type_device_event_id"]
    pub static spa_type_device_event_id: *const spa_type_info;
    #[link_name = "libspa_rs_type_device_event"]
    pub static spa_type_device_event: *const spa_type_info;
    #[link_name = "libspa_rs_type_io"]
    pub static spa_type_io: *const spa_type_info;
    #[link_name = "libspa_rs_type_node_event_id"]
    pub static spa_type_node_event_id: *const spa_type_info;
    #[link_name = "libspa_rs_type_node_event"]
    pub static spa_type_node_event: *const spa_type_info;
    #[link_name = "libspa_rs_type_node_command_id"]
    pub static spa_type_node_command_id: *const spa_type_info;
    #[link_name = "libspa_rs_type_node_command"]
    pub static spa_type_node_command: *const spa_type_info;
    #[link_name = "libspa_rs_type_data_type"]
    pub static spa_type_data_type: *const spa_type_info;
    #[link_name = "libspa_rs_type_meta_type"]
    pub static spa_type_meta_type: *const spa_type_info;
    #[link_name = "libspa_rs_type_control"]
    pub static spa_type_control: *const spa_type_info;
    #[link_name = "libspa_rs_type_param"]
    pub static spa_type_param: *const spa_type_info;
    #[link_name = "libspa_rs_type_prop_float_array"]
    pub static spa_type_prop_float_array: *const spa_type_info;
    #[link_name = "libspa_rs_type_prop_channel_map"]
    pub static spa_type_prop_channel_map: *const spa_type_info;
    #[link_name = "libspa_rs_type_prop_iec958_codec"]
    pub static spa_type_prop_iec958_codec: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_bitorder"]
    pub static spa_type_param_bitorder: *const spa_type_info;
    #[link_name = "libspa_rs_type_props"]
    pub static spa_type_props: *const spa_type_info;
    #[link_name = "libspa_rs_type_prop_info"]
    pub static spa_type_prop_info: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_meta"]
    pub static spa_type_param_meta: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_io"]
    pub static spa_type_param_io: *const spa_type_info;
    #[link_name = "libspa_rs_type_media_type"]
    pub static spa_type_media_type: *const spa_type_info;
    #[link_name = "libspa_rs_type_media_subtype"]
    pub static spa_type_media_subtype: *const spa_type_info;
    #[link_name = "libspa_rs_type_format"]
    pub static spa_type_format: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_buffers"]
    pub static spa_type_param_buffers: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_availability"]
    pub static spa_type_param_availability: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_profile"]
    pub static spa_type_param_profile: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_port_config_mode"]
    pub static spa_type_param_port_config_mode: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_port_config"]
    pub static spa_type_param_port_config: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_route"]
    pub static spa_type_param_route: *const spa_type_info;
    #[link_name = "libspa_rs_type_profiler"]
    pub static spa_type_profiler: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_latency"]
    pub static spa_type_param_latency: *const spa_type_info;
    #[link_name = "libspa_rs_type_param_process_latency"]
    pub static spa_type_param_process_latency: *const spa_type_info;
    #[link_name = "libspa_rs_type_audio_format"]
    pub static spa_type_audio_format: *const spa_type_info;
    #[link_name = "libspa_rs_type_audio_flags"]
    pub static spa_type_audio_flags: *const spa_type_info;
    #[link_name = "libspa_rs_type_audio_channel"]
    pub static spa_type_audio_channel: *const spa_type_info;
    #[link_name = "libspa_rs_type_audio_iec958_codec"]
    pub static spa_type_audio_iec958_codec: *const spa_type_info;
    #[link_name = "libspa_rs_type_bluetooth_audio_codec"]
    pub static spa_type_bluetooth_audio_codec: *const spa_type_info;
    #[link_name = "libspa_rs_type_video_format"]
    pub static spa_type_video_format: *const spa_type_info;
    #[cfg(feature = "v0_3_65")]
    #[link_name = "libspa_rs_type_video_flags"]
    pub static spa_type_video_flags: *const spa_type_info;
    #[cfg(feature = "v0_3_65")]
    #[link_name = "libspa_rs_type_video_interlace_mode"]
    pub static spa_type_video_interlace_mode: *const spa_type_info;
}

#[cfg(test)]
mod test {
    use crate::{spa_type_media_type, SPA_MEDIA_TYPE_audio};

    use std::ffi;

    #[test]
    fn test_libspa_rs_debug_type_find() {
        unsafe {
            let type_info = super::spa_debug_type_find(spa_type_media_type, SPA_MEDIA_TYPE_audio);
            assert_eq!(
                ffi::CStr::from_ptr((*type_info).name),
                c"Spa:Enum:MediaType:audio"
            );
        }
    }

    #[test]
    fn test_libspa_rs_debug_type_find_name() {
        unsafe {
            let name = super::spa_debug_type_find_name(spa_type_media_type, SPA_MEDIA_TYPE_audio);
            assert_eq!(ffi::CStr::from_ptr(name), c"Spa:Enum:MediaType:audio");
        }
    }

    #[test]
    fn test_libspa_rs_debug_type_find_short_name() {
        unsafe {
            let name =
                super::spa_debug_type_find_short_name(spa_type_media_type, SPA_MEDIA_TYPE_audio);
            assert_eq!(ffi::CStr::from_ptr(name), c"audio");
        }
    }
}