Revert "pipewire-alsa: Make it MT safe"

This reverts commit f22dd9d781.

Obsolete now that pw_init and factory loading/unloading has been
made thread safe.
This commit is contained in:
Wim Taymans 2021-09-21 12:34:57 +02:00
parent d8aec1c7b4
commit 423e8b2f03

View file

@ -33,8 +33,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <pthread.h>
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <alsa/pcm_external.h> #include <alsa/pcm_external.h>
@ -56,8 +54,6 @@
#define MIN_PERIOD 64 #define MIN_PERIOD 64
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
typedef struct { typedef struct {
snd_pcm_ioplug_t io; snd_pcm_ioplug_t io;
@ -165,9 +161,7 @@ static int snd_pcm_pipewire_close(snd_pcm_ioplug_t *io)
{ {
snd_pcm_pipewire_t *pw = io->private_data; snd_pcm_pipewire_t *pw = io->private_data;
pw_log_debug(NAME" %p:", pw); pw_log_debug(NAME" %p:", pw);
pthread_mutex_lock(&lock);
snd_pcm_pipewire_free(pw); snd_pcm_pipewire_free(pw);
pthread_mutex_unlock(&lock);
return 0; return 0;
} }
@ -1120,6 +1114,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire)
uint32_t flags = 0; uint32_t flags = 0;
int err; int err;
pw_init(NULL, NULL);
if (strstr(pw_get_library_version(), "0.2") != NULL)
return -ENOTSUP;
snd_config_for_each(i, next, conf) { snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i); snd_config_t *n = snd_config_iterator_entry(i);
const char *id; const char *id;
@ -1195,17 +1193,9 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire)
return -EINVAL; return -EINVAL;
} }
pthread_mutex_lock(&lock);
pw_init(NULL, NULL);
if (strstr(pw_get_library_version(), "0.2") != NULL) {
pthread_mutex_unlock(&lock);
return -ENOTSUP;
}
err = snd_pcm_pipewire_open(pcmp, name, node_name, server_name, playback_node, err = snd_pcm_pipewire_open(pcmp, name, node_name, server_name, playback_node,
capture_node, role, stream, mode, flags, rate, format, capture_node, role, stream, mode, flags, rate, format,
channels, period_bytes); channels, period_bytes);
pthread_mutex_unlock(&lock);
return err; return err;
} }