RFC: Adding hooks for port+profile changes (possibly UCM related)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

A while ago a user needed to get notification (in a module) when a sink
port changed.. I recommended he added a simple patch for this to add a
new hook which he implemented. I'm only now getting around to merging
(sorry kt)

I extended this a little to add a similar hook when the card profile
changed. I've pasted both below for review (they are simple).

I guess this could be used in UCM such that a ucm module could listen
for changes to ports then push the verb to ALSA as appropriate... Just
double checking that this is sensible before I push it but I think it
makes sense to have this :)



commit 9379d4015c48ed15a9f5bde8dac085dbca08bea3
Author: Kim Therkelsen <kim_t26 at hotmail.com>
Date:   Fri Oct 15 09:25:12 2010 +0200

    core: Added new hooks: PA_CORE_HOOK_SOURCE_PORT_CHANGED and
PA_CORE_HOOK_SINK_PORT_CHANGED

    This allows modules to know when certain ports are changed.
    This will allow e.g. a filter module (or LADSAP) to only load
    when a certain port is used on the device (e.g. to only filter
    headphones and not normal speakers).

    (Comment from Colin Guthrie: This may also have use in UCM)

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index a1215bb..daa89c1 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -74,6 +74,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_UNLINK_POST,
     PA_CORE_HOOK_SINK_STATE_CHANGED,
     PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
+    PA_CORE_HOOK_SINK_PORT_CHANGED,
     PA_CORE_HOOK_SOURCE_NEW,
     PA_CORE_HOOK_SOURCE_FIXATE,
     PA_CORE_HOOK_SOURCE_PUT,
@@ -81,6 +82,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SOURCE_UNLINK_POST,
     PA_CORE_HOOK_SOURCE_STATE_CHANGED,
     PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
+    PA_CORE_HOOK_SOURCE_PORT_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_NEW,
     PA_CORE_HOOK_SINK_INPUT_FIXATE,
     PA_CORE_HOOK_SINK_INPUT_PUT,
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 0de544c..773123d 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2700,6 +2700,8 @@ int pa_sink_set_port(pa_sink *s, const char *name,
pa_bool_t save) {
     s->active_port = port;
     s->save_port = save;

+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PORT_CHANGED], s);
+
     return 0;
 }

diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 24d0ff6..a553662 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1571,5 +1571,7 @@ int pa_source_set_port(pa_source *s, const char
*name, pa_bool_t save) {
     s->active_port = port;
     s->save_port = save;

+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PORT_CHANGED], s);
+
     return 0;
 }





commit 9e2aec6a66dde80f63171a2ad15ac74d34678560
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Fri Feb 25 10:27:23 2011 +0000

    core: Add a new hook PA_CORE_HOOK_CARD_PROFILE_CHANGED

    This will allow modules to know when a card profile has changed
    and take appropriate action. This might prove useful when developing
    UCM so that the appropriate verb can be set.

diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 2f0a3af..1758f48 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -214,6 +214,7 @@ int pa_card_set_profile(pa_card *c, const char
*name, pa_bool_t save) {
     pa_card_profile *profile;
     int r;
     pa_assert(c);
+    pa_assert(c->core);

     if (!c->set_profile) {
         pa_log_debug("set_profile() operation not implemented for card
%u \"%s\"", c->index, c->name);
@@ -241,6 +242,8 @@ int pa_card_set_profile(pa_card *c, const char
*name, pa_bool_t save) {
     c->active_profile = profile;
     c->save_profile = save;

+    pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
+
     return 0;
 }

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index daa89c1..358b98d 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -113,6 +113,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_CARD_NEW,
     PA_CORE_HOOK_CARD_PUT,
     PA_CORE_HOOK_CARD_UNLINK,
+    PA_CORE_HOOK_CARD_PROFILE_CHANGED,
     PA_CORE_HOOK_MAX
 } pa_core_hook_t;


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux