* Are ALSA io plugins implemented as threads or does ALSA use fork() ?
@ 2010-03-19 14:20 Stefan Schoenleitner
2010-03-19 14:44 ` Jaroslav Kysela
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Schoenleitner @ 2010-03-19 14:20 UTC (permalink / raw)
To: alsa-devel@alsa-project.org
Hello,
from what I have learned so far ALSA io plugins are implemented as
shared libraries with their entry point defined with the
SND_PCM_PLUGIN_DEFINE_FUNC() macro.
However, each plugin instance can only work for either the
SND_PCM_STREAM_PLAYBACK or SND_PCM_STREAM_CAPTURE stream.
Hence this is why io plugins supporting playback and capture usually set
up their callback functions depending on what type of stream is used.
For example in the pulseaudio io plugin, this is done with:
pcm->io.callback = stream == SND_PCM_STREAM_PLAYBACK ?
&pulse_playback_callback : &pulse_capture_callback;
* If such a plugin is used for capture AND playback at the same time, it
seems that two instances of the plugin need to be running, right ?
* Are these instances running as separate processes (i.e. fork()) or are
they implemented as threads ? How is this implemented internally in the
ALSA code ?
In my plugin I'm planning that both the playback and the capture plugin
instances talk to a common data processing thread over shared buffers.
The reason for this is that the data processing threads needs to have
access to the capture and playback samples *at the same time*.
I'm guessing that the plugin instances run with different PIDs so that I
would need to use common IPC mechanisms in order to let them communicate
with each other, right ?
Hence my first approach would be to set up a common shared memory
together with a semaphore so that only one process can access the shared
memory at a time.
Any better ideas ?
cheers,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Are ALSA io plugins implemented as threads or does ALSA use fork() ?
2010-03-19 14:20 Are ALSA io plugins implemented as threads or does ALSA use fork() ? Stefan Schoenleitner
@ 2010-03-19 14:44 ` Jaroslav Kysela
2010-03-19 15:20 ` Stefan Schoenleitner
0 siblings, 1 reply; 3+ messages in thread
From: Jaroslav Kysela @ 2010-03-19 14:44 UTC (permalink / raw)
To: Stefan Schoenleitner; +Cc: alsa-devel@alsa-project.org
On Fri, 19 Mar 2010, Stefan Schoenleitner wrote:
> Hello,
>
> from what I have learned so far ALSA io plugins are implemented as
> shared libraries with their entry point defined with the
> SND_PCM_PLUGIN_DEFINE_FUNC() macro.
>
> However, each plugin instance can only work for either the
> SND_PCM_STREAM_PLAYBACK or SND_PCM_STREAM_CAPTURE stream.
> Hence this is why io plugins supporting playback and capture usually set
> up their callback functions depending on what type of stream is used.
>
> For example in the pulseaudio io plugin, this is done with:
>
> pcm->io.callback = stream == SND_PCM_STREAM_PLAYBACK ?
> &pulse_playback_callback : &pulse_capture_callback;
>
>
>
>
> * If such a plugin is used for capture AND playback at the same time, it
> seems that two instances of the plugin need to be running, right ?
>
> * Are these instances running as separate processes (i.e. fork()) or are
> they implemented as threads ? How is this implemented internally in the
> ALSA code ?
No forks or threads. Both instances will run in one process with the
audio application. The plugin code must take core how many pcm instances
are active and send the appropriate communication file descriptors to
application for select/poll I/O multiplexing.
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Are ALSA io plugins implemented as threads or does ALSA use fork() ?
2010-03-19 14:44 ` Jaroslav Kysela
@ 2010-03-19 15:20 ` Stefan Schoenleitner
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Schoenleitner @ 2010-03-19 15:20 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: alsa-devel@alsa-project.org
Jaroslav Kysela wrote:
> On Fri, 19 Mar 2010, Stefan Schoenleitner wrote:
>> * Are these instances running as separate processes (i.e. fork()) or are
>> they implemented as threads ? How is this implemented internally in the
>> ALSA code ?
>
> No forks or threads. Both instances will run in one process with the
> audio application. The plugin code must take core how many pcm instances
> are active and send the appropriate communication file descriptors to
> application for select/poll I/O multiplexing.
Thanks for the quick answer, I have a better understanding of the plugin
concept now.
cheers,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-19 15:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-19 14:20 Are ALSA io plugins implemented as threads or does ALSA use fork() ? Stefan Schoenleitner
2010-03-19 14:44 ` Jaroslav Kysela
2010-03-19 15:20 ` Stefan Schoenleitner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.