mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
module-switch-*: use pa_module_hook_connect
Refactoring, no functional change. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
10d9d8af5f
commit
37a7834737
2 changed files with 10 additions and 46 deletions
|
|
@ -49,9 +49,6 @@ static const char* const valid_modargs[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct userdata {
|
struct userdata {
|
||||||
pa_hook_slot
|
|
||||||
*sink_put_slot,
|
|
||||||
*source_put_slot;
|
|
||||||
bool only_from_unavailable;
|
bool only_from_unavailable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -183,8 +180,8 @@ int pa__init(pa_module*m) {
|
||||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||||
|
|
||||||
/* A little bit later than module-rescue-streams... */
|
/* A little bit later than module-rescue-streams... */
|
||||||
u->sink_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE+30, (pa_hook_cb_t) sink_put_hook_callback, u);
|
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE+30, (pa_hook_cb_t) sink_put_hook_callback, u);
|
||||||
u->source_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE+20, (pa_hook_cb_t) source_put_hook_callback, u);
|
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE+20, (pa_hook_cb_t) source_put_hook_callback, u);
|
||||||
|
|
||||||
if (pa_modargs_get_value_boolean(ma, "only_from_unavailable", &u->only_from_unavailable) < 0) {
|
if (pa_modargs_get_value_boolean(ma, "only_from_unavailable", &u->only_from_unavailable) < 0) {
|
||||||
pa_log("Failed to get a boolean value for only_from_unavailable.");
|
pa_log("Failed to get a boolean value for only_from_unavailable.");
|
||||||
|
|
@ -211,10 +208,5 @@ void pa__done(pa_module*m) {
|
||||||
if (!(u = m->userdata))
|
if (!(u = m->userdata))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (u->sink_put_slot)
|
|
||||||
pa_hook_slot_free(u->sink_put_slot);
|
|
||||||
if (u->source_put_slot)
|
|
||||||
pa_hook_slot_free(u->source_put_slot);
|
|
||||||
|
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,6 @@
|
||||||
|
|
||||||
#include "module-switch-on-port-available-symdef.h"
|
#include "module-switch-on-port-available-symdef.h"
|
||||||
|
|
||||||
struct userdata {
|
|
||||||
pa_hook_slot *available_slot;
|
|
||||||
pa_hook_slot *sink_new_slot;
|
|
||||||
pa_hook_slot *source_new_slot;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool profile_good_for_output(pa_card_profile *profile) {
|
static bool profile_good_for_output(pa_card_profile *profile) {
|
||||||
pa_sink *sink;
|
pa_sink *sink;
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
|
|
@ -246,7 +240,7 @@ static pa_device_port *new_sink_source(pa_hashmap *ports, const char *name) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new_data, struct userdata *u) {
|
static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new_data, void *u) {
|
||||||
|
|
||||||
pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
|
pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
|
||||||
|
|
||||||
|
|
@ -257,7 +251,7 @@ static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new
|
||||||
return PA_HOOK_OK;
|
return PA_HOOK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data *new_data, struct userdata *u) {
|
static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data *new_data, void *u) {
|
||||||
|
|
||||||
pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
|
pa_device_port *p = new_sink_source(new_data->ports, new_data->active_port);
|
||||||
|
|
||||||
|
|
@ -269,39 +263,17 @@ static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa__init(pa_module*m) {
|
int pa__init(pa_module*m) {
|
||||||
struct userdata *u;
|
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
m->userdata = u = pa_xnew(struct userdata, 1);
|
|
||||||
|
|
||||||
/* Make sure we are after module-device-restore, so we can overwrite that suggestion if necessary */
|
/* Make sure we are after module-device-restore, so we can overwrite that suggestion if necessary */
|
||||||
u->sink_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_NEW],
|
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_NEW],
|
||||||
PA_HOOK_NORMAL, (pa_hook_cb_t) sink_new_hook_callback, u);
|
PA_HOOK_NORMAL, (pa_hook_cb_t) sink_new_hook_callback, NULL);
|
||||||
u->source_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_NEW],
|
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_NEW],
|
||||||
PA_HOOK_NORMAL, (pa_hook_cb_t) source_new_hook_callback, u);
|
PA_HOOK_NORMAL, (pa_hook_cb_t) source_new_hook_callback, NULL);
|
||||||
u->available_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
|
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
|
||||||
PA_HOOK_LATE, (pa_hook_cb_t) port_available_hook_callback, u);
|
PA_HOOK_LATE, (pa_hook_cb_t) port_available_hook_callback, NULL);
|
||||||
|
|
||||||
handle_all_unavailable(m->core);
|
handle_all_unavailable(m->core);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa__done(pa_module*m) {
|
|
||||||
struct userdata *u;
|
|
||||||
|
|
||||||
pa_assert(m);
|
|
||||||
|
|
||||||
if (!(u = m->userdata))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (u->available_slot)
|
|
||||||
pa_hook_slot_free(u->available_slot);
|
|
||||||
if (u->sink_new_slot)
|
|
||||||
pa_hook_slot_free(u->sink_new_slot);
|
|
||||||
if (u->source_new_slot)
|
|
||||||
pa_hook_slot_free(u->source_new_slot);
|
|
||||||
|
|
||||||
pa_xfree(u);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue