[RFC] core: New hook: PA_CORE_HOOK_SINK_INPUT_PUT_PRE.

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

 



Would the following patch (and a similar one for source
outputs) be accepted for 1.1 or 2.0 even if there were no
(in-tree) users for the new hooks?

I'm writing code to Harmattan's policy module that would set
the PA_SINK_INPUT_START_CORKED flag for phone streams if
they appear before the routing and mixer settings are ready
for the call. I can't use (at least conveniently) the
existing hooks, because _NEW and _FIXATE are fired before
the pa_sink_input object is created, so I don't have the
pointer or index available to be stored for the time when
the streams need to be uncorked. The _PUT hook is fired too
late.

---
 src/pulsecore/core.h       |    5 +++++
 src/pulsecore/sink-input.c |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 61c8690..78f6ce1 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -84,6 +84,11 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SOURCE_PORT_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_NEW,
     PA_CORE_HOOK_SINK_INPUT_FIXATE,
+
+    /* Fired from pa_sink_input_put() before doing anything else.
+     * Call data: pointer to the pa_sink_input object. */
+    PA_CORE_HOOK_SINK_INPUT_PUT_PRE,
+
     PA_CORE_HOOK_SINK_INPUT_PUT,
     PA_CORE_HOOK_SINK_INPUT_UNLINK,
     PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d386b00..ec1b68d 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -693,6 +693,8 @@ void pa_sink_input_put(pa_sink_input *i) {
     pa_assert(i->process_rewind);
     pa_assert(i->kill);
 
+    pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT_PRE], i);
+
     state = i->flags & PA_SINK_INPUT_START_CORKED ? PA_SINK_INPUT_CORKED : PA_SINK_INPUT_RUNNING;
 
     update_n_corked(i, state);
-- 
1.7.6



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

  Powered by Linux