]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
pulse - Change to hook load_if_running
authorSjoerd Simons <sjoerd@luon.net>
Tue, 13 May 2008 12:16:06 +0000 (14:16 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 6 Jun 2008 13:55:03 +0000 (15:55 +0200)
Unfortunately some more testing revealed some issues with it,
specifically if pulse is running your complete config is replaced the bits in
the on_pulse_is_running directive. Which might not be what one actually wants :)

I couldn't find a proper solution for this. So i've changed the code to
optionally load config files. Just like the load hook does. Actually i just
optionally call the snd_config_hook_load function, but that's not actually in
the alsa API....

Also it now decides pulse is running as soon as the authorizing step begins
(just after the actually connection is setup), which should save some
round-trips and overhead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
pulse/conf_pulse.c

index 78cf042e3a64db5e684365454d6b475bcc4580a2..6627b317446122344494f1905e50d382727832e2 100644 (file)
 #include <pulse/pulseaudio.h>
 
 
+/* Not actually part of the alsa api....  */
+extern int
+snd_config_hook_load (snd_config_t *root, snd_config_t *config,
+  snd_config_t **dst, snd_config_t *private_data);
+
 int
-conf_pulse_hook_on_is_running (snd_config_t *root, snd_config_t *config,
+conf_pulse_hook_load_if_running (snd_config_t *root, snd_config_t *config,
     snd_config_t **dst, snd_config_t *private_data) {
-  snd_config_t *n = NULL;
   pa_mainloop *loop = NULL;
   pa_context *context = NULL;
   int ret = 0, err, state;
 
+  *dst = NULL;
 
   /* Defined if we're called inside the pulsedaemon itself */
   if (getenv("PULSE_INTERNAL") != NULL)
@@ -65,12 +70,12 @@ conf_pulse_hook_on_is_running (snd_config_t *root, snd_config_t *config,
       goto out;
 
     state = pa_context_get_state(context);
-  } while (state < PA_CONTEXT_READY);
+  } while (state < PA_CONTEXT_AUTHORIZING);
 
-  if (state != PA_CONTEXT_READY)
+  if (state > PA_CONTEXT_READY)
     goto out;
 
-  ret = snd_config_expand(config, root, NULL, private_data, &n);
+  ret = snd_config_hook_load(root, config, dst, private_data);
 
 out:
   if (context != NULL)
@@ -79,10 +84,8 @@ out:
   if (loop != NULL)
     pa_mainloop_free(loop);
 
-  *dst = n;
-
   return ret;
 }
 
-SND_DLSYM_BUILD_VERSION(conf_pulse_hook_on_is_running,
+SND_DLSYM_BUILD_VERSION(conf_pulse_hook_load_if_running,
   SND_CONFIG_DLSYM_VERSION_HOOK);