Re: [ecasound] update: ECI API

New Message Reply Date view Thread view Subject view Author view Other groups

Subject: Re: [ecasound] update: ECI API
From: Kai Vehmanen (k@eca.cx)
Date: Mon Dec 04 2000 - 05:15:52 EET


On Fri, 1 Dec 2000, janne halttunen wrote:

>>> (from my point of view) An important question: can one have multiple instances of ECI to one engine?
>> Multiple instances, yes, but controlling the same engine, no. But that
> I'm thinking about threading. I haven't much experience of it
> yet, but I have a feeling I'm gonna delve into it sometime. So, if:

Good thing that this came up, because ECI API will _not_ be thread-safe.
As most ECI clients won't use threading, it's better to leave locking
out of ECI implementation. It would mean that even non-threaded apps
using ECI API would suffer from the locking overhead. But this
shouldn't stop you from using threading, you just have to take care of
locking yourself. So instead of...:

> thread A:
> eci1.command("cs-position")
> a=eci1.last_double()
>
> thread B:
> eci1.command("aio-position")
> b=eci1.last_double()

A:
eci1_lock.lock()
eci1.command("cs-position")
a=eci1.last_double()
ec1_lock.unlock()

B:
eci1_lock.lock()
eci1.command("aio-position")
b=eci1.last_double()
eci1_lock.unlock()

Without the locking, there might be two threads messing with libecasound's
internals at the same time, and that's a bad thing. :)

One common way to use threading with non-threadsafe libraries (there're
lot of them out there) is to centralize all library use to one thread.
This is especially common in GUI programming. Apps can have lots of
threads running, but only one of them makes GUI calls.

>> eci_command("cs-is-connected")
>> a = eci_last_integer()
>> if (a != 0) print("Connected!")
> Ok. I was just wondering about from where to extract the
> information. Still not worried about the growing list of
> iam-commands?

Well, at least not yet. :) My plan is to use the "easy access to simple
functions, obscurity allowed for complex tasks" paradigm that has proven
succesful with ecasound's command-line arguments. A prime example of this
is that ecasound accepts "ecasound myfile.mp3" and translates this
automatically to "ecasound -a:default -i:myfile.mp3 -o:/dev/dsp" before
execution. An example of complex&obscure is '-z:psr' (enable precise
sample-rate feature for OSS devices). Similarly I could introduce a
"special-xxx-yyy" command to ia-mode which would cover all the rarely
needed functions without cluttering the ia-mode namespace

-- 
 . http://www.eca.cx ... [ audio software for linux ] /\ . 
 . http://www.eca.cx/sculpscape [ my armchair-tunes mp3/ra/wav ]

-- To unsubscribe send message 'unsubscribe' in the body of the message to <ecasound-list-request@wakkanet.fi>.


New Message Reply Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Dec 04 2000 - 05:27:03 EET