> 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[1] 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? > > [1] 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 unresolved symbol? 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 the error? >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 clearly. 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. https://wiki.gnome.org/Projects/Vala/PulseAudioSamples For an explanation of callbacks with and without context see: https://wiki.gnome.org/Projects/Vala/LegacyBindings#Delegates If you end up digging deep into the VAPI this may also help: http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-March/009383.html For a list of CCode attributes see: https://wiki.gnome.org/Projects/Vala/Manual/Attributes#CCode_Attribute If you are not familiar with Vala structs take a look at: https://wiki.gnome.org/Projects/Vala/Tutorial#Structs and also "boxing" structs in collections: http://stackoverflow.com/questions/14096999/vala-interface-generics-compiler-error Although you have "boxed" the struct in your code. Hope that helps a little, Al