Re: [LAD] easiest way to serialize messages for sending over a ringbuffer?

From: Iain Duncan <iainduncanlists@email-addr-hidden>
Date: Wed Dec 14 2011 - 05:02:21 EET

On Tue, Dec 13, 2011 at 5:53 AM, Paul Davis <paul@email-addr-hiddenwrote:

> On Mon, Dec 12, 2011 at 11:44 PM, Iain Duncan <iainduncanlists@email-addr-hidden>
> wrote:
>
> > Yup, what I'm talking about is being able to put a data structure on to
> the
> > ring buffer. It needs be castable to a const *char, so the structure
> needs
> > a way to be converted to a string.
>
> these two statements are not related. in an awful lot of C code,
> "pointer to char" means "pointer". in newer better C code, one uses
> void*. in newer, better code than that, one doesn't use raw pointers
> much at all.
>
> are you working in C or C++ ?
>

Thanks Paul. I'm working in C++, but I'm using the jack C api, which from
the docs I see has a signature for
size_t jack_ringbuffer_write ( jack_ringbuffer_t * rb, const char * src,
size_t cnt )

My DataMessage structure is just a simple C structure for now. Is there a
recommended way of writing it to the ringbuffer given that I want to do
something like this:

void MessageQueue::push( DataMessage msg ){
    // write to the ring buffer, converting DataMessage to a string
    unsigned int written = jack_ringbuffer_write( mRingBuffer, (char *)
&msg , sizeof(DataMessage) );
   // etc
}

Thanks
Iain

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Wed Dec 14 04:15:01 2011

This archive was generated by hypermail 2.1.8 : Wed Dec 14 2011 - 04:15:01 EET