[gst-devel] Co-routines functional in GStreamer

Erik Walthinsen omega at cse.ogi.edu
Wed Mar 22 11:31:04 CET 2000


I've just gotten coroutines to work for simple pipelines.  I have fake
source and sink elements in both chain and loop forms, and they work
interchangably with others.  Switching between elements happens whenever
there's a push or a pull that isn't satisfied by the holding pen.  There
is a nice clean split between the pad and container code, such that the
coroutine-based container can be replaced with something else trivially
(just use a different factory to create the container).

In the bin code there are places where code can be placed allowing the
whole thing to be stopped (at the next buffer passing), allowing state
control easily with no help from the elements themselves.

This means that there will be three ways to write an element:

a) chain function attached to each sink pad
b) loop function that pulls from pads and pushes to others, in while(1)
c) 'loop' function that pulls and pushes, but does so once

Method c) is a trivial change from b) enabled by a while(1) in the wrapper
function around the loop function, with zero added cost in the b) case
(since it's "start:call loopfunc;jmp start" in assembler).  Of course,
those familiar with coroutines know that having an arbitrary number of
while(1) loops in your code doesn't matter as long as their capable of
switching to other coroutines.

For everyone else on the gst-devel list who cares, I'll write up something
on what this all means sometime tomorrow, when my eyes aren't about to
shut independent of my brain's commands to stay open just a few seconds
longer.  I won't be committing the code until I've done a lot more testing
and verification, and have gone over the videosink stuff (since it seems
to use the pad->push() stuff for something that looked orthogonal at first
glance).

TTYL,
    Omega

         Erik Walthinsen <omega at cse.ogi.edu> - Staff Programmer @ OGI
        Quasar project - http://www.cse.ogi.edu/DISC/projects/quasar/
   Video4Linux Two drivers and stuff - http://www.cse.ogi.edu/~omega/v4l2/
        __
       /  \             SEUL: Simple End-User Linux - http://www.seul.org/
      |    | M E G A           Helping Linux become THE choice
      _\  /_                          for the home or office user





More information about the gstreamer-devel mailing list