[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-audio-dev
Subject:    Re: [LAD] making sense of Jack MIDI; or, is this an appropriate use
From:       "Jeff McClintock" <jef () synthedit ! com>
Date:       2013-02-18 20:18:44
Message-ID: 002101ce0e15$26e97820$74bc6860$ () com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Message: 7

Date: Sun, 17 Feb 2013 17:10:11 -0500

From: Paul Coccoli < <mailto:pcoccoli@gmail.com> pcoccoli@gmail.com>

 

>You're effectively serializing your object and passing them over the
ringbuffer.  If you do it this way, you should at least consider explicitly
embedding the type and length as the first member of EventBase (and have
each derived class set their own type and length in their constructors), and
reading those before touching the object you read.

 

Very good, that's what I do. The event is serialised to the ringbuffer, one
member at a time (so I don't rely on a particular memory layout, or padding.
The Type of message and the length are the first two values. (this example
sends some text to the GUI to display a message box)..

       my_output_stream& strm = MessageQueToGui();

 

       strm << id_to_long("mbox");

       strm << (int) ( sizeof(wchar_t) * msg.size() + sizeof(int) +
sizeof(icontype)); // message length.

       strm << msg;

       strm << icontype;

 

 

Jeff


[Attachment #5 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
	{mso-style-priority:99;
	mso-style-link:"Plain Text Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.5pt;
	font-family:Consolas;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.PlainTextChar
	{mso-style-name:"Plain Text Char";
	mso-style-priority:99;
	mso-style-link:"Plain Text";
	font-family:Consolas;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoPlainText>Message: 7<o:p></o:p></p><p \
class=MsoPlainText>Date: Sun, 17 Feb 2013 17:10:11 -0500<o:p></o:p></p><p \
class=MsoPlainText>From: Paul Coccoli &lt;<a href="mailto:pcoccoli@gmail.com"><span \
style='color:windowtext;text-decoration:none'>pcoccoli@gmail.com</span></a>&gt;<o:p></o:p></p><p \
class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;You're effectively \
serializing your object and passing them over the ringbuffer.&nbsp; If you do it this \
way, you should at least consider explicitly embedding the type and length as the \
first member of EventBase (and have each derived class set their own type and length \
in their constructors), and reading those before touching the object you \
read.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoNormal \
style='text-autospace:none'>Very good, that's what I do. The event is serialised to \
the ringbuffer, one member at a time (so I don't rely on a particular memory layout, \
or padding. The Type of message and the length are the first two values. (this \
example sends some text to the GUI to display a message box)..<br><br><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white'>my_output_stream</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&amp; \
strm = MessageQueToGui();<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
strm &lt;&lt; id_to_long(</span><span \
style='font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white'>&quot;mbox&quot;</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>);<o:p></o:p></span></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
strm &lt;&lt; (</span><span \
style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>int</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) \
( </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(</span><span \
style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>wchar_t</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) \
* </span><span style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>msg</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>.size() \
+ </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(</span><span \
style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>int</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>) \
+ </span><span style='font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white'>sizeof</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>(icon</span><span \
style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>type</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>)); \
</span><span style='font-size:9.5pt;font-family:Consolas;color:green;background:white;mso-highlight:white'>// \
message length.</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'><o:p></o:p></span></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
strm &lt;&lt; </span><span \
style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>msg</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
strm &lt;&lt; icon</span><span \
style='font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white'>type</span><span \
style='font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white'>;<o:p></o:p></span></p><p \
class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><span \
style='color:black'><o:p>&nbsp;</o:p></span></p><p class=MsoPlainText><span \
style='color:black'>Jeff<o:p></o:p></span></p></div></body></html>



_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic