<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.11" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Words from the inside</title>
	<link>http://blogs.igalia.com/jasuarez</link>
	<description>Posts from an igaul</description>
	<pubDate>Fri, 02 May 2008 15:14:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.11</generator>
	<language>en</language>
			<item>
		<title>Ubuntu and Scratchbox: singing duets</title>
		<link>http://blogs.igalia.com/jasuarez/2008/05/02/ubuntu-and-scratchbox-singing-duets/</link>
		<comments>http://blogs.igalia.com/jasuarez/2008/05/02/ubuntu-and-scratchbox-singing-duets/#comments</comments>
		<pubDate>Thu, 01 May 2008 23:01:49 +0000</pubDate>
		<dc:creator>jasuarez</dc:creator>
		
		<category>Software</category>

		<category>Igalia</category>

		<guid isPermaLink="false">http://blogs.igalia.com/jasuarez/2008/05/02/ubuntu-and-scratchbox-singing-duets/</guid>
		<description><![CDATA[Recently Igalia gave me a new laptop, a Lenovo &#8220;The Beast &#038; The Best&#8221; Thinkpad, for everyday work. I decided to install Ubuntu Hardy Heron 64bits, as I had never worked with such operating system, and I am eager to learn benefits and drawbacks of working on a 64bits OS.
Among other features, Hardy comes with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently <a title="Igalia" href="http://www.igalia.com">Igalia</a> gave me a new laptop, a Lenovo <em>&#8220;The Beast &#038; The Best&#8221;</em> Thinkpad, for everyday work. I decided to install <a title="Ubuntu" href="http://www.ubuntu.com">Ubuntu Hardy Heron</a> 64bits, as I had never worked with such operating system, and I am eager to learn benefits and drawbacks of working on a 64bits OS.</p>
<p>Among other features, Hardy comes with <a title="PulseAudio" href="http://www.pulseaudio.org/">PulseAudio</a>, the new sound system which has a lot of features.</p>
<p>As I am playing with <a title="Maemo" href="http://maemo.org/">Maemo</a> I have installed a <a title="Scratchbox" href="http://www.scratchbox.org/">scratchbox</a> too. A workmate, <a title="Calvaris' blog" href="http://blogs.igalia.com/xrcalvar">Calvaris</a>, wrote about how to <a title="Installing scratchbox under Amd64" href="http://blogs.igalia.com/xrcalvar/2008/04/23/installing-scratchbox-under-amd64/">install scratchbox in a Linux Amd64</a>.</p>
<p>Now the problem: scratchbox comes with esound to manage the sounds. When I am working within the scratchbox, esound daemon blocks the <tt>/dev/dsp</tt> device, preventing other applications outside the scratchbox to be able to play. This disturbs me a lot, as I like listening music while working. Of course, we can kill <tt>esd</tt> daemon to free the <em>dsp</em> device, but in this case I can not play songs inside the scratchbox, which I need to do too.</p>
<p>So, what is the solution? The idea is to use the soundcard to play songs for our Ubuntu applications, while the scratchbox will use a virtual soundcard that will sent the music to another host using networking capabilities of esound. The trick is that the &#8216;another host&#8217; will be our own host, which will receive the music stream and will play it. Cool, uh?</p>
<p>Lets do it!.</p>
<p><strong>Configuring PulseAudio</strong></p>
<p>The first step is configuring Pulseaudio to be able to receive streams through the network. Therefore, edit <tt>/etc/pulse/default.pa</tt> and add the following line:</p>
<p><tt>load-module module-esound-protocol-tcp</tt></p>
<p>It is likely that line already exists in the file but commented. In this case, uncomment it.</p>
<p>Now you must restart pulseaudio in order to load the new configuration.</p>
<p><strong>Configuring a Dummy Soundcard</strong></p>
<p>Scratchbox esound daemon requires to have a <em>dsp</em> device even when sending the music through network. So we are going to add a dummy sound card that will be used by the daemon.</p>
<p>Linux kernel provides a driver for a dummy soundcard. To load it, execute as root:</p>
<p><tt>modprobe snd-dummy</tt></p>
<p>A new <em>dsp</em> device, <tt>/dev/dsp1</tt>, will be created.</p>
<p><strong>Configuring Scratchbox eSound </strong></p>
<p>We must configure esound daemon in scratchbox to use the new dummy soundcard.  To do this, enter in the scratchbox and edit <tt>/etc/esd.conf</tt> file. Search the options line and add at the end:</p>
<p><tt>-d /dev/dsp1</tt></p>
<p>In my case, the <tt>esd.conf</tt> file contains:</p>
<p><tt>auto_spawn=1<br />
#spawn_options=-promiscuous -nobeeps<br />
spawn_options=-promiscuous -nobeeps -d /dev/dsp1<br />
spawn_wait_ms=500<br />
# default options are used in spawned and non-spawned mode<br />
#default_options=-promiscuous -nobeeps<br />
default_options=-promiscuous -nobeeps -d /dev/dsp1</tt></p>
<p>Thus, scratchbox will use the dummy soundcard, while the real soundcard will remain free for Ubunutu. Of course, being a dummy sound card, don not expect to hear music playing in the scratchbox. To resolve this problem, the last step is send what is playing with esound daemon through the network to our own host to be played through pulseaudio.</p>
<p><strong>Configuring eSound&#8217;s Network Transparent Sound</strong></p>
<p>This is the last step. Network sound uses a authentication mechanism. So in order to use network transparency both sides must be authenticated between them. When pulseaudio is launched, an <tt>.esd_auth</tt> file is created in the home directory. Copying this file to the scratchbox home will allow esd to send music to pulseaudio daemon. After copying the file, restart esound daemon.</p>
<p>Now we can send the sound to the pulseudio daemon. From the scratchbox, execute this:</p>
<p><tt>esdmon | esdcat -s 127.0.0.1 &#038;</tt></p>
<p><tt>esdmon</tt> listens all data sent to esound daemon, sending it also to the standard output. On the other hand, <tt>esdcat</tt> reads all data from the standard input and sends it (in this case) to the localhost. As you can notice, working together means that all sound sent to the dummy sound card is also sent through localhost to the pulseaudio daemon, which in turn sends it to the real soundcard.</p>
<p>Now, you can play songs inside the scratchbox and you will hear them! Moreover, you can be playing at the same time music in the scratchbox and in the host, due to multiplexing capabilities of pulseaudio. So both systems, Ubuntu and scratchbox, will sing duet.
</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.igalia.com/jasuarez/2008/05/02/ubuntu-and-scratchbox-singing-duets/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Defun in Emacs</title>
		<link>http://blogs.igalia.com/jasuarez/2008/02/14/defun-in-emacs/</link>
		<comments>http://blogs.igalia.com/jasuarez/2008/02/14/defun-in-emacs/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 18:03:44 +0000</pubDate>
		<dc:creator>jasuarez</dc:creator>
		
		<category>Software</category>

		<category>Igalia</category>

		<guid isPermaLink="false">http://blogs.igalia.com/jasuarez/2008/02/14/defun-in-emacs/</guid>
		<description><![CDATA[If you are an Emacs fan, you may have notice a lot of cool changes from Emacs21 to Emacs22. One of those changes is related to defuns. A defun is simply a function definition. But, what is actually a &#8216;function definition&#8217;? Until Emacs21, a function definition is the code that defines the function (easy, is [...]]]></description>
			<content:encoded><![CDATA[<p>If you are an Emacs fan, you may have notice a lot of cool changes from <em>Emacs21</em> to <em>Emacs22</em>. One of those changes is related to <strong>defuns</strong>. A defun is simply a function definition. But, what is actually a &#8216;function definition&#8217;? Until <em>Emacs21</em>, a function definition is the code that defines the function (easy, is not it? <img src='http://blogs.igalia.com/jasuarez/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). There are a lot of functions in Emacs that are based on defuns: <em>beginning-of-defun</em>, <em>mark-defun</em>, <em>narrow-to-defun</em>, etc.</p>
<p>One of those functions that is very useful is <strong>narrow-to-defun</strong> (<em>C-x n d</em>): it hides all source code except the current function. Then, you can do all kind of changes that will affect only the shown code. If you try it with a C example, you will notice all code except the function you are positioned is hidden. Unfortunately, as you can check, the function definition is not part of the defun, so it is also hidden. Besides being upset, as you can not see the definition, there are other problems, like Emacs indenting wrong.</p>
<p>But with <em>Emacs22</em>, this has changed, so now a defun includes both the code of a function and its definition. If you try again the previous example in <em>Emacs22</em>, you will notice that now the function is shown fine, and it even indents fine.</p>
<p>The problem is that some Emacs packages are not aware of this change. One of that package is <strong>gtk-doc</strong>: it creates a skeleton of the Gtk function you are writting. Unfortunately, this package, which works fine until Emacs21, does not work fine in Emacs22, because of the change of defun.</p>
<p>The fix is very easy, and I attach the <a id="p8" href="http://blogs.igalia.com/jasuarez/wp-content/uploads/2008/02/gtk-doctar.gz">package</a> already fixed. You need to load Emacs22, and compile it (<em>gtk-doc.el</em>) with compile it with <em>byte-compile-file</em> funtion, which creates a <em>gtk-doc.elc</em>, and then replace the current file with the newer. If you want to have a look at the change done, I attach also a patch with the fix.
</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.igalia.com/jasuarez/2008/02/14/defun-in-emacs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Three Musketeers in WebKit</title>
		<link>http://blogs.igalia.com/jasuarez/2007/08/23/the-three-musketeers-in-webkit/</link>
		<comments>http://blogs.igalia.com/jasuarez/2007/08/23/the-three-musketeers-in-webkit/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 15:36:32 +0000</pubDate>
		<dc:creator>jasuarez</dc:creator>
		
		<category>Software</category>

		<category>Igalia</category>

		<guid isPermaLink="false">http://blogs.igalia.com/jasuarez/?p=4</guid>
		<description><![CDATA[Some time ago I began to look at WebKit, the render engine used in Safari and ported to other platforms, like our favourite, Gtk. Some of the issues it takes to me understand is the design of WebKit, mainly the differences between WebCore and WebKit.
So, here is my conclusions. Notice that I&#8217;m roughly speaking. Like [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I began to look at <strong>WebKit</strong>, the render engine used in <em>Safari</em> and ported to other platforms, like our favourite, <em>Gtk</em>. Some of the issues it takes to me understand is the design of <strong>WebKit</strong>, mainly the differences between <em>WebCore</em> and <em>WebKit</em>.</p>
<p>So, here is my conclusions. Notice that I&#8217;m roughly speaking. Like <em>The Three Musketeers</em> or <em>Three Little Pigs</em>, <strong>WebKit</strong> is composed by three high level modules: <em>JavaScriptCore</em>, <em>WebCore</em> and <em>WebKit</em> (latter names the global project).</p>
<div style="text-align: center"><img width="411" height="216" alt="WebKit Structure" id="image6" src="http://blogs.igalia.com/jasuarez/wp-content/uploads/2007/08/estructura-de-webkit.png" /></div>
<ul>
<li><strong>JavaScriptCore</strong>, as its name suggests, is the interpreter of JavaScript.</li>
<li><strong>WebCore</strong> is the core of the project. Implements the render engine itself: analyzes the web pages, generates a DOM tree, a render tree and finally renders it with a backend. There are as many backends as ports. So <em>WebKit/Gdk</em>, the port of <strong>WebKit</strong> for the best platform <img src='http://blogs.igalia.com/jasuarez/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  uses widgets <em>Gtk/Gdk</em> and <em>Cairo</em> to draw the elements. Though in the figure the backend is separated from <em>WebCore,</em> actually the backend is part of <em>WebCore</em>.</li>
<li><strong>WebKit</strong> is a façade of <em>WebCore</em>. It hides and adapts <em>WebCore</em> to the current platform. In <em>WebKit/Gtk</em>, shows <em>WebCore</em> as <em>Gtk</em> objects, with their signals and API similar to other <em>Gtk</em> objects.</li>
</ul>
<p>I hope this information be helpful to any one.
</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.igalia.com/jasuarez/2007/08/23/the-three-musketeers-in-webkit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Electric debugging</title>
		<link>http://blogs.igalia.com/jasuarez/2007/03/30/electric-debugging/</link>
		<comments>http://blogs.igalia.com/jasuarez/2007/03/30/electric-debugging/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 08:43:38 +0000</pubDate>
		<dc:creator>jasuarez</dc:creator>
		
		<category>Software</category>

		<category>Igalia</category>

		<guid isPermaLink="false">http://blogs.igalia.com/jasuarez/?p=3</guid>
		<description><![CDATA[One of the most scary problems when I develop an application is a buffer overflow, that happens when you access a  memory zone that it doesn&#8217;t have be assigned. The problem is that  if you  overwrite that zone, not always the program crashes, but it stills continues running with that zone corrupted. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most scary problems when I develop an application is a buffer overflow, that happens when you access a  memory zone that it doesn&#8217;t have be assigned. The problem is that  if you  overwrite that zone, not always the program crashes, but it stills continues running with that zone corrupted.  And, if you are lucky, the program crashes after 10 lines, 50 or God knows.</p>
<p>One of the most used applications to find buffer overflows is <em><a title="Valgrind" href="http://valgrind.org/">Valgrind</a></em>. It is very sophisticated, and is able to find other type of problems. The drawback is that it only runs on x86, AMD, PPC32 and PPC64.</p>
<p>When I was studying, I discovered <em><a title="Efence" href="http://freshmeat.net/projects/efence/">Electric Fence</a></em>, a library that detect illegal accesses to memory. Roughly speaking, it changes the <em>malloc</em> function, so when a buffer is allocated, it adds around it a &#8220;red zone&#8221;: if you touch that zone, the program aborts with a segmentation fault. What is the advantage? It always crashes in the moment you access an invalid position of memory, not 100 or 300 lines far away. So you can use a debugger and see in which line is crashing: surely, in that line there is an illegal access to memory.</p>
<p>How to use it? More simply, impossible. You only need to link your program with the library (<em>-lefence</em>). That&#8217;s all! A banner is showed when the program is executed. Even you may use the <em>Electric Fence</em> with an already compiled program if you preload first the library (exporting the <strong>LD_PRELOAD</strong> environment variable to <em>libefence.so.0.0</em>).</p>
<p>The drawback with <em>Electric Fence</em> is that it makes the program more more slow. So use it only when developing, and disable it in the final release.</p>
<p>And remember: <em>Electric Fence</em> is in almost all GNU/Linux distributions. Happy bug hunting!
</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.igalia.com/jasuarez/2007/03/30/electric-debugging/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
