All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC alsa-lib 0/5] Add thread-safety to PCM API
@ 2016-07-05 15:20 Takashi Iwai
  2016-07-05 15:20 ` [PATCH RFC alsa-lib 1/5] pcm: " Takashi Iwai
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Takashi Iwai @ 2016-07-05 15:20 UTC (permalink / raw)
  To: alsa-devel

Hi,

here is an experimental patchset to add multi thread safety to PCM
functions.  Basically ALSA PCM functions are thread-unsafe, and
applications are supposed to do the proper protection against racy
accesses.  The reality is, however, that application developers don't
care such, as alsa-lib works in most cases.  Of course, users still
get occasionally mysterious crashes.

As a workaround, this patchset adds the pthread mutex protection to
most of exported PCM functions.  This is slightly an overkill, but the
biggest merit is that it's easy to implement; I just wrapped the
functions and replaced the internal ones with unlocked versions.

To be noted, there is an optimization for the direct hw PCM access.
Performance-sensitive applications like JACK should work like before
without any overhead.

Another bonus by this addition is that we can finally get rid of home
brew (and deadly smelling) atomic macros from the tree, since it's now
more widely protected.

I lightly tested on my local machines and it seems working well, so
far.

Comments and suggestions welcome.


thanks,

Takashi

===

Takashi Iwai (5):
  pcm: Add thread-safety to PCM API
  test: Add pcm-multi-thread program
  Add pcm-multi-thread to .gitignore
  pcm: Remove superfluous rmb() from PCM meter plugin
  pcm: Remove home brew atomic operations

 .gitignore              |   1 +
 configure.ac            |  15 ++
 include/Makefile.am     |   2 +-
 include/iatomic.h       | 170 ------------------
 src/pcm/Makefile.am     |   2 +-
 src/pcm/atomic.c        |  43 -----
 src/pcm/pcm.c           | 468 +++++++++++++++++++++++++++++++++++++++++-------
 src/pcm/pcm_direct.c    |   4 +-
 src/pcm/pcm_dmix.c      |  13 +-
 src/pcm/pcm_dshare.c    |  13 +-
 src/pcm/pcm_dsnoop.c    |  15 +-
 src/pcm/pcm_file.c      |  21 ++-
 src/pcm/pcm_generic.c   |  10 +-
 src/pcm/pcm_hw.c        |   3 +
 src/pcm/pcm_ioplug.c    |  11 +-
 src/pcm/pcm_local.h     |  62 ++++++-
 src/pcm/pcm_meter.c     |   1 -
 src/pcm/pcm_mmap.c      |  16 +-
 src/pcm/pcm_params.c    |   2 +-
 src/pcm/pcm_plugin.c    |  72 ++------
 src/pcm/pcm_plugin.h    |   2 -
 src/pcm/pcm_rate.c      |  41 ++---
 src/pcm/pcm_route.c     |   2 +-
 test/Makefile.am        |   3 +-
 test/pcm-multi-thread.c | 263 +++++++++++++++++++++++++++
 25 files changed, 851 insertions(+), 404 deletions(-)
 delete mode 100644 include/iatomic.h
 delete mode 100644 src/pcm/atomic.c
 create mode 100644 test/pcm-multi-thread.c

-- 
2.9.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-07-05 16:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 15:20 [PATCH RFC alsa-lib 0/5] Add thread-safety to PCM API Takashi Iwai
2016-07-05 15:20 ` [PATCH RFC alsa-lib 1/5] pcm: " Takashi Iwai
2016-07-05 16:30   ` Clemens Ladisch
2016-07-05 16:36     ` Takashi Iwai
2016-07-05 15:20 ` [PATCH RFC alsa-lib 2/5] test: Add pcm-multi-thread program Takashi Iwai
2016-07-05 15:20 ` [PATCH RFC alsa-lib 3/5] Add pcm-multi-thread to .gitignore Takashi Iwai
2016-07-05 15:20 ` [PATCH RFC alsa-lib 4/5] pcm: Remove superfluous rmb() from PCM meter plugin Takashi Iwai
2016-07-05 15:20 ` [PATCH RFC alsa-lib 5/5] pcm: Remove home brew atomic operations Takashi Iwai

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.