<br><br><div class="gmail_quote">On Sun, Feb 17, 2013 at 9:20 PM, Paul Coccoli <span dir="ltr"><<a href="mailto:pcoccoli@gmail.com" target="_blank">pcoccoli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This scheme sounds error prone.  In general, copying C++ objects via<br>
memcpy (or writing them 1 byte at a time into the ringbuffer, which is<br>
what I think you're proposing) is a bad idea.  </blockquote><div>Nope, write them one   sizeof( event->size() ) at a time.<br>I'm very interested in why copying C++ objects like this is a bad idea.<br>Its been discussed on list before (<a href="http://linux-audio.4202.n7.nabble.com/Inter-thread-Communication-Design-Approach-td68710.html">http://linux-audio.4202.n7.nabble.com/Inter-thread-Communication-Design-Approach-td68710.html</a>).<br>
This seemed to be the best simple RT safe solution. If you have suggestions / improvements I'd love to hear them.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
JACK ringbuffers are<br>
ideally suited to passing simple types (like floats), and not vairable<br>
sized things (like different derived Event classes).  Your enum for<br>
event types is a bit of a red flag, too.  While its perfectly valid,<br>
"type flags" like this more often than not accompany inflexible,<br>
tightly coupled code (which may be fine in a small audio app, but few<br>
apps stay small).<br></blockquote><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What about passing pointers via the ringbuffer?  </blockquote><div>Pointers to an Event? Just makes it more hassle to send an Event from the RT thread.<br>Involves taking X memory from a mem-pool, and then using placement new to construct<br>
the EventPlay(), and then send the pointer trough the ringbuffer. More complicated IMO.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To free the event 
objects, you could pass them back via a second ringbuffer so the RT<br>
threads aren't responsible for deleting them.<br>
</blockquote></div>Indeed, that would be necessary. Again, more complications. That said, it can be done,<br>and would involve less "traffic" trough the ringbuffer, and also "fixed size" traffic": pointers to EventBase.<br>
<br>