[pulseaudio-discuss] [PATCH 5/6] module-filter-*: use pa_module_hook_connect
David Henningsson
david.henningsson at canonical.com
Fri Mar 27 03:20:15 PDT 2015
Refactoring, no functional change.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/modules/module-filter-apply.c | 52 +++++++---------------------------
src/modules/module-filter-heuristics.c | 22 +++-----------
2 files changed, 14 insertions(+), 60 deletions(-)
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index c7c7367..5a927a3 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -65,17 +65,6 @@ struct filter {
struct userdata {
pa_core *core;
pa_hashmap *filters;
- pa_hook_slot
- *sink_input_put_slot,
- *sink_input_move_finish_slot,
- *sink_input_proplist_slot,
- *sink_input_unlink_slot,
- *sink_unlink_slot,
- *source_output_put_slot,
- *source_output_move_finish_slot,
- *source_output_proplist_slot,
- *source_output_unlink_slot,
- *source_unlink_slot;
bool autoclean;
pa_time_event *housekeeping_time_event;
};
@@ -681,16 +670,16 @@ int pa__init(pa_module *m) {
u->filters = pa_hashmap_new(filter_hash, filter_compare);
- u->sink_input_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
- u->sink_input_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_move_finish_cb, u);
- u->sink_input_proplist_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_proplist_cb, u);
- u->sink_input_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_unlink_cb, u);
- u->sink_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_unlink_cb, u);
- u->source_output_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_output_put_cb, u);
- u->source_output_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH], PA_HOOK_LATE, (pa_hook_cb_t) source_output_move_finish_cb, u);
- u->source_output_proplist_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) source_output_proplist_cb, u);
- u->source_output_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) source_output_unlink_cb, u);
- u->source_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE-1, (pa_hook_cb_t) source_unlink_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_move_finish_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_proplist_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_unlink_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_unlink_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_output_put_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH], PA_HOOK_LATE, (pa_hook_cb_t) source_output_move_finish_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) source_output_proplist_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) source_output_unlink_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE-1, (pa_hook_cb_t) source_unlink_cb, u);
pa_modargs_free(ma);
@@ -713,27 +702,6 @@ void pa__done(pa_module *m) {
if (!(u = m->userdata))
return;
- if (u->sink_input_put_slot)
- pa_hook_slot_free(u->sink_input_put_slot);
- if (u->sink_input_move_finish_slot)
- pa_hook_slot_free(u->sink_input_move_finish_slot);
- if (u->sink_input_proplist_slot)
- pa_hook_slot_free(u->sink_input_proplist_slot);
- if (u->sink_input_unlink_slot)
- pa_hook_slot_free(u->sink_input_unlink_slot);
- if (u->sink_unlink_slot)
- pa_hook_slot_free(u->sink_unlink_slot);
- if (u->source_output_put_slot)
- pa_hook_slot_free(u->source_output_put_slot);
- if (u->source_output_move_finish_slot)
- pa_hook_slot_free(u->source_output_move_finish_slot);
- if (u->source_output_proplist_slot)
- pa_hook_slot_free(u->source_output_proplist_slot);
- if (u->source_output_unlink_slot)
- pa_hook_slot_free(u->source_output_unlink_slot);
- if (u->source_unlink_slot)
- pa_hook_slot_free(u->source_unlink_slot);
-
if (u->housekeeping_time_event)
u->core->mainloop->time_free(u->housekeeping_time_event);
diff --git a/src/modules/module-filter-heuristics.c b/src/modules/module-filter-heuristics.c
index 1b1aae1..423e873 100644
--- a/src/modules/module-filter-heuristics.c
+++ b/src/modules/module-filter-heuristics.c
@@ -46,11 +46,6 @@ static const char* const valid_modargs[] = {
struct userdata {
pa_core *core;
- pa_hook_slot
- *sink_input_put_slot,
- *sink_input_move_finish_slot,
- *source_output_put_slot,
- *source_output_move_finish_slot;
};
static pa_hook_result_t process(struct userdata *u, pa_object *o, bool is_sink_input) {
@@ -147,10 +142,10 @@ int pa__init(pa_module *m) {
u->core = m->core;
- u->sink_input_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_input_put_cb, u);
- u->sink_input_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_input_move_finish_cb, u);
- u->source_output_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], PA_HOOK_LATE-1, (pa_hook_cb_t) source_output_put_cb, u);
- u->source_output_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH], PA_HOOK_LATE-1, (pa_hook_cb_t) source_output_move_finish_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_input_put_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_LATE-1, (pa_hook_cb_t) sink_input_move_finish_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], PA_HOOK_LATE-1, (pa_hook_cb_t) source_output_put_cb, u);
+ pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH], PA_HOOK_LATE-1, (pa_hook_cb_t) source_output_move_finish_cb, u);
pa_modargs_free(ma);
@@ -174,15 +169,6 @@ void pa__done(pa_module *m) {
if (!(u = m->userdata))
return;
- if (u->sink_input_put_slot)
- pa_hook_slot_free(u->sink_input_put_slot);
- if (u->sink_input_move_finish_slot)
- pa_hook_slot_free(u->sink_input_move_finish_slot);
- if (u->source_output_put_slot)
- pa_hook_slot_free(u->source_output_put_slot);
- if (u->source_output_move_finish_slot)
- pa_hook_slot_free(u->source_output_move_finish_slot);
-
pa_xfree(u);
}
--
1.9.1
More information about the pulseaudio-discuss
mailing list