Re: [linux-audio-dev] a port/buffer proposal

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] a port/buffer proposal
From: Richard Guenther (rguenth_AT_tat.physik.uni-tuebingen.de)
Date: Wed May 23 2001 - 15:38:35 EEST


On Tue, 22 May 2001, Paul Davis wrote:

> So in GLAME, there are really only input ports and output buffers,
> true? A plugin writes into an output buffer, and sees its input
> port(s) as a list of connected pipes that point back to buffers?
>
> The issue there is that it means that plugins have to be "smart" about
> reading data from a port. I think there is something appealing about
> putting the "intelligence" in the host, and allowing plugins to see
> reading and writing as just operations a single, contiguous memory
> region (for audio, anyway).

Perhaps I should speak "code" - so code follows for a simple
volume adjust plugin (without setup/cleanup fragments) - so this
is the simple (but common) case of having exactly one input and
one output:

/* loop, receiving new buffers from input until an EOS comes in (this
 * blocks, if no buffers are available) */
while ((buf = sbuf_get(input))) {
        /* we want to do in-place processing */
        buf = sbuf_make_private(buf);
        /* get float * pointer to the actual buffer and its size */
        s = sbuf_buf(buf);
        len = sbuf_size(buf);
        /* do the work - scale samples with factor */
        for (;len>0;len--)
                *(s++) *= factor;
        /* queue the processed buffer to our output port (may block
         * for rate limiting) */
        sbuf_queue(output, buf);
}
/* signal EOS */
sbus_queue(output, NULL);

Richard.

--
Richard Guenther <richard.guenther_AT_uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Wed May 23 2001 - 17:06:55 EEST