Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
'Twas brillig, and Alexander Kurtz at 16/04/11 20:57 did gyre and gimble: > Please merge this into master if you have no objections. Well you know this stuff better than me. I've merged it in my tree now. Sean if you have any objections please shout before I push it (likely tomorrow). Alexander, if possible in future if you could provide git format-patch style diffs, it would make applying them easier for me (and preserving your authorship). It doesn't matter with a couple of simpler patches but for anything larger it would be appreciated! Cheers Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Hi, I think I got it: With the attached patch I am successfully able to use channel maps in vala in my program. Here are the details: 1. Remove the "has_destroy_function=false" attribute. It was only necessary because of a bug in vala which is fixed in 0.12. [1] 2. Add sizes to all fixed-size arrays to make vala recognize them as such. Using symbolic constants for this is not yet supported. [2] 3. CardInfo struct: Move the brackets in the list of available profiles to the type to make it clear that this is a dynamically-sized array. [3] Please merge this into master if you have no objections. Best regards Alexander Kurtz [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622773 [2] https://bugzilla.gnome.org/show_bug.cgi?id=647788 [3] http://0pointer.de/lennart/projects/pulseaudio/doxygen/structpa__card__info.html diff -Naur a/libpulse.vapi b/libpulse.vapi --- a/libpulse.vapi 2011-04-05 12:24:12.0 +0200 +++ b/libpulse.vapi 2011-04-14 20:31:28.876372889 +0200 @@ -243,7 +243,8 @@ [CCode (cname="pa_cvolume")] public struct CVolume { public uint8 channels; -public Volume values[]; +// TODO: Replace array length with CHANNELS_MAX once vala's bug #647788 is fixed +public Volume values[32]; [CCode (cname="PA_SW_CVOLUME_SNPRINT_DB_MAX")] public static const size_t SW_SNPRINT_DB_MAX; @@ -373,10 +374,11 @@ public unowned CVolume? dec(Volume minus = 1); } -[CCode (cname="pa_channel_map",has_destroy_function=false)] +[CCode (cname="pa_channel_map")] public struct ChannelMap { public uint8 channels; -public ChannelPosition map[]; +// TODO: Replace array length with CHANNELS_MAX once vala's bug #647788 is fixed +public ChannelPosition map[32]; [CCode (cname="PA_CHANNEL_MAP_SNPRINT_MAX")] public static const size_t SNPRINT_MAX; @@ -1350,7 +1352,7 @@ public uint32 owner_module; public string driver; public uint32 n_profiles; -public CardProfileInfo profiles[]; +public CardProfileInfo[] profiles; public CardProfileInfo *active_profile; public Proplist proplist; } signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Am Mittwoch, den 30.03.2011, 13:44 -0400 schrieb Sean McNamara: > As to your bugs in [3] (from your message): Please see here for a short status update: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345#27 Best regards Alexander Kurtz signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Am Donnerstag, den 14.04.2011, 10:22 -0400 schrieb Sean McNamara: > So +1 for committing Alex's patch. Thanks, that's good news. @Colin: Please give me some more time (1-2 days) before committing this. Best regards Alexander Kurtz signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Hi guys, On Thu, Apr 14, 2011 at 9:36 AM, Colin Guthrie wrote: > 'Twas brillig, and Alexander Kurtz at 14/04/11 13:52 did gyre and gimble: >> What do you think? Does the current upstream libpulse.vapi file really >> work for you w/o modifications? > > No I seem to get this error too. I'm sure I did test the previous fix, > but perhaps not :s I think something either changed in Vala or in PulseAudio. When I tested the previous fix against the Vala shipped in Ubuntu 10.10, everything was working fine -- no build-time errors. But I get the same error message as Alexander when I try with pulseaudio git master + Fedora 15's Vala (a much newer version). It's puzzling that you can't conveniently "bind" a constant from C into Vala. I guess the only way to do it would be to declare an inline function that just returns the value you want -- but this would bump the libpulse API by adding a bunch of new functions (one for each constant we want to export). There's got to be a cleaner way to simply reach into libpulse and grab the constant, since you can do that if you're writing C and Vala compiles to C. Of course, if it's a #define instead of an actual variable, that's another issue entirely, since #defines have no linkage and no symbol -- they are basically invisible to Vala. Plus you don't get type safety at all. Now about the fix, I still don't know why my compile worked before with only my patch, but it seems that Alexander's additional patch is complimentary and will further help the bindings along. That said, what would __really__ help the bindings along would be to write the libpulse API in a way that either vapigen or gobject-introspection could easily parse the whole thing with minimal human intervention. Vala's got the tools to do this, and they work, but not so much with "plain C" type APIs as we have in libpulse. Maybe a libpulse-glib or libpulse-gobject wrapper is in order? I dunno. We seem to be getting _a lot_ of niggling issues with the Vala bindings, and it'll always be a moving target as Vala changes (and to a lesser extent these days, as PA changes). So +1 for committing Alex's patch. HTH, Sean > > I guess you're additional patch with the 32 is needed, but I'll wait for > Sean to confirm his thoughts. > > Col > > -- > > Colin Guthrie > gmane(at)colin.guthr.ie > http://colin.guthr.ie/ > > Day Job: > Tribalogic Limited [http://www.tribalogic.net/] > Open Source: > Mageia Contributor [http://www.mageia.org/] > PulseAudio Hacker [http://www.pulseaudio.org/] > Trac Hacker [http://trac.edgewall.org/] > > ___ > pulseaudio-discuss mailing list > pulseaudio-discuss@mail.0pointer.de > https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss > ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
'Twas brillig, and Alexander Kurtz at 14/04/11 13:52 did gyre and gimble: > What do you think? Does the current upstream libpulse.vapi file really > work for you w/o modifications? No I seem to get this error too. I'm sure I did test the previous fix, but perhaps not :s I guess you're additional patch with the 32 is needed, but I'll wait for Sean to confirm his thoughts. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Hi again Sean! I'm sorry it took so long, but I finally was able to test your patch: Am Mittwoch, den 30.03.2011, 13:44 -0400 schrieb Sean McNamara: > FYI, this page is an absolute lifesaver: > http://live.gnome.org/Vala/Manual/Attributes#CCode_Attribute Thanks, that's *very* helpful! > With the attached patch, I get: > > $ valac --pkg=libpulse --vapidir=/usr/share/vala-0.12/vapi test2.vala > test2.vala:2.16-2.40: warning: field `MyClass.map' never used >PulseAudio.ChannelMap map; >^ > Compilation succeeded - 1 warning(s) Hmm, with the current upstream version (which contains your patch) I get this: $ cat Test.vala class Test : Object { PulseAudio.ChannelMap map; public static void main(){ } } $ valac-0.12 --pkg=libpulse --vapidir=. Test.vala Test.vala:2.2-2.26: warning: field `Test.map' never used PulseAudio.ChannelMap map; ^ /home/alexander/Test.vala.c: In function ‘pulse_audio_channel_map_destroy’: /home/alexander/Test.vala.c:50: error: incompatible types when assigning to type ‘enum pa_channel_position_t[32]’ from type ‘void *’ error: cc exited with status 256 Compilation failed: 1 error(s), 1 warning(s) $ The attached patch fixes the issue for me: $ valac-0.12 --pkg=libpulse --vapidir=. Test.vala Test.vala:2.2-2.26: warning: field `Test.map' never used PulseAudio.ChannelMap map; ^ Compilation succeeded - 1 warning(s) $ However, I'm not quite certain whether this is the correct solution, since I means hardcoding the array size (constants are not supported). What do you think? Does the current upstream libpulse.vapi file really work for you w/o modifications? Best regards Alexander Kurtz --- libpulse.vapi.old 2011-04-05 12:24:12.0 +0200 +++ libpulse.vapi 2011-04-14 13:42:36.773584634 +0200 @@ -376,7 +376,7 @@ [CCode (cname="pa_channel_map",has_destroy_function=false)] public struct ChannelMap { public uint8 channels; -public ChannelPosition map[]; +public ChannelPosition map[32]; [CCode (cname="PA_CHANNEL_MAP_SNPRINT_MAX")] public static const size_t SNPRINT_MAX; signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
'Twas brillig, and Sean McNamara at 30/03/11 18:44 did gyre and gimble: > Hi again Alexander, >> Can anybody confirm (or deny) that this is *not* a Pulseaudio bug? > > FYI, this page is an absolute lifesaver: > http://live.gnome.org/Vala/Manual/Attributes#CCode_Attribute > > With the attached patch, I get: > > $ valac --pkg=libpulse --vapidir=/usr/share/vala-0.12/vapi test2.vala > test2.vala:2.16-2.40: warning: field `MyClass.map' never used >PulseAudio.ChannelMap map; >^ > Compilation succeeded - 1 warning(s) Thanks again Sean. Applied. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Hi again Alexander, On Wed, Mar 30, 2011 at 1:12 PM, Alexander Kurtz wrote: > Hi, > > I've got another problem with Vala and Pulseaudio's official Vala bindings. > > This is my source code: > > $ cat test.vala > class MyClass : Object { > PulseAudio.ChannelMap map; > static void main(){ > } > } > $ > > Compiling it fails: > > $ valac --pkg=libpulse --vapidir=. test.vala > test.vala:2.2-2.26: warning: field `MyClass.map' never used > PulseAudio.ChannelMap map; > ^ > /tmp/ccCFqscK.o: In function `myclass_finalize': > test.vala.c:(.text+0x152): undefined reference to > `pulse_audio_channel_map_destroy' > collect2: ld returned 1 exit status > error: cc exited with status 256 > Compilation failed: 1 error(s), 1 warning(s) > $ > > I thought this was a bug in Vala, since valac accepted the code but gcc > threw an error. I reported this to the Debian BTS[1] and was told that > this is a bug in the bindings which I doubt[3]. > > Can anybody confirm (or deny) that this is *not* a Pulseaudio bug? FYI, this page is an absolute lifesaver: http://live.gnome.org/Vala/Manual/Attributes#CCode_Attribute With the attached patch, I get: $ valac --pkg=libpulse --vapidir=/usr/share/vala-0.12/vapi test2.vala test2.vala:2.16-2.40: warning: field `MyClass.map' never used PulseAudio.ChannelMap map; ^ Compilation succeeded - 1 warning(s) The result is that the struct is created with _init() using memory you already allocated (on the stack, or on the heap) and then you are responsible for calling pa_xfree() later to free it if it's allocated on the heap. This is how most structs work in my experience (except for GObjects). As to your bugs in [3] (from your message): > (1) valac doesn't fail if you try to put a dynamically-sized array > into a struct Probably a bug, yes. > (2) valac doesn't allow adding a destructor function to a struct Not sure that this is a bug. The destructor syntax in Vala more or less assumes that you are working with an (instance of a) class inheriting from GObject (the `Object' class in Vala), which structs cannot possibly be. The attribute hack isn't nearly as pretty, but eh, bindings are write-once use-everywhere, and bindings in other languages are much nastier (cf. native code written to generate Python bindings to C, etc.) > (3) valac doesn't allow making fixed-sized arrays from constants. > This is absolutely necessary since there are no preprocessor > directives in vala and most C libraries define symbolic names > for these things. If this is true, it sounds like a bug. A trivial test program not involving the vapi cruft would be nice. > (4) valac doesn't handle fixed-size arrays correctly, as it still > thinks they need to freed after use. Sounds ugly, but I haven't confirmed it myself. A trivial test program not involving the vapi cruft would be nice. HTH, Sean > > Best regards > > Alexander Kurtz > > [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345 > [2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345#10 > [3] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345#15 > > ___ > pulseaudio-discuss mailing list > pulseaudio-discuss@mail.0pointer.de > https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss > > From f429ab1889f936b4fcc4ecd7c22e5aa4c369be31 Mon Sep 17 00:00:00 2001 From: Sean McNamara Date: Wed, 30 Mar 2011 13:41:02 -0400 Subject: [PATCH] vala: ChannelMap has no destroy function. --- vala/libpulse.vapi |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/vala/libpulse.vapi b/vala/libpulse.vapi index 4315988..06f412d 100644 --- a/vala/libpulse.vapi +++ b/vala/libpulse.vapi @@ -373,7 +373,7 @@ namespace PulseAudio { public unowned CVolume? dec(Volume minus = 1); } -[CCode (cname="pa_channel_map")] +[CCode (cname="pa_channel_map",has_destroy_function=false)] public struct ChannelMap { public uint8 channels; public ChannelPosition map[]; -- 1.7.4.1 ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
[pulseaudio-discuss] Is this a Pulseaudio bug or a Vala bug? (v2)
Hi, I've got another problem with Vala and Pulseaudio's official Vala bindings. This is my source code: $ cat test.vala class MyClass : Object { PulseAudio.ChannelMap map; static void main(){ } } $ Compiling it fails: $ valac --pkg=libpulse --vapidir=. test.vala test.vala:2.2-2.26: warning: field `MyClass.map' never used PulseAudio.ChannelMap map; ^ /tmp/ccCFqscK.o: In function `myclass_finalize': test.vala.c:(.text+0x152): undefined reference to `pulse_audio_channel_map_destroy' collect2: ld returned 1 exit status error: cc exited with status 256 Compilation failed: 1 error(s), 1 warning(s) $ I thought this was a bug in Vala, since valac accepted the code but gcc threw an error. I reported this to the Debian BTS[1] and was told that this is a bug in the bindings which I doubt[3]. Can anybody confirm (or deny) that this is *not* a Pulseaudio bug? Best regards Alexander Kurtz [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345 [2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345#10 [3] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619345#15 signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a pulseaudio bug or a vala bug?
Am Freitag, den 25.03.2011, 09:16 + schrieb Colin Guthrie: > 'Twas brillig, and Sean McNamara at 25/03/11 05:29 did gyre and gimble: > > Yep, this works! > > > > $ valac --pkg=libpulse --pkg=posix test.vala > > $ file test > > test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically > > linked (uses shared libs), for GNU/Linux 2.6.15, not stripped > > > > Attached is a patch > > Cool, thanks Sean and Alexander. > > I've pushed your fix to git master then applied both Alexander's earlier > vala fix and your one to stable-queue. I can confirm that now everything works as it should. Thank you both so very much! Best regards Alexander Kurtz signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a pulseaudio bug or a vala bug?
'Twas brillig, and Sean McNamara at 25/03/11 05:29 did gyre and gimble: > Yep, this works! > > $ valac --pkg=libpulse --pkg=posix test.vala > $ file test > test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically > linked (uses shared libs), for GNU/Linux 2.6.15, not stripped > > Attached is a patch Cool, thanks Sean and Alexander. I've pushed your fix to git master then applied both Alexander's earlier vala fix and your one to stable-queue. All the best Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] Is this a pulseaudio bug or a vala bug?
Replying to myself: On Fri, Mar 25, 2011 at 1:08 AM, Sean McNamara wrote: > Hi, > > On Thu, Mar 24, 2011 at 10:37 PM, Alexander Kurtz > wrote: >> Hi, >> >> I have a problem with Pulseaudio (0.9.21) + Vala (0.10.4). I've written >> this small demonstration program: >> >> $ cat test.vala >> class MyClass : Object { >> static void main(){ >> PulseAudio.SampleSpec spec = PulseAudio.SampleSpec() { >> format = PulseAudio.SampleFormat.S32NE, >> channels = 2, >> rate = 44100 >> }; >> PulseAudio.MainLoop loop = >> new PulseAudio.MainLoop(); >> PulseAudio.Context context = >> new PulseAudio.Context(loop.get_api(), null); >> PulseAudio.Stream stream = >> new PulseAudio.Stream(context, "", spec); >> int32[] data = new int32[10]; >> stream.write(data, sizeof(int32) * data.length); >> } >> } >> $ >> >> I know that this program won't work (i.e. "run") but it should compile >> just fine. However, I get this: >> >> $ valac --vapidir=. --pkg=libpulse --pkg=posix test.vala >> /home/alexander/test/test.vala.c: In function ‘myclass_main’: >> /home/alexander/test/test.vala.c:61: warning: passing argument 5 of >> ‘pa_stream_write’ makes integer from pointer without a cast >> /usr/include/pulse/stream.h:503: note: expected ‘int64_t’ but >> argument is of type ‘void *’ >> /home/alexander/test/test.vala.c:61: error: too many arguments to >> function ‘pa_stream_write’ >> error: cc exited with status 256 >> Compilation failed: 1 error(s), 0 warning(s) >> $ >> >> Looking at the generated C-Code reveals this: >> >> $ valac --vapidir=. --pkg=libpulse --pkg=posix --ccode test.vala >> $ cat test.c >> [...] >> pa_stream_write (stream, data, (gsize) (sizeof (gint32) * >> data_length1), NULL, NULL, 0, PA_SEEK_RELATIVE); >> [...] >> $ >> >> This is obviously wrong, since pa_stream_write takes 6 arguments not 7, >> see[1]. >> >> Is this a bug in PA's Vala bindings or in Vala itself? > > Look at the PulseAudio bindings in > /usr/share/vala*/vapi/pulseaudio.vapi, or in git: > http://git.0pointer.de/?p=pulseaudio.git;a=blob_plain;f=vala/libpulse.vapi;hb=refs/heads/master-tx > > [Vala]: > public int write(void *data, size_t bytes, FreeCb? free_cb = null, > int64 offset = 0, SeekMode mode = SeekMode.RELATIVE); > > Compared to [C]: > int pa_stream_write (pa_stream *p, const void *data, size_t nbytes, > pa_free_cb_t free_cb, int64_t offset, pa_seek_mode_t seek) > > It seems that the parameters match up in the vapi, but it compiles > down to two NULLs instead of just one for the FreeCb. But if you look > at the signature of FreeCb, it tries to accept a void* as a parameter: > > [Vala] > public delegate void FreeCb(void *p); > > Maybe the extra parameter that Vala compiles in is supposed to be the > void* that the callback would then get passed? I think this is the > default behavior of a delegate. Maybe there is an annotation to tell > the Vala compiler not to supply a parameter to the call for the formal > parameters of the delegate? > > Try the following > > [CCode (has_target = false)] > public delegate void FreeCb(void *p); Yep, this works! $ valac --pkg=libpulse --pkg=posix test.vala $ file test test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped Attached is a patch HTH, Sean > > Just a guess though -- it may not work as intended! There's virtually > no documentation on this attribute; I'm just guessing from the Vala > sources. > > HTH, > > Sean > >> >> Best regards >> >> Alexander Kurtz >> >> [1] >> http://0pointer.de/lennart/projects/pulseaudio/doxygen/stream_8h.html#a4fc69dec0cc202fcc174125dc88dada7 >> >> ___ >> pulseaudio-discuss mailing list >> pulseaudio-discuss@mail.0pointer.de >> https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss >> >> > From 93d9b6bad80c5112b5ff63189abad10bc56cf79e Mon Sep 17 00:00:00 2001 From: Sean McNamara Date: Fri, 25 Mar 2011 01:28:10 -0400 Subject: [PATCH] Vala: delegate FreeCb does not have a target. --- vala/libpulse.vapi |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/vala/libpulse.vapi b/vala/libpulse.vapi index aed526a..8304911 100644 --- a/vala/libpulse.vapi +++ b/vala/libpulse.vapi @@ -49,7 +49,7 @@ namespace PulseAudio { [CCode (cname="PA_INVALID_INDEX")] public const uint32 INVALID_INDEX; -[CCode (cname="pa_free_cb_t")] +[CCode (cname="pa_free_cb_t", has_target=false)] public del
Re: [pulseaudio-discuss] Is this a pulseaudio bug or a vala bug?
Hi, On Thu, Mar 24, 2011 at 10:37 PM, Alexander Kurtz wrote: > Hi, > > I have a problem with Pulseaudio (0.9.21) + Vala (0.10.4). I've written > this small demonstration program: > > $ cat test.vala > class MyClass : Object { > static void main(){ > PulseAudio.SampleSpec spec = PulseAudio.SampleSpec() { > format = PulseAudio.SampleFormat.S32NE, > channels = 2, > rate = 44100 > }; > PulseAudio.MainLoop loop = > new PulseAudio.MainLoop(); > PulseAudio.Context context = > new PulseAudio.Context(loop.get_api(), null); > PulseAudio.Stream stream = > new PulseAudio.Stream(context, "", spec); > int32[] data = new int32[10]; > stream.write(data, sizeof(int32) * data.length); > } > } > $ > > I know that this program won't work (i.e. "run") but it should compile > just fine. However, I get this: > > $ valac --vapidir=. --pkg=libpulse --pkg=posix test.vala > /home/alexander/test/test.vala.c: In function ‘myclass_main’: > /home/alexander/test/test.vala.c:61: warning: passing argument 5 of > ‘pa_stream_write’ makes integer from pointer without a cast > /usr/include/pulse/stream.h:503: note: expected ‘int64_t’ but argument > is of type ‘void *’ > /home/alexander/test/test.vala.c:61: error: too many arguments to > function ‘pa_stream_write’ > error: cc exited with status 256 > Compilation failed: 1 error(s), 0 warning(s) > $ > > Looking at the generated C-Code reveals this: > > $ valac --vapidir=. --pkg=libpulse --pkg=posix --ccode test.vala > $ cat test.c > [...] > pa_stream_write (stream, data, (gsize) (sizeof (gint32) * > data_length1), NULL, NULL, 0, PA_SEEK_RELATIVE); > [...] > $ > > This is obviously wrong, since pa_stream_write takes 6 arguments not 7, > see[1]. > > Is this a bug in PA's Vala bindings or in Vala itself? Look at the PulseAudio bindings in /usr/share/vala*/vapi/pulseaudio.vapi, or in git: http://git.0pointer.de/?p=pulseaudio.git;a=blob_plain;f=vala/libpulse.vapi;hb=refs/heads/master-tx [Vala]: public int write(void *data, size_t bytes, FreeCb? free_cb = null, int64 offset = 0, SeekMode mode = SeekMode.RELATIVE); Compared to [C]: int pa_stream_write (pa_stream *p, const void *data, size_t nbytes, pa_free_cb_t free_cb, int64_t offset, pa_seek_mode_t seek) It seems that the parameters match up in the vapi, but it compiles down to two NULLs instead of just one for the FreeCb. But if you look at the signature of FreeCb, it tries to accept a void* as a parameter: [Vala] public delegate void FreeCb(void *p); Maybe the extra parameter that Vala compiles in is supposed to be the void* that the callback would then get passed? I think this is the default behavior of a delegate. Maybe there is an annotation to tell the Vala compiler not to supply a parameter to the call for the formal parameters of the delegate? Try the following [CCode (has_target = false)] public delegate void FreeCb(void *p); Just a guess though -- it may not work as intended! There's virtually no documentation on this attribute; I'm just guessing from the Vala sources. HTH, Sean > > Best regards > > Alexander Kurtz > > [1] > http://0pointer.de/lennart/projects/pulseaudio/doxygen/stream_8h.html#a4fc69dec0cc202fcc174125dc88dada7 > > ___ > pulseaudio-discuss mailing list > pulseaudio-discuss@mail.0pointer.de > https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss > > ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
[pulseaudio-discuss] Is this a pulseaudio bug or a vala bug?
Hi, I have a problem with Pulseaudio (0.9.21) + Vala (0.10.4). I've written this small demonstration program: $ cat test.vala class MyClass : Object { static void main(){ PulseAudio.SampleSpec spec = PulseAudio.SampleSpec() { format = PulseAudio.SampleFormat.S32NE, channels = 2, rate = 44100 }; PulseAudio.MainLoop loop = new PulseAudio.MainLoop(); PulseAudio.Context context = new PulseAudio.Context(loop.get_api(), null); PulseAudio.Stream stream = new PulseAudio.Stream(context, "", spec); int32[] data = new int32[10]; stream.write(data, sizeof(int32) * data.length); } } $ I know that this program won't work (i.e. "run") but it should compile just fine. However, I get this: $ valac --vapidir=. --pkg=libpulse --pkg=posix test.vala /home/alexander/test/test.vala.c: In function ‘myclass_main’: /home/alexander/test/test.vala.c:61: warning: passing argument 5 of ‘pa_stream_write’ makes integer from pointer without a cast /usr/include/pulse/stream.h:503: note: expected ‘int64_t’ but argument is of type ‘void *’ /home/alexander/test/test.vala.c:61: error: too many arguments to function ‘pa_stream_write’ error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) $ Looking at the generated C-Code reveals this: $ valac --vapidir=. --pkg=libpulse --pkg=posix --ccode test.vala $ cat test.c [...] pa_stream_write (stream, data, (gsize) (sizeof (gint32) * data_length1), NULL, NULL, 0, PA_SEEK_RELATIVE); [...] $ This is obviously wrong, since pa_stream_write takes 6 arguments not 7, see[1]. Is this a bug in PA's Vala bindings or in Vala itself? Best regards Alexander Kurtz [1] http://0pointer.de/lennart/projects/pulseaudio/doxygen/stream_8h.html#a4fc69dec0cc202fcc174125dc88dada7 signature.asc Description: This is a digitally signed message part ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss