summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-06-18 21:27:02 +0200
committerLennart Poettering <lennart@poettering.net>2009-06-18 21:27:02 +0200
commit348dcd6a31280217cad787f9ee75e607c0f1bf6c (patch)
tree94eeebf749e7ae149de5981e2016b09ba3bb3c06
parent25e5197f6adb6a371631237a53de15eb4dc1a776 (diff)
alsa: unify alsa log handling and snd_config_update_free_global() handling in one place
-rw-r--r--src/modules/alsa/alsa-sink.c1
-rw-r--r--src/modules/alsa/alsa-source.c2
-rw-r--r--src/modules/alsa/alsa-util.c8
-rw-r--r--src/modules/alsa/alsa-util.h4
-rw-r--r--src/modules/alsa/module-alsa-card.c6
-rw-r--r--src/modules/alsa/module-alsa-sink.c6
-rw-r--r--src/modules/alsa/module-alsa-source.c6
7 files changed, 13 insertions, 20 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 34ff65829..281371f74 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -838,7 +838,6 @@ static int unsuspend(struct userdata *u) {
pa_log_info("Trying resume...");
- snd_config_update_free_global();
if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_PLAYBACK,
/*SND_PCM_NONBLOCK|*/
SND_PCM_NO_AUTO_RESAMPLE|
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index c8244c662..4be27eb0c 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -787,8 +787,6 @@ static int unsuspend(struct userdata *u) {
pa_log_info("Trying resume...");
- snd_config_update_free_global();
-
if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_CAPTURE,
/*SND_PCM_NONBLOCK|*/
SND_PCM_NO_AUTO_RESAMPLE|
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 0ed4361c5..1f3e5dcd8 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -735,20 +735,22 @@ static void alsa_error_handler(const char *file, int line, const char *function,
static pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0);
-void pa_alsa_redirect_errors_inc(void) {
+void pa_alsa_refcnt_inc(void) {
/* This is not really thread safe, but we do our best */
if (pa_atomic_inc(&n_error_handler_installed) == 0)
snd_lib_error_set_handler(alsa_error_handler);
}
-void pa_alsa_redirect_errors_dec(void) {
+void pa_alsa_refcnt_dec(void) {
int r;
pa_assert_se((r = pa_atomic_dec(&n_error_handler_installed)) >= 1);
- if (r == 1)
+ if (r == 1) {
snd_lib_error_set_handler(NULL);
+ snd_config_update_free_global();
+ }
}
pa_bool_t pa_alsa_init_description(pa_proplist *p) {
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index c2f0e5b74..830a922ec 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -114,8 +114,8 @@ snd_pcm_t *pa_alsa_open_by_template(
void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
void pa_alsa_dump_status(snd_pcm_t *pcm);
-void pa_alsa_redirect_errors_inc(void);
-void pa_alsa_redirect_errors_dec(void);
+void pa_alsa_refcnt_inc(void);
+void pa_alsa_refcnt_dec(void);
void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index e8a7f206f..55f6a6e25 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -287,8 +287,7 @@ int pa__init(pa_module *m) {
const char *description;
char *fn = NULL;
- pa_alsa_redirect_errors_inc();
- snd_config_update_free_global();
+ pa_alsa_refcnt_inc();
pa_assert(m);
@@ -443,6 +442,5 @@ void pa__done(pa_module*m) {
pa_xfree(u);
finish:
- snd_config_update_free_global();
- pa_alsa_redirect_errors_dec();
+ pa_alsa_refcnt_dec();
}
diff --git a/src/modules/alsa/module-alsa-sink.c b/src/modules/alsa/module-alsa-sink.c
index 058ea205c..3aa89b2aa 100644
--- a/src/modules/alsa/module-alsa-sink.c
+++ b/src/modules/alsa/module-alsa-sink.c
@@ -82,8 +82,7 @@ int pa__init(pa_module*m) {
pa_assert(m);
- pa_alsa_redirect_errors_inc();
- snd_config_update_free_global();
+ pa_alsa_refcnt_inc();
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
@@ -124,6 +123,5 @@ void pa__done(pa_module*m) {
if ((sink = m->userdata))
pa_alsa_sink_free(sink);
- snd_config_update_free_global();
- pa_alsa_redirect_errors_dec();
+ pa_alsa_refcnt_dec();
}
diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c
index 3bd1b4512..de8bcd0b2 100644
--- a/src/modules/alsa/module-alsa-source.c
+++ b/src/modules/alsa/module-alsa-source.c
@@ -106,8 +106,7 @@ int pa__init(pa_module*m) {
pa_assert(m);
- pa_alsa_redirect_errors_inc();
- snd_config_update_free_global();
+ pa_alsa_refcnt_inc();
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
@@ -148,6 +147,5 @@ void pa__done(pa_module*m) {
if ((source = m->userdata))
pa_alsa_source_free(source);
- snd_config_update_free_global();
- pa_alsa_redirect_errors_dec();
+ pa_alsa_refcnt_dec();
}