All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Schlemmer <Tobias.Schlemmer@tu-dresden.de>
To: Tobias Schlemmer <keinstein_junior@gmx.net>, alsa-devel@alsa-project.org
Subject: Re: cloning snd_seq_t (or creating one from client id)
Date: Mon, 31 Mar 2014 16:40:20 +0200	[thread overview]
Message-ID: <53397E54.2060309@tu-dresden.de> (raw)
In-Reply-To: <53395FA7.5050704@ladisch.de>

[-- Attachment #1: Type: text/plain, Size: 2091 bytes --]

Am 31.03.2014 14:29, schrieb Clemens Ladisch:
> Tobias Schlemmer wrote:
>> I'm surprised that the upcoming version of RtMidi uses one ALSA client
>> per MIDI port.
>>
>> I found out that sequencer handles (snd_seq_t) are not thread safe.
> A sequencer client use a common buffer for the events of all ports.
Yes. Thus, I suggested to split the set of ports of a client into
disjoint subsets. Then each sequencer would handle only one of these
subsets, which should reduce the interference with other ports' code.
>> Could you provide some way to implement multithreaded ALSA clients?
> Multiple threads would have to synchronize the buffer accesses in some
> way.
That is not true. Programmers tend to program lock free, as locking
creates always a bottleneck. Other problems can occur if have different
load and different priority to the program. The current aproach that is
taken by kmid and RtMidi is to use different sequencers. The ALSA docu
suggests to use different sequencers in the latter way. Unfortunately
this does not comply with the idea of clients and ports as they are
presented to end users. So I suggested to hide this implementation
detail from the end user and present him all ports from all sequencers
of a program instance under one common client id. The port ids used in
the sequencers should be the same as the ones that are presented to the
end user in order to prevent unexpected behaviour.

How exactly merging and distributing of events from/to multiple
ports is handled (even when some thread does not react) is a policy that
cannot be imposed by the ALSA library.

The current policy is forcing the client to serialise events of
different connections that don't interfere. The ALSA imposes a policy
that is obviously is not necessary from a technical point of view as
every program instance can use different sequencer clients already with
the current implementation at the cost of worsening the usability. My
suggestion is to losen this restriction.

Regards,

Tobias

P.S.: We are talking about the library API right?

[-- Attachment #2: 0x73A2F90C.asc --]
[-- Type: application/pgp-keys, Size: 4372 bytes --]

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2014-03-31 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31  6:31 cloning snd_seq_t (or creating one from client id) Tobias Schlemmer
2014-03-31 12:29 ` Clemens Ladisch
2014-03-31 14:40   ` Tobias Schlemmer [this message]
2014-03-31 21:01     ` Clemens Ladisch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53397E54.2060309@tu-dresden.de \
    --to=tobias.schlemmer@tu-dresden.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=keinstein_junior@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.