Lars Luthman schrieb: > On Fri, 2009-07-24 at 23:35 +0200, Ulrich Lorenz Schlüter wrote: > >> Hello list, >> >> I never get a valid event iterator with lv2_event_is_valid(). Can >> somebody tell me why please? >> >> [...] >> LV2_Event_Buffer* inbuf = p<LV2_Event_Buffer>(*p(6)); >> > > The template version of p() works just like the non-template version, it > takes a uint32_t port index argument and returns a pointer to the buffer > for that port. The only difference is that while the non-template > version returns the buffer pointer as a pointer-to-float, the template > version returns it as a pointer-to-T, where T is the template parameter. > So in order to get the MIDI event input buffer for the port with index 6 > you do > > LV2_Event_Buffer* inbuf = p<LV2_Event_Buffer>(6); > > or, equivalently > > LV2_Event_Buffer* inbuf = reinterpret_cast<LV2_Event_Buffer*>(p(6)); > > What you are doing above is to first get the buffer as a > pointer-to-float although the buffer really contains an > LV2_Event_Buffer, then dereference it to get some garbage float value, > then truncate that float value to an uint32_t and pass it as the index > parameter to p<LV2_Event_Buffer>(). This will cause undefined behaviour. > It could crash with a segmentation fault, it could give you garbage MIDI > events or it could do nothing at all. > > > --ll > Was about to ask especially you about that until I solved this on my own. But thanks a lot for your explanation.
Uli :-) _______________________________________________ Linux-audio-dev mailing list [email protected] http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
