<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for conrad</title>
    <link>http://www.advogato.org/person/conrad/</link>
    <description>Advogato blog for conrad</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Fri, 10 Feb 2012 16:58:28 GMT</pubDate>
    <item>
      <pubDate>Sun, 18 Sep 2011 10:10:27 GMT</pubDate>
      <title>Iteratees at Tsuru Capital</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=63</link>
      <guid>http://blog.kfish.org/feeds/7124718153026346276/comments/default</guid>
      <description>&lt;p&gt;&lt;a href="http://www.tsurucapital.com/" &gt;Tsuru Capital&lt;/a&gt; is a small company. We build our internal systems for live trading and offline analysis in Haskell, and we're proud to be sponsoring &lt;a href="http://www.icfpconference.org/icfp2011/index.html" &gt;ICFP 2011&lt;/a&gt;. We use iteratees throughout our systems, and have actively encouraged all our staff to contribute changes upstream and participate in community design discussions. By being part of the open source community and taking part in peer-review, we all end up with better software.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Over time various Tsuru staff members have worked on tools using iteratees, including (grepping the CONTRIBUTORS files): Bryan Buecking, Michael Baikov, Elliott Pace, Conrad Parker, Akio Takano, and Maciej Wos. There's been some lively discussions and many small patches providing functions that we use in production every day. &lt;br/&gt;&lt;/p&gt;&lt;p&gt;Last year Conal Elliott provided some mentoring to Tsuru staff, during which we worked through a denotational semantics for iteratees. This resulted in discussions on both the iteratee project list and haskell-cafe about &lt;a href="http://www.haskell.org/pipermail/haskell-cafe/2010-August/082533.html" &gt;Semantics of iteratees, enumerators, enumeratees&lt;/a&gt;.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;By using iteratees in production we've contributed various simple but practical functions, including:&lt;br/&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.3.6/doc/html/Data-Iteratee-IO-Fd.html#g:2" &gt;enumFdFollow&lt;/a&gt;&lt;/b&gt;, an enumerator (data source) which allows you to process the growing tail of a log file as it is being written.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/latest/doc/html/Data-Iteratee-IO-Interact.html" &gt;ioIter&lt;/a&gt;&lt;/b&gt;, an iteratee that uses an IO action to determine what to do. Typically this is action involves some user interaction, such as a user issuing commands like play/pause/next/prev.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.8.6.2/doc/html/Data-Iteratee-ListLike.html" &gt;ListLike&lt;/a&gt; functions &lt;b&gt;last&lt;/b&gt; (an iteratee that efficiently returns the last element of a stream), &lt;b&gt;mapM_&lt;/b&gt; and &lt;b&gt;foldM&lt;/b&gt;.&lt;br/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.8.6.2/doc/html/Data-Iteratee-Iteratee.html#g:4" &gt;mapChunksM_&lt;/a&gt;&lt;/b&gt;, a more efficient version of &lt;tt&gt;mapM_&lt;/tt&gt; that operates on the underlying chunks, eg. &lt;tt&gt;logger = mapChunksM_ (liftIO . print)&lt;/tt&gt;.&lt;br/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;takeWhile&lt;/b&gt;, and its enumeratee variant &lt;b&gt;takeWhileE&lt;/b&gt;&lt;/li&gt;&lt;br/&gt;&lt;br/&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.8.6.2/doc/html/Data-Iteratee-Binary.html#g:2" &gt;endianRead8&lt;/a&gt;&lt;/b&gt;, an iteratee for reading 64bit values with a given endianness. I've used this in &lt;a href="http://hackage.haskell.org/package/ght" &gt;ght&lt;/a&gt; as well as an internal project.&lt;br/&gt;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Stream conversion&lt;/b&gt; We've done quite a bit of work on stream conversion, as we use a few different layers of data processing. The iteratee architecture allows you to isolate the data source, conversion and processing functions; much of what we've worked on involves ensuring the converters (enumeratees) can control or translate control messages, so that commands like "seek" do not get lost. We've also built combinators to simplify the task of creating new stream converters. &lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.3.6/doc/html/Data-Iteratee-Base.html#g:6" &gt;convStateStream&lt;/a&gt;&lt;/b&gt;, which converts one stream into another while continually updating an internal state. Importantly for variable bitrate binary data, it can produce elements of the output stream from data that spans stream chunks.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/0.8.6.2/doc/html/Data-Iteratee-Iteratee.html#g:9" &gt;(&amp;gt;) and (&lt;/a&gt;&lt;/b&gt;. These allow stream converters to be composed without rewriting boilerplate. Jon Lato gives a good example using these in the StackOverflow answer to &lt;a href="http://stackoverflow.com/questions/6360963/attoparsec-iteratee" &gt;Attoparsec Iteratee&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://hackage.haskell.org/packages/archive/iteratee/latest/doc/html/Data-Iteratee-ListLike.html" &gt;zip, zip[345], sequence_&lt;/a&gt;&lt;/b&gt; for using multiple iteratees to process a single stream instance, and (for zip*) collecting the results.&lt;br/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://projects.haskell.org/pipermail/iteratee/2011-July/000090.html" &gt;eneeCheckIfDone*&lt;/a&gt;&lt;/b&gt;: This family of functions (eneeCheckIfDoneHandle, eneeCheckIfDonePass, eneeCheckIfDoneIgnore) can be used with &lt;br/&gt;
unfoldConvStreamCheck to make a version of unfoldConvStream which respects seek messages.&lt;/li&gt;&lt;br/&gt;&lt;br/&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;Parallel stream processing&lt;/b&gt; We often want to do multiple unrelated analysis tasks on a data stream. Whereas &lt;tt&gt;sequence_&lt;/tt&gt; takes a list of iteratees to run simultaneously and handles each input chunk by mapM across that list, &lt;tt&gt;psequence_&lt;/tt&gt; runs each input iteratee in a separate forkIO thread. For a real-world example, see Michael Baikov's post about &lt;a href="https://plus.google.com/114526833797384802477/posts/UAqYHwgXpy5" &gt;psequence, psequence_, parE, parI&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Thanks&lt;/b&gt; &lt;/p&gt;&lt;p&gt;Thanks to John Lato for consistently and reliably maintaining the iteratee package, providing thoughtful feedback and graciously suggesting improvements. &lt;/p&gt;&lt;div&gt;
  &lt;img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/9101292118679422945-7124718153026346276?l=blog.kfish.org" alt=""/&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 30 Jul 2010 09:13:14 GMT</pubDate>
      <title>A Haskell template for GTK, Glade, Cairo apps</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=62</link>
      <guid>http://blog.kfish.org/feeds/8561160376803994858/comments/default</guid>
      <description>&lt;p&gt;
I just uploaded &lt;a href="http://hackage.haskell.org/package/cairo-appbase" &gt;cairo-appbase&lt;/a&gt; to Hackage.
This is a template for building new GUI applications using GTK, Glade and Cairo.
&lt;/p&gt;
&lt;p&gt;
To install it:
&lt;pre&gt;&lt;blockquote&gt;
$ cabal update
$ cabal install gtk2hs-buildtools
$ cabal install cairo-appbase
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
Then, run &lt;tt&gt;cairo-appbase&lt;/tt&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://seq.kfish.org/~conrad/images/blog/201007/cairo-appbase-screenshot.png" width="320"/&gt;
&lt;p&gt;
The GTK widget layout is done via a Glade XML file which can be
edited visually using glade.
This template includes working callbacks to handle the File
and Help menus and File Save/Open dialogs, with dummy
handlers for selecting filenames and the Edit menu's
cut/copy/paste.
The main canvas uses Cairo for
graphics rendering, and includes example code from the
cairo package.
&lt;/p&gt;
&lt;p&gt;
To build your own application on top of this, first grab the code. You can either grab it from hackage
with &lt;tt&gt;cabal unpack cairo-appbase&lt;/tt&gt;, or clone the git repo:
&lt;ul&gt;
&lt;li&gt;&lt;tt&gt;git clone &lt;a href="http://github.com/kfish/cairo-appbase" &gt;git://github.com/kfish/cairo-appbase.git&lt;/a&gt;&lt;/tt&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
To add widgets, install glade from your distro system and run &lt;tt&gt;glade data/main.glade&lt;/tt&gt;. Note that you must run &lt;tt&gt;cabal
install&lt;/tt&gt; to put the glade file in the correct place for your application to pick it up.
To modify the code, edit &lt;tt&gt;src/cairo-appbase.hs&lt;/tt&gt;. Hooking up functions to widgets is very simple: get a widget by name 
(which you set in glade file), and hook one of its signals (which you found in the Signals tab in glade) to an &lt;tt&gt;IO ()&lt;/tt&gt; action:
&lt;pre&gt;&lt;blockquote&gt;
  cut1 &lt;- get G.castToMenuItem "cut1"
  G.onActivateLeaf cut1 $ myCut
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
The template code includes a trivial definition of &lt;tt&gt;myCut&lt;/tt&gt;:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
  myCut :: IO ()
  myCut = putStrLn "Cut"
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
A real application will want to pass data to the callback. In C, this is fairly tedious as you only have a single &lt;tt&gt;void *&lt;/tt&gt; to
pass to callbacks as "&lt;tt&gt;user_data&lt;/tt&gt;", and applications typically do lots of marshalling and unmarshalling to pass data around. In
Haskell however, you can make yourself a more complex callback handler and use a curried version of it in each instance:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
  cut1 &lt;- get G.castToMenuItem "cut1"
  G.onActivateLeaf cut1 $ myComplexCut project phase 7

  ...

  myCut :: Project -&gt; MoonPhase -&gt; LuckyNumber -&gt; IO ()
  myCut project phase num = do
      let selection = currentSelection project
      when (phase == Full) howl
      when (num /= 7) fail
      doActualCut selection
&lt;/blockquote&gt;&lt;/pre&gt;

&lt;p&gt;
Erik de Castro Lopo discussed how currying at length in his April 2006 post,
&lt;a href="http://www.mega-nerd.com/erikd/Blog/CodeHacking/Ocaml/gtk_callbacks.html" &gt;GTK+ Callbacks in OCaml&lt;/a&gt;.
The
&lt;a href="http://www.haskell.org/gtk2hs/" &gt;Haskell GTK+&lt;/a&gt; bindings have been around a long time, but were only
recently cabalized and uploaded to Hackage. I put together &lt;tt&gt;cairo-appbase&lt;/tt&gt; in August 2006 when I was
playing with it, but now that I have more time for Haskell I've updated it and uploaded it to Hackage. Enjoy, and hack away!
&lt;/p&gt;

&lt;script type="text/javascript" src="http://reddit.com/static/button/button1.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-8561160376803994858?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 15 Jun 2010 00:06:26 GMT</pubDate>
      <title>Speeding up cross-compiling with ccache and distcc on Debian</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=61</link>
      <guid>http://blog.kfish.org/feeds/7998421825070720483/comments/default</guid>
      <description>&lt;p&gt;
The conventional way of doing embedded development is to cross-compile everything then copy it onto the target,
but working natively allows you to use "normal" tools and workflows.
We want to issue commands directly to a shell on the development board or phone prototype, and speed up the compilation step by distributing it to a faster machine such as your workstation.
This isn't the usual way to do things, but I like working this way, and here's how to make it work faster.
&lt;/p&gt;
&lt;p&gt;
This article explains how to configure a Debian PC host and a Debian target system so that development done on the target invokes the cross-compiler on the host. The advantage offered by this approach is a speed-up of compile times. Note that this does not speed up other aspects of building, such as source configuration (which can be slow for packages using GNU autotools), linking or installation.
&lt;/p&gt;
&lt;p&gt;
We assume that a full Debian system is available for development on the target: packages can be built natively using gcc and a full toolchain (binutils, ld etc.), and
tools such as automake, autoconf, libtool, version control systems etc. are available.
&lt;/p&gt;
&lt;p&gt;
The setup we work with uses Debian on both the host PC and the target.
The examples will use a &lt;a href="http://wiki.debian.org/SH4" &gt;debian-sh4&lt;/a&gt; on the target, with the &lt;tt&gt;sh4-linux-gnu-gcc&lt;/tt&gt;
cross compiler installed on the build host. For other target architectures, simply replace all instances of &lt;tt&gt;sh4-linux-gnu-&lt;/tt&gt; with the arch prefix, eg. &lt;tt&gt;arm-linux-gnueabi-&lt;/tt&gt;.
&lt;/p&gt;
&lt;p&gt;
In this article, commands executed natively on the target device will use the prompt &lt;tt&gt;target#&lt;/tt&gt;, and commands executed on the x86 build host will use the prompt &lt;tt&gt;host#&lt;/tt&gt;.
&lt;/p&gt;
&lt;p&gt;
The first step is to ensure you can build software natively on the target. For GCC:
&lt;pre&gt;&lt;blockquote&gt;
target$ gcc hello.c -o hello
&lt;/blockquote&gt;&lt;/pre&gt;
and for autotools projects:
&lt;pre&gt;&lt;blockquote&gt;
target$ ./configure
target$ make
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;ccache&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
Next, install ccache:
&lt;pre&gt;&lt;blockquote&gt;
target# apt-get install ccache
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;
ccache keeps a cache of compiled object files, such that the same compilation does not need to be repeated. This cache exists outside of your source tree, so it persists across invocations of 'make clean'. It compares the pre-processed source files, so that compilation of a source file will happen if it or any of its included headers is changed. The usual way to use ccache is to simply set your C compiler to be "ccache gcc".
&lt;pre&gt;&lt;blockquote&gt;
target$ ccache gcc hello.c -o hello
&lt;/blockquote&gt;&lt;/pre&gt;

and for autotools projects:
&lt;pre&gt;&lt;blockquote&gt;
target$ CC="ccache gcc" ./configure
target$ make
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
Debian also sets things up so that if you put &lt;tt&gt;/usr/lib/ccache&lt;/tt&gt; ahead of &lt;tt&gt;/usr/bin&lt;/tt&gt; in your PATH, it will get used for native builds whenever gcc is invoked. That is useful to set up, but not necessary for this setup with distcc.
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;An aside about compiler naming&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;
Before we move on to cross compiling, it's important to realize that the native compiler is also available with its full architecture prefix:
&lt;pre&gt;&lt;blockquote&gt;
target$ ls -l /usr/bin/sh4-linux-gnu-gcc
lrwxrwxrwx 1 root root 7 Mar 17 01:45 /usr/bin/sh4-linux-gnu-gcc -&gt; gcc-4.4
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
The binary called sh4-linux-gnu-gcc does the same thing on both the host and target: you can simply think of it as a program that takes in a C file and produces an sh4 binary:
&lt;/p&gt;
&lt;pre&gt;

                +-------------------+ 
    C source -&gt; | sh4-linux-gnu-gcc | -&gt; sh4 binary
                +-------------------+ 
&lt;/pre&gt;
&lt;p&gt;
The distinction between "native" and "cross-" compiling is then just a matter of what machine you are running this compiler program on. If you run &lt;tt&gt;sh4-linux-gnu-gcc&lt;/tt&gt;
on an x86 machine, you are cross-compiling, but if you run &lt;tt&gt;sh4-linux-gnu-gcc&lt;/tt&gt; on an sh4 machine then you are just compiling. Of course the compiler binaries are
different; the point is that a shell script which calls the compiler by its full name would work without modification on either machine.
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;distcc&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
distcc allows you to use a compiler running on a different, faster machine.  This involves running a server (distccd) there, and it is far easier to set up than it would seem.
&lt;/p&gt;
&lt;p&gt;
First, ensure that we can cross-compile on the build host:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
host$ sh4-linux-gnu-gcc hello.c -o hello
host$ file hello
sh4-linux-gnu-gcc hello.c -o hello
host$ file hello
hello: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
&lt;/blockquote&gt;&lt;/pre&gt;

&lt;p&gt;
Next, we install distcc on the build host:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
host# apt-get install distcc
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
To activate the server and tell it what clients to allow, edit &lt;tt&gt;/etc/default/distcc&lt;/tt&gt;:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
STARTDISTCC="true"
ALLOWEDNETS="127.0.0.1 10.0.0.0/16"
&lt;/blockquote&gt;&lt;/pre&gt;

&lt;p&gt;
and restart it:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
host# /etc/init.d/distcc restart
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
You can check that it is running:
&lt;pre&gt;&lt;blockquote&gt;
host# netstat -pant | grep distcc
tcp        0      0 10.0.0.1:3632           0.0.0.0:*               LISTEN      16142/distccd   
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
So that we can ensure that compilation is running on the host, watch this log file in a separate window:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
host# tail -f /var/log/distccd.log
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
Then, on the client (ie. the target system) we also install distcc:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
target# apt-get install distcc
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
We do not need to modify the distcc configuration on the target as it will not be running the server, so Debian's defaults are fine.
However, we do need to set an environment variable to specify which machine[s] to compile on.
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
target$ export DISTCC_HOSTS='host'
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
You run distcc in a similar manner to ccache, by simply setting your C compiler. Note that we are only distributing compilation, not
linking, so we just run the compilation step:
&lt;/p&gt;
&lt;pre&gt;&lt;blockquote&gt;
target$ distcc sh4-linux-gnu-gcc -c hello.c
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
This should turn up in the host's distcc logs:
&lt;pre&gt;&lt;blockquote&gt;
host# tail -f /var/log/distccd.log
distccd[16390] (dcc_job_summary) client: 10.0.1.103:45983 COMPILE_OK exit:0 sig:0 core:0 ret:0 time:46ms sh4-linux-gnu-gcc hello.c
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
And back on the target, we have the &lt;tt&gt;hello.o&lt;/tt&gt; file which was generated by the sh4-linux-gnu-gcc cross-compiler on the build host:
&lt;pre&gt;&lt;blockquote&gt;
target$ ls -l *.o
total 16
-rw-r--r-- 1 conrad conrad  884 Jun 11 07:28 hello.o
target$ file hello.o
hello.o: ELF 32-bit LSB relocatable, Renesas SH, version 1 MathCoPro/FPU/MAU Required (SYSV), not stripped
&lt;/blockquote&gt;&lt;/pre&gt;
&lt;p&gt;
The C file was transferred over the network to the host, where distccd invoked the cross-compiler and then sent the results back to the target. The end result is the same as
if &lt;tt&gt;sh4-linux-gnu-gcc&lt;/tt&gt; had been run directly on the target, but we avoided using the slower CPU of the target system.
&lt;/p&gt;
&lt;p&gt;
To fully take advantage of distcc, you can run &lt;tt&gt;distccd&lt;/tt&gt; on multiple build hosts, and specify all their names in the DISTCC_HOSTS environment variable on the target.
Then use eg. "make -j 10" to run multiple compiles in parallel, which will each then get farmed out to different build hosts.
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Combining ccache and distcc&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;
&lt;strike&gt;You can quite simply put these two tools together, by calling:&lt;/strike&gt;
&lt;pre&gt;&lt;blockquote&gt;
&lt;strike&gt;target$ ccache distcc sh4-linux-gnu-gcc -c hello.c&lt;/strike&gt;
&lt;/blockquote&gt;&lt;/pre&gt;

You can quite simply put these two tools together, by setting CCACHE_PREFIX to "distcc" before calling ccache:
&lt;pre&gt;&lt;blockquote&gt;
target$ export CCACHE_PREFIX="distcc"
target$ ccache sh4-linux-gnu-gcc -c hello.c
&lt;/blockquote&gt;&lt;/pre&gt;

(Thanks to Joel Rosdahl for the correction).
&lt;/p&gt;
&lt;p&gt;
The first time we run this the code is cross-compiled on the build host and sent back to the target, and ccache keeps track of that. The second time we run this, ccache
notices that it already has a stored copy of the output hello.o, and decides to use that rather than calling the compiler. (From ccache's point of view, the compiler is
"distcc sh4-linux-gnu-gcc").
&lt;/p&gt;
&lt;p&gt;
For autotools project, you can simply do the following before calling ./configure:
&lt;pre&gt;&lt;blockquote&gt;
target$ export CCACHE_PREFIX="distcc"
target$ export CC="ccache sh4-linux-gnu-gcc"
&lt;/blockquote&gt;&lt;/pre&gt;
After which the &lt;tt&gt;./configure&lt;/tt&gt; step will write Makefiles which specify to compile with ccache, so the rest of your build (ie. &lt;tt&gt;make -j 10&lt;/tt&gt;) just
works as normal without any new settings or any other change to your workflow.
&lt;/p&gt;
&lt;p&gt;
For more discussion of combining distcc with ccache, see the &lt;a href="http://distcc.samba.org/man/distcc_1.html" &gt;distcc(1)&lt;/a&gt; man page.
&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
By combining both ccache and distcc we can:
&lt;ol&gt;
&lt;li&gt;avoid redundant compilations, and&lt;/li&gt;
&lt;li&gt;distribute required compilations to a faster build host.&lt;/li&gt;
&lt;/ol&gt;
The result is faster build times, which speeds up your development cycle and allows you to work more efficiently on the target system itself.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-7998421825070720483?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 24 May 2010 00:11:28 GMT</pubDate>
      <title>Monday Music: Heyoo by Kobi</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=60</link>
      <guid>http://blog.kfish.org/feeds/8627662583238008113/comments/default</guid>
      <description>&lt;p&gt;
Made with &lt;a href="http://www.metadecks.org/software/aube/" &gt;AUBE&lt;/a&gt; on Linux last November,
this is &lt;a href="http://www.kfish.org/music/Kobi/Kobi-Heyoo_20091105.ogg" &gt;Heyoo&lt;/a&gt; by Kobi:
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;audio src="http://www.kfish.org/music/Kobi/Kobi-Heyoo_20091105.ogg" controls/&gt;
&lt;/p&gt;
&lt;p&gt;
AUBE/Metadecks Live is a music production tool designed for live use. A track
like this is made by setting up a bunch of sample, rhythm and effects
units, playing them for a while and recording the result.
&lt;/p&gt;
&lt;p&gt;
This post uses the HTML5 &amp;lt;audio&amp;gt; tag. If the audio controls are not present then the problem may simply be that your browser does not support HTML5 &amp;lt;audio&amp;gt; with Ogg Vorbis (in which case upgrade to one that does). If you are reading this in a feed reader or via a planet aggregator, then the problem may be that the reader or aggregator strips the HTML5 &amp;lt;audio&amp;gt; tag -- in which case you might want to switch to a more modern reader, or upgrade your planet.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-8627662583238008113?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 17 May 2010 00:11:15 GMT</pubDate>
      <title>Monday Music: Deika by Kobi</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=59</link>
      <guid>http://blog.kfish.org/feeds/2276518944128009387/comments/default</guid>
      <description>&lt;p&gt;
Made with &lt;a href="http://www.kfish.org/aube/" &gt;AUBE&lt;/a&gt; on Linux a few years ago,
this is Deika by Kobi:
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;audio src="http://www.kfish.org/music/Kobi/Kobi-Deika_20011126.ogg" controls/&gt;
&lt;/p&gt;
&lt;p&gt;
AUBE/Metadecks Live is a music production tool designed for live use. A track
like this is made by setting up a bunch of sample, rhythm and effects
units, playing them for a while and recording the result.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-2276518944128009387?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 11 May 2010 01:09:59 GMT</pubDate>
      <title>Streaming Ogg Vorbis with sighttpd 1.1.0</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=58</link>
      <guid>http://blog.kfish.org/feeds/8634118797549037461/comments/default</guid>
      <description>&lt;p&gt;
I just released
&lt;a href="http://www.kfish.org/software/sighttpd/" &gt;Sighttpd&lt;/a&gt; version 1.1.0,
which includes support for streaming Ogg Vorbis from standard input.
In an earlier post introducing
&lt;a href="http://blog.kfish.org/2010/04/new-http-streaming-server-sighttpd-100.html" &gt;a new HTTP streaming server (sighttpd 1.0.0)&lt;/a&gt;,
I described how sighttpd could be used to stream raw data, such as plain text:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;&lt;pre&gt;
$ while `true`; do date; sleep 1; done | sighttpd
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
and H.264 elementary video streams but not Ogg, because an Ogg stream needs to have setup headers prepended for each
codec stream. "Instead, we would need to do something like Icecast:
buffering these headers and serving them first to each client that connects before continuing with live Ogg pages".
&lt;/p&gt;
&lt;p&gt;
So, that's exactly what version 1.1.0 introduces with a new &amp;lt;OggStdin&amp;gt; module.
The sighttpd.conf setup is similar to the normal &amp;lt;Stdin&amp;gt; configuration:

&lt;blockquote&gt;&lt;pre&gt;
Listen 3000

# Streaming Ogg Vorbis from stdin, using the special
# OggStdin module that caches Ogg Vorbis headers
&amp;lt;OggStdin&amp;gt;
        Path "/stream.ogg"
        Type "audio/ogg"
&amp;lt;/OggStdin&amp;gt;
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
You can run this with a shell pipeline like:
&lt;blockquote&gt;&lt;pre&gt;
$ arecord -c 2 -r 44100 -f S16_LE -t wav | oggenc -o - - | sighttpd -f examples/sighttpd-oggstdin.conf
&lt;/pre&gt;&lt;/blockquote&gt;

And you can connect to it as an Ogg stream, eg:
&lt;blockquote&gt;&lt;pre&gt;
$ ogg123 http://localhost:3000/stream.ogg
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
At the start of an Ogg Vorbis file or stream are three mandatory header packets:
&lt;ol&gt;
&lt;li&gt;The &lt;a href="http://wiki.xiph.org/OggVorbis" &gt;Vorbis BOS&lt;/a&gt; (beginning of stream) header,
which describes basic information like the number of channels and the samplerate of the audio.
&lt;/li&gt;
&lt;li&gt;Metadata in &lt;a href="http://wiki.xiph.org/VorbisComment" &gt;VorbisComment&lt;/a&gt; format, which
basically consists of text values like "ARTIST=Richard Feynman".
&lt;/li&gt;
&lt;li&gt;The setup header, which includes "codec setup information as well as the complete VQ and Huffman
&lt;a href="http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-170001.2.6" &gt;codebooks&lt;/a&gt;
needed for decode".
&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;
&lt;p&gt;
We can view the raw contents of these packets with
&lt;a href="http://www.xiph.org/oggz/" &gt;oggz dump&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;&lt;pre&gt;
$ oggz dump &lt;a href="http://blog.kfish.org/2010/05/monday-music-birk-by-kobi.html" &gt;Kobi-Birk_20011125.ogg&lt;/a&gt; |head -n 30
00:00:00.000: serialno 0639825516, granulepos 0, packetno 0 *** bos: 30 bytes
    0000: 0176 6f72 6269 7300 0000 0002 44ac 0000  .vorbis.....D...
    0010: 18fc ffff 00f4 0100 18fc ffff b801       ..............

00:00:00.000: serialno 0639825516, calc. gpos 0, packetno 1: 94 bytes
    0000: 0376 6f72 6269 7320 0000 0058 6970 686f  .vorbis ...Xipho
    0010: 7068 6f72 7573 206c 6962 566f 7262 6973  phorus libVorbis
    0020: 2049 2032 3030 3130 3831 3303 0000 000a   I 20010813.... 
    0030: 0000 0074 6974 6c65 0042 6972 6b0b 0000  ...title.Birk ..
    0040: 0061 7274 6973 7400 4b6f 6269 0d00 0000  .artist.Kobi ...
    0050: 6461 7465 0032 3030 3131 3132 3501       date.20011125.

00:00:00.000: serialno 0639825516, granulepos 0, packetno 2: 2.820 kB
    0000: 0576 6f72 6269 7325 4243 5601 0040 0000  .vorbis%BCV..@..
    0010: 8020 9a19 a7b1 945a 6bad 1d72 9a42 abb5  . .....Zk..r.B..
    0020: d65a 6bad 2594 5a5b adb5 d65a 6bad b5d6  .Zk.%.Z[...Zk...
    0030: 5a6b adb5 d65a 6b8d 81d0 9055 0000 1000  Zk...Zk....U....
    0040: 0021 0c55 0651 c99c d65a 6b44 1064 0649  .! U.Q...ZkD.d.I
    0050: e920 d65a 6be8 a0a5 105a 4cad d65a 6bad  . .Zk....ZL..Zk.
    0060: b5d6 5a6b adb5 d61a 6320 3464 1500 0004  ..Zk....c 4d....
    0070: 00c0 1863 8c31 0619 6410 5248 21a5 9452  ...c.1..d.RH!..R
    0080: 8c31 e618 74d2 5147 9d76 da71 6821 9594  .1..t.QG.v.qh!..
    0090: 5acc 2de7 9c73 ceb9 d61a 080d 5905 0024  Z.-..s..... Y..$
    00a0: 0000 a838 8664 5886 0584 86ac 0200 3200  ...8.dX.......2.
    00b0: 0004 1024 4353 34c7 d554 cf34 5d55 0542  ...$CS4..T.4]U.B
    00c0: 4356 0100 4000 0002 8000 0a18 4451 1445  CV..@..... .DQ.E
    00d0: 5114 4551 1445 d1f3 3ccf f33c cff3 3ccf  Q.EQ.E..&lt;..&lt;..&lt;.
    00e0: f33c cff3 3ccf f33c cf03 4243 5601 0009  .&lt;..&lt;..&lt;..BCV.. 
    00f0: 0000 1a8a a228 8ee2 00a1 21ab 0080 0c00  .....(....!... .
    0100: 0001 0cc7 9014 49d1 244d d22c cff2 80d0  .. ...I.$M.,....

&lt;/pre&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
When a client connects to a stream somewhere in the middle of a song, these headers from the
beginning are required in order to decode the audio data.
sighttpd writes the pages containing the 3 header packets to a temporary file (created with
&lt;tt&gt;mkstemp(3)&lt;/tt&gt;). When a new client connects, the contents of that file are sent to it
with &lt;tt&gt;sendfile(2)&lt;/tt&gt; before jumping into the current contents of the stream.
&lt;/p&gt;
&lt;p&gt;
I'm not trying to make a replacement for Icecast, but instead building a more general
streaming server -- and of course I want it to have good Ogg support! So, please try it out,
and leave some feedback in the comments or in email to me or ogg-dev :)
&lt;/p&gt;

&lt;script type="text/javascript" src="http://reddit.com/static/button/button1.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-8634118797549037461?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 10 May 2010 00:07:46 GMT</pubDate>
      <title>Monday Music: Birk by Kobi</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=57</link>
      <guid>http://blog.kfish.org/feeds/8064008898840368363/comments/default</guid>
      <description>&lt;p&gt;
Made with &lt;a href="http://www.kfish.org/aube/" &gt;AUBE&lt;/a&gt; on Linux a few years ago,
this is Birk by Kobi:
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;audio src="http://www.kfish.org/music/Kobi/Kobi-Birk_20011125.ogg" controls/&gt;
&lt;/p&gt;
&lt;p&gt;
AUBE/Metadecks Live is a music production tool designed for live use. A track
like this is made by setting up a bunch of sample, rhythm and effects
units, playing them for a while and recording the result.
&lt;/p&gt;
&lt;p&gt;
The rhythms are made with a simple drum machine, which is basically a matrix
of triggers tied up to sample players. These are fed through a cascade of
delays to get the rolling effect -- I love feeding a short delay to provide
echo into a longer delay which matches the beat, so that the individual
sounds combine with each other to make a more complex rhythm.
&lt;/p&gt;
&lt;p&gt;
The rhythm is sent through a resonant low-pass filter; as the track starts
off, the cutoff of that filter is raised to give the effect of opening up
the whole track. It's a pretty simple technique, used in tracks like
Fatboy Slim's &lt;a href="http://en.wikipedia.org/wiki/Right_Here,_Right_Now_(Fatboy_Slim_song)" &gt;Right Here, Right
Now&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The filtered version is called the "wet" part of the mix, and the unfiltered
version is the "dry" part. Changing the amount of these is useful: the dry part
provides definition (the attacks of each drum are clearly audible), and the wet
part has a more interesting texture. In a sequencer you might program the "wetness"
of the effect; I like to work with it more directly by  feeding the two
versions into a cross-fader and switching between them live. If you are quick enough
with the controls then your other arm is free for doing handstands :)
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-8064008898840368363?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Sat, 8 May 2010 07:11:17 GMT</pubDate>
      <title>A monoid for server parties</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=56</link>
      <guid>http://blog.kfish.org/feeds/4768917548653396328/comments/default</guid>
      <description>&lt;p&gt;
Happstack is a Haskell web applications framework.
I hadn't played with it in a while but
Happstack 0.5.0 was recently released
so I decided to try it out. You can get it with
&lt;a href="http://cabal.haskell.org/" &gt;cabal&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;
&lt;pre&gt;$ cabal update
$ cabal install happstack
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
Happstack has a pretty detailed tutorial, which is actually a
self-hosted happstack site that you can &lt;tt&gt;cabal install&lt;/tt&gt;
and dig around in. It takes a while though, so let's just get
into it. The tutorial doesn't actually start showing
any code until section 7,
&lt;a href="http://tutorial.happstack.com/tutorial/your-first-happstack" &gt;first
shot at happstack&lt;/a&gt;. This shows you how to run a Hello World
server from Haskell's
&lt;abbrev title="Read-Evaluate-Print Loop"&gt;REPL&lt;/abbrev&gt; &lt;tt&gt;ghci&lt;/tt&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;
&lt;pre&gt;$ ghci
Prelude&gt; import Happstack.Server
Prelude Happstack.Server&gt; simpleHTTP (Conf 8080 Nothing) (return "Hello World!")
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
Then your &lt;a href="http://localhost:8080/" &gt;http://localhost:8080/&lt;/a&gt; should show a Hello World
message, ie. you can run this in another terminal:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;
&lt;pre&gt;$  curl -i http://localhost:8080/
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 12
Content-Type: text/plain; charset=UTF-8
Date: Tue, 04 May 2010 01:02:31 GMT
Server: Happstack/0.5.0

Hello World!
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A REPL is great for playing around, but some real code to read
for an example server is
&lt;a href="http://tutorial.happstack.com/src/ControllerBasic.hs" &gt;ControllerBasic.hs&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
At the top of that file we get hit with this:
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote&gt;
mzero corresponds to a 404 and mzero `mappend` f = f,
while if f is not mzero then f `mappend` g = f.
&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
That's not even code, it's a &lt;emph&gt;comment&lt;/emph&gt;.
&lt;i&gt;Like, omg why would anyone talk like that? lol&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
It's talking about a type called &lt;tt&gt;ServerPartT&lt;/tt&gt;, which you can think of as
an abstract part of your web server, like the part that handles "everything under
&lt;tt&gt;/articles&lt;/tt&gt;" or "all the images". If you connect a bunch of these together
you get your whole web server.
Anyway, it turns out that it's much more fun if you simply pronounce ServerPartT as
"Server Party":
&lt;/p&gt;
&lt;p&gt;
&lt;p align="center"&gt;
&lt;img title="It seems somehow approrpiate that servers would be wearing party hats. Servers seem to enjoy many of
the same things that cats do, like long naps and bits of string. Also, both dislike water." alt="A Server Party" src="http://seq.kfish.org/%7Econrad/images/blog/201005/server-party.png" width="320" /&gt;
&lt;/p&gt;
&lt;p&gt;
So what's all this about monoids?
Mathematically speaking, a monoid is a simple party game that some data objects
can play when they get together. This is a mathematical definition in the
sense that mathematicians are fun at parties.
&lt;/p&gt;
&lt;p&gt;
The rules of the game are just that you have some way of appending things together;
the tricky Haskell name for this is &lt;tt&gt;mappend&lt;/tt&gt;, named after
&lt;a href="http://en.wikipedia.org/wiki/Nicolas_Bourbaki" &gt; the famous French mathematician&lt;/a&gt;
M. Append. Whenever you &lt;tt&gt;mappend&lt;/tt&gt; two things together you get another thing
of the same type that can also be &lt;tt&gt;mappend&lt;/tt&gt;ed. There's also an empty element
called &lt;tt&gt;mempty&lt;/tt&gt;, or here called &lt;tt&gt;mzero&lt;/tt&gt;(*).
&lt;/p&gt;
&lt;p&gt;
So a monoid is just a way of saying how you connect things up. In terms of
&lt;tt&gt;ServerPartT&lt;/tt&gt;s:
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;mzero corresponds to a 404&lt;/b&gt;:
  The empty part of your server is
&lt;a href="http://www.squareoak.com/blog/404-pages-funny-geeky-disturbing/" &gt;404 Not Found&lt;/a&gt;;
ie. if your server contained
no application parts at all, it would just have to return 404 for any request. In
general if a ServerPartT can't handle the current request (eg. the &lt;tt&gt;ServerPartT&lt;/tt&gt;
for images doesn't handle &lt;tt&gt;/articles&lt;/tt&gt; then it'll act like &lt;tt&gt;mzero&lt;/tt&gt; for that
request).
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;mzero `mappend` f = f&lt;/b&gt;:
&lt;tt&gt;mappend&lt;/tt&gt; is the way that you connect up two server parts. Basically you just try
server parts one after another: when a request comes along, if the first &lt;tt&gt;ServerPartT&lt;/tt&gt;
can't handle it, ie. acts like &lt;tt&gt;mzero&lt;/tt&gt;, then try the next &lt;tt&gt;ServerPartT&lt;/tt&gt;
(and hey let's call it &lt;tt&gt;f&lt;/tt&gt;).
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;if f is not mzero then f `mappend` g = f&lt;/b&gt;:
  On the other hand, if the first server part &lt;emph&gt;can&lt;/emph&gt; handle the request,
ie. it does not return 404 and is not &lt;tt&gt;mzero&lt;/tt&gt;, then use it and ignore all the
other &lt;tt&gt;ServerPartT&lt;/tt&gt;s (call them &lt;tt&gt;g&lt;/tt&gt;). The whole server is acting just like &lt;tt&gt;f&lt;/tt&gt;
by itself!
&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
The point is that because &lt;tt&gt;ServerPartT&lt;/tt&gt; follows all the rules of the monoid party game,
you can suddenly use all the functions available in
&lt;a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Data-Monoid.html" &gt;Data.Monoid&lt;/a&gt;,
like &lt;tt&gt;mconcat&lt;/tt&gt; which takes a whole list of objects and works out what would happen if they were all
&lt;tt&gt;mappend&lt;/tt&gt;ed together. This allows you to simply make a list of &lt;tt&gt;ServerPartT&lt;/tt&gt;s and use the first one
that doesn't return 404: you don't even need to write a function for evaluating your whole server, you can
just use the plain old boring &lt;tt&gt;mconcat&lt;/tt&gt; from the base libraries!
&lt;/p&gt;
&lt;p&gt;
The structure of monoids (stuff that can be appended) is pretty trivial, but very common. I highly recommend
sigfpe's
&lt;a href="http://blog.sigfpe.com/2009/01/haskell-monoids-and-their-uses.html" &gt;Haskell Monoids and their Uses&lt;/a&gt;
to learn about some other more general uses.
&lt;/p&gt;
&lt;p&gt;
As for Happstack: it's obviously a bit deeper than your average web framework. In this article I've only looked at
the basic idea behind making a server; it has many more features for managing data, transactions and scaling.
So what do you think? Is the monoidal mumbo-jumbo useful or does it just add a layer of confusion?
Would servers really wear party hats to a &lt;tt&gt;ServerPartT&lt;/tt&gt;?
&lt;/p&gt;
&lt;h6&gt;(*) because &lt;tt&gt;ServerPartT&lt;/tt&gt; is the awesome kind of monoid formed by the &lt;tt&gt;MonadPlus&lt;/tt&gt; type class,
obviously.&lt;/h6&gt;

&lt;script type="text/javascript" src="http://reddit.com/static/button/button1.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-4768917548653396328?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 5 May 2010 00:11:06 GMT</pubDate>
      <title>How oggz-validate works</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=55</link>
      <guid>http://blog.kfish.org/feeds/3926367212962321099/comments/default</guid>
      <description>&lt;p&gt;
&lt;a href="http://xiph.org/oggz/" &gt;oggz-validate&lt;/a&gt;
is a tool for checking the conformance of Ogg files against the
&lt;a href="http://xiph.org/ogg/doc/framing.html" &gt;Ogg logical bitstream framing&lt;/a&gt; specification
and &lt;a href="http://www.ietf.org/rfc/rfc3533.txt" &gt;RFC3533&lt;/a&gt;.
It is used by 
&lt;a href="http://validator.xiph.org/" &gt;validator.xiph.org&lt;/a&gt;
an online conformance-checking service.
&lt;/p&gt;
&lt;p&gt;
oggz-validate builds on the correctness checks imposed by liboggz when
writing Ogg packets. Whereas the low-level libogg simply allows an application to construct arbitrary
Ogg packets and push them into a stream, liboggz checks each packet against the basic constraints:
&lt;ul&gt;
&lt;li&gt;Packet belongs to unknown serialno&lt;/li&gt;
&lt;li&gt;Granulepos decreasing within track&lt;/li&gt;
&lt;li&gt;Multiple bos pages&lt;/li&gt;
&lt;li&gt;Multiple eos pages&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://www.xiph.org/oggz/doc/group__write__api.html" &gt;oggz_write()&lt;/a&gt; fails if any of
these constraints are violated.
&lt;/p&gt;
&lt;p&gt;
oggz-validate works by
reading the input file and attempting to reproduce its sequence of packets.
It creates both a reader and a writer and feeds the output of the reader into the writer;
any errors in stream creation are reported as validation errors.
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;img src="http://seq.kfish.org/~conrad/images/blog/201005/oggz-validate.png" width="480" alt="File -&amp;gt; oggz_read() -&amp;gt; packets -&amp;gt; oggz_write() -&amp;gt; discard"/&gt;
&lt;/p&gt;
&lt;p&gt;
Additionally, oggz_write() checks the following higher-level constraints:
&lt;ul&gt;
&lt;li&gt;File contains no Ogg packets&lt;/li&gt;
&lt;li&gt;Packets out of order&lt;/li&gt;
&lt;li&gt;eos marked but no bos&lt;/li&gt;
&lt;li&gt;Missing eos pages&lt;/li&gt;
&lt;li&gt;eos marked on page with no completed packets&lt;/li&gt;
&lt;li&gt;Granulepos on page with no completed packets&lt;/li&gt;
&lt;li&gt;Theora video bos page after audio bos page&lt;/li&gt;
&lt;li&gt;Terminal header page has non-zero granulepos&lt;/li&gt;
&lt;li&gt;Terminal header page contains non-header packet&lt;/li&gt;
&lt;li&gt;Terminal header page contains non-header segment&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
For example, the check for "packets out of order" uses liboggz's parsing of codec granulepos
to interpret timestamps of many free codecs including Ogg Dirac, FLAC, Speex, Theora and Vorbis.
Also, there is a simple constraint in the specification for Ogg Theora that the
BOS (Beginning Of Stream) header packet for Theora must come before that for Vorbis (or
another audio codec).
&lt;/p&gt;
&lt;p&gt;
What oggz-validate does not do is check that the contents of the codec streams are valid for
that codec. Such checking is left up to codec-specific tools such as
&lt;tt&gt;&lt;a href="http://svn.xiph.org/trunk/vorbose/" &gt;vorbose&lt;/a&gt;&lt;/tt&gt;, and &lt;tt&gt;flac --test&lt;/tt&gt;.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-3926367212962321099?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 4 May 2010 00:09:27 GMT</pubDate>
      <title>Towards adaptive streaming for Ogg</title>
      <link>http://www.advogato.org/person/conrad/diary.html?start=54</link>
      <guid>http://blog.kfish.org/feeds/3466807149703410327/comments/default</guid>
      <description>&lt;p&gt;
Video streaming must be reliable and glitch-free. It must be possible for video hosting
sites to allow clients to adapt to the available bandwidth, and for clients to be able to
take advantage of this.
&lt;/p&gt;
&lt;p&gt;
Adaptive streaming refers to a system which allows a video streaming client to
request different versions of a stream according to the bandwidth it has
available, and to change this selection on the fly, during the course of streaming.
Such a system of course requires the streaming server to have various versions of
a stream available, each in different bitrates. In order to allow the client to
switch streams on the fly the content must be produced in such a way that corresponding
video frames in the different representations can be easily accessed and decoded.
&lt;/p&gt;
&lt;p&gt;
The first stage in building an adaptive streaming system is making it work for static content,
ie. files on disk. The second stage is making it work for live content, ie. streams coming
from a video production system consisting of cameras, mixing desks and random people in
black tshirts. The first is mainly a technical problem; the second requires developing both
technology and production processes.
&lt;/p&gt;
&lt;p&gt;
Microsoft have a proprietary technology for adaptive bitrate streaming called
&lt;a href="http://learn.iis.net/page.aspx/626/smooth-streaming-technical-overview/" &gt;Smooth Streaming&lt;/a&gt;,
and an extension for
&lt;a href="http://www.iis.net/download/livesmoothstreaming" &gt;Live Smooth Streaming&lt;/a&gt;.
Apple are following a more open path, pursuing standardization of their specifications through
the IETF, in the current form of the
&lt;a href="http://tools.ietf.org/html/draft-pantos-http-live-streaming-03" &gt;HTTP Live Streaming&lt;/a&gt;
Internet-Draft. This extends the m3u playlist format with
durations, sequence numbering, caching and stream information hints.
&lt;/p&gt;
&lt;p&gt;
Ogg does not yet have an adaptive streaming specification; this should be developed in a
way that is compatible with open specifications, and also taking into account the various
quirks of Ogg. For example, the client must have access to codec setup headers for each
bitrate representation, and the system must accomodate chained Ogg resources (as commonly
used for streaming Ogg).
In the
&lt;a href="http://www.w3.org/2008/01/media-fragments-wg.html" &gt;W3C Media Fragments&lt;/a&gt;
working group we are developing specifications for addressing fragments
of media resources. The ongoing development of
&lt;a href="http://wiki.xiph.org/Ogg_Skeleton" &gt;Ogg Skeleton&lt;/a&gt; allows Ogg to take advantage
of these, allowing faster seeking through
&lt;a href "http://wiki.xiph.org/OggIndex"&gt;OggIndex&lt;/a&gt; and gapless playback through hints on
presentation time.
&lt;/p&gt;
&lt;p&gt;
Encouraging use of these features requires tool support and demonstrations of novel
applications for video mash-ups. Video on the web should be a means of creative
expression, allowing new applications that mash up parts of many videos and present
the result seamlessly to the user. This goal makes Ogg fun, and brings us beyond
thinking about video on the Web as just a different way of watching pre-packaged TV-style
content.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9101292118679422945-3466807149703410327?l=blog.kfish.org' alt='' /&gt;&lt;/div&gt;</description>
    </item>
  </channel>
</rss>

