Hi,

I wanted to enumerate the ports on the cards through vala today. I
quickly found that the vala binding was not up-to-date, so I added
fields for that (see attachment).

However, to be able to access the card ports, I needed to do two things
differently from how the existing arrays look:

 1) I needed to add this line to indicate the length of the array:

[CCode (array_length_cname="n_ports", array_length_type="uint32")]

 2) I needed to add a question mark to indicate these are
pointer-to-pointers (pa_card_port_info **). Otherwise vala would think
they are simple pointers (pa_card_port_info *) and fail with a segfault.

This raises the question if anybody ever has used these arrays before
and got them to work, or if I should just change this on all arrays
(with pointer-to-pointers)? Anybody who knows?

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
diff --git a/vala/libpulse.vapi b/vala/libpulse.vapi
index eb8dfa1..6e34df6 100644
--- a/vala/libpulse.vapi
+++ b/vala/libpulse.vapi
@@ -1348,6 +1348,19 @@ namespace PulseAudio {
                 public uint32 priority;
         }
 
+        [CCode (cname="pa_card_port_info", has_type_id=false)]
+        public struct CardPortInfo {
+                public string name;
+                public string description;
+                public uint32 priority;
+                public int available;
+                public int direction;
+                public uint32 n_profiles;
+                public CardProfileInfo[] profiles;
+                public Proplist proplist;
+                public int64 latency_offset;
+        }
+
         [CCode (cname="pa_card_info", has_type_id=false)]
         public struct CardInfo {
                 public uint32 index;
@@ -1358,6 +1371,9 @@ namespace PulseAudio {
                 public CardProfileInfo[] profiles;
                 public CardProfileInfo *active_profile;
                 public Proplist proplist;
+                public uint32 n_ports;
+                [CCode (array_length_cname="n_ports", array_length_type="uint32")]
+                public CardPortInfo?[] ports;
         }
 
         [CCode (cname="pa_sink_input_info", has_type_id=false)]
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to