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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Paul Davis <paul@...>
Cc: <linux-audio-dev@...>
Date: Wednesday, December 14, 2011 - 3:59 am

--20cf303dd31202caba04b4056454
Content-Type: text/plain; charset=ISO-8859-1

> My DataMessage structure is just a simple C structure for now. Is there a

&msg

as long as the struct is POD (Plain Old Data - no embedded pointers,

Thanks for the tips. What should one do if one detects a partial write? Is
it best to have integrity checks on both ends of the ringbuffer?

the jack ringbuffer design is particular bad in this respect because

Does this mean a good way to initialize it is to make the ringbuffer some
multiple of the sizeof(myMessageStruct) plus one byte?

Thanks again for all the help.
iain

--20cf303dd31202caba04b4056454
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

> My DataMessage structure is just a simple C structure for now. Is ther=
e a

o
g
char *) &msg

as long as the st=
ruct is POD (Plain Old Data - no embedded pointers,
etc), this will work fine.

however, you need to keep in mind that under some easily encounterable
circumstances, the write may not return sizeof(DataMessage). this is a
very easy mistake to make with ringbuffers (ditto for read).

it can be avoided via careful sizing of the ringbuffer and always
read/writing "whole objects" OR by carefully checking the results=
of
read/write.Thanks for the tips. What s=
hould one do if one detects a partial write? Is it best to have integrity c=
hecks on both ends of the ringbuffer?

the jack ringbuffer design is particular bad in this respect because
it can only hold size-1 bytes (where size is its actual size).Does this mean a good way to initialize it is to ma=
ke the ringbuffer some multiple of the sizeof(myMessageStruct) plus one byt=
e?
Thanks again for all the help.iain

--20cf303dd31202caba04b4056454--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [LAD] easiest way to serialize messages for sending over..., Iain Duncan, (Wed Dec 14, 3:59 am)