[pulseaudio-discuss] [Vala] Issues will vala and pulse vapi
astavale at yahoo.co.uk
Sat Nov 21 04:33:41 PST 2015
> From: Aaron Paden <aaronbpaden at gmail.com>
> Sent: Saturday, 21 November 2015, 0:17
> Subject: [Vala] Issues will vala and pulse vapi
> So I was asking around IRC (both channels) about why a personal
> project I was working on was generating a non-existent
> pulse_audio_source_info_destroy, and it looks like the vapi file is
> possibly the issue. I'm not that familiar with either vala or pulse,
> so possibly I'm just doing something really stupid, but it looks like
> the issue is that vala is expecting to manage a SourceInfo struct,
> while SourceInfo is actually only provided as a const pointer in the
> API (I think) and doesn't have any memory management.
> I was looking around the vapi file, but I'm not sure how to fix it. I
> think SourceInfo should be unowned in the api, but I'm not sure how to
> denote that for structs. Or perhaps there is a ccode for that? Is
> there an index of ccode attributes somewhere?
>  http://paste.fedoraproject.org/292593/88300144/
This looks complex so I can only give a few pointers.
Does the code actually compile or are you getting an error about an
You are using SourceInfo in two places. Once as a field in your
SinkSourceList class, this is an ArrayList of SourceInfo. The other
is when you iterate over that field as part of your main function.
If you are getting an error, which of those sections of code is giving
>From an object oriented design point of view your SinkSoureList
class is doing too much. Initialisation should be done elsewhere
and I think it is unusual to have GLib.MainLoop within a class.
Some refactoring would be helpful here to see the problem more
Your callback that adds the SourceInfo to the ArrayList is a closure.
That is the enclosing context is passed as part of the callback. It
doesn't look as though PulseAudio uses that. It would be better to
define the callback as a method in the SourceInfo class then pass
the callback as this.my_callback, e.g.
For an explanation of callbacks with and without context see:
If you end up digging deep into the VAPI this may also help:
For a list of CCode attributes see:
If you are not familiar with Vala structs take a look at:
and also "boxing" structs in collections:
Although you have "boxed" the struct in your code.
Hope that helps a little,
More information about the pulseaudio-discuss