On Mon, Aug 08, 2011 at 03:38:48PM +0800, Colin Guthrie wrote:
> 'Twas brillig, and Lu Guanqun at 08/08/11 08:55 did gyre and gimble:
> > On Sat, Aug 06, 2011 at 07:10:16PM +0800, Colin Guthrie wrote:
> >> 'Twas brillig, and Pierre-Louis Bossart at 05/08/11 16:24 did gyre and
> >> gimble:
> >>>> there're multiple pthreads in pulseuadio, which makes reading a bit
> >>>> confuse.
> >>>> this patch can print each pthread's id.
> >>>
> >>> Wouldn't it be easier to understand if the thread name was used? We
> >>> typically rely on thread names to understand what goes on with
> >>> ftrace/pytimechart, I would think this is similar here. I would rather
> >>> see a
> >>> log with "alsa-sink" rather than "PID 6779", it'd also make log comparison
> >>> and analysis easier.
> >>
> >> Yup I agree (in an ideal world we'd name the thread by sink index too...
> >> (i.e. "alsa-sink 0")
> >
> > Hi Col,
> >
> > Do you think it's better to invoke pa_thread_new("alsa-sink 0", func, u)
> > or adding another index after the plain name? (e.g.
> > pa_thread_new("alsa-sink", index, func, u))
>
> I've not looked at the code, but if we know the sink index by this stage
> (I'm not sure we do?) then yes that could be helpful.
Not for now. at pa__init() stage, we don't know the module's index,
however, it can be supported via attached patch.
>
> Pierre will probably know if this is practically useful tho'. I suppose
> in most cases testing and probing will be done with only one sink anyway
> so there is no doubt which one owns the thread :p
I'm justing looking around on this mailing list and would like to get my
hands dirty. :D So either way is OK for me.
--
guanqun
>From 524829788c5b5a9aa34986fbee163326f6f09267 Mon Sep 17 00:00:00 2001
From: Lu Guanqun <[email protected]>
Date: Mon, 8 Aug 2011 10:22:50 +0800
Subject: [PATCH] module: shuffle the sequence of acquiring the module index
With this change, we can get the module index in pa__init() function of a
module.
Signed-off-by: Lu Guanqun <[email protected]>
---
src/pulsecore/module.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index 8b3ff8f..73f1208 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -64,6 +64,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const
char *argument) {
m->argument = pa_xstrdup(argument);
m->load_once = FALSE;
m->proplist = pa_proplist_new();
+ m->index = PA_IDXSET_INVALID;
if (!(m->dl = lt_dlopenext(name))) {
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
@@ -106,14 +107,14 @@ pa_module* pa_module_load(pa_core *c, const char *name,
const char *argument) {
m->core = c;
m->unload_requested = FALSE;
+ pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
+ pa_assert(m->index != PA_IDXSET_INVALID);
+
if (m->init(m) < 0) {
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"):
initialization failed.", name, argument ? argument : "");
goto fail;
}
- pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
- pa_assert(m->index != PA_IDXSET_INVALID);
-
pa_log_info("Loaded \"%s\" (index: #%u; argument: \"%s\").", m->name,
m->index, m->argument ? m->argument : "");
pa_subscription_post(c,
PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
@@ -137,6 +138,9 @@ pa_module* pa_module_load(pa_core *c, const char *name,
const char *argument) {
fail:
if (m) {
+ if (m->index != PA_IDXSET_INVALID)
+ pa_idxset_remove_by_index(c->modules, m->index);
+
if (m->proplist)
pa_proplist_free(m->proplist);
--
1.7.6
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss