mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
module-*-restore: use pa_module_hook_connect
Refactoring, no functional change. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
127e8a1519
commit
619def0c73
3 changed files with 23 additions and 89 deletions
|
|
@ -60,15 +60,8 @@ static const char* const valid_modargs[] = {
|
|||
struct userdata {
|
||||
pa_core *core;
|
||||
pa_module *module;
|
||||
pa_hook_slot *card_new_hook_slot;
|
||||
pa_hook_slot *card_put_hook_slot;
|
||||
pa_hook_slot *card_profile_changed_hook_slot;
|
||||
pa_hook_slot *card_profile_added_hook_slot;
|
||||
pa_hook_slot *profile_available_changed_hook_slot;
|
||||
pa_hook_slot *port_offset_hook_slot;
|
||||
pa_time_event *save_time_event;
|
||||
pa_database *database;
|
||||
bool hooks_connected;
|
||||
};
|
||||
|
||||
#define ENTRY_VERSION 2
|
||||
|
|
@ -536,14 +529,13 @@ int pa__init(pa_module*m) {
|
|||
u->core = m->core;
|
||||
u->module = m;
|
||||
|
||||
u->card_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) card_new_hook_callback, u);
|
||||
u->card_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PUT], PA_HOOK_NORMAL, (pa_hook_cb_t) card_put_hook_callback, u);
|
||||
u->card_profile_changed_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_changed_callback, u);
|
||||
u->card_profile_added_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_added_callback, u);
|
||||
u->profile_available_changed_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED],
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_CARD_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) card_new_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_CARD_PUT], PA_HOOK_NORMAL, (pa_hook_cb_t) card_put_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_changed_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_added_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED],
|
||||
PA_HOOK_NORMAL, profile_available_changed_callback, u);
|
||||
u->port_offset_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) port_offset_change_callback, u);
|
||||
u->hooks_connected = true;
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) port_offset_change_callback, u);
|
||||
|
||||
if (!(fname = pa_state_path("card-database", true)))
|
||||
goto fail;
|
||||
|
|
@ -577,15 +569,6 @@ void pa__done(pa_module*m) {
|
|||
if (!(u = m->userdata))
|
||||
return;
|
||||
|
||||
if (u->hooks_connected) {
|
||||
pa_hook_slot_free(u->card_new_hook_slot);
|
||||
pa_hook_slot_free(u->card_put_hook_slot);
|
||||
pa_hook_slot_free(u->card_profile_changed_hook_slot);
|
||||
pa_hook_slot_free(u->card_profile_added_hook_slot);
|
||||
pa_hook_slot_free(u->profile_available_changed_hook_slot);
|
||||
pa_hook_slot_free(u->port_offset_hook_slot);
|
||||
}
|
||||
|
||||
if (u->save_time_event)
|
||||
u->core->mainloop->time_free(u->save_time_event);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,15 +78,6 @@ struct userdata {
|
|||
pa_core *core;
|
||||
pa_module *module;
|
||||
pa_subscription *subscription;
|
||||
pa_hook_slot
|
||||
*sink_new_hook_slot,
|
||||
*sink_fixate_hook_slot,
|
||||
*sink_port_hook_slot,
|
||||
*sink_put_hook_slot,
|
||||
*source_new_hook_slot,
|
||||
*source_fixate_hook_slot,
|
||||
*source_port_hook_slot,
|
||||
*connection_unlink_hook_slot;
|
||||
pa_time_event *save_time_event;
|
||||
pa_database *database;
|
||||
|
||||
|
|
@ -1243,25 +1234,25 @@ int pa__init(pa_module*m) {
|
|||
u->protocol = pa_native_protocol_get(m->core);
|
||||
pa_native_protocol_install_ext(u->protocol, m, extension_cb);
|
||||
|
||||
u->connection_unlink_hook_slot = pa_hook_connect(&pa_native_protocol_hooks(u->protocol)[PA_NATIVE_HOOK_CONNECTION_UNLINK], PA_HOOK_NORMAL, (pa_hook_cb_t) connection_unlink_hook_cb, u);
|
||||
pa_module_hook_connect(m, &pa_native_protocol_hooks(u->protocol)[PA_NATIVE_HOOK_CONNECTION_UNLINK], PA_HOOK_NORMAL, (pa_hook_cb_t) connection_unlink_hook_cb, u);
|
||||
|
||||
u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK|PA_SUBSCRIPTION_MASK_SOURCE, subscribe_callback, u);
|
||||
|
||||
if (restore_port) {
|
||||
u->sink_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) sink_new_hook_callback, u);
|
||||
u->source_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) source_new_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) sink_new_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) source_new_hook_callback, u);
|
||||
}
|
||||
|
||||
if (restore_muted || restore_volume) {
|
||||
u->sink_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_fixate_hook_callback, u);
|
||||
u->source_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) source_fixate_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_fixate_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) source_fixate_hook_callback, u);
|
||||
|
||||
u->sink_port_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PORT_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) sink_port_hook_callback, u);
|
||||
u->source_port_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PORT_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) source_port_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_PORT_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) sink_port_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_PORT_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) source_port_hook_callback, u);
|
||||
}
|
||||
|
||||
if (restore_formats)
|
||||
u->sink_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_EARLY, (pa_hook_cb_t) sink_put_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_EARLY, (pa_hook_cb_t) sink_put_hook_callback, u);
|
||||
|
||||
if (!(fname = pa_state_path("device-volumes", true)))
|
||||
goto fail;
|
||||
|
|
@ -1304,24 +1295,6 @@ void pa__done(pa_module*m) {
|
|||
if (u->subscription)
|
||||
pa_subscription_free(u->subscription);
|
||||
|
||||
if (u->sink_fixate_hook_slot)
|
||||
pa_hook_slot_free(u->sink_fixate_hook_slot);
|
||||
if (u->source_fixate_hook_slot)
|
||||
pa_hook_slot_free(u->source_fixate_hook_slot);
|
||||
if (u->sink_new_hook_slot)
|
||||
pa_hook_slot_free(u->sink_new_hook_slot);
|
||||
if (u->source_new_hook_slot)
|
||||
pa_hook_slot_free(u->source_new_hook_slot);
|
||||
if (u->sink_port_hook_slot)
|
||||
pa_hook_slot_free(u->sink_port_hook_slot);
|
||||
if (u->source_port_hook_slot)
|
||||
pa_hook_slot_free(u->source_port_hook_slot);
|
||||
if (u->sink_put_hook_slot)
|
||||
pa_hook_slot_free(u->sink_put_hook_slot);
|
||||
|
||||
if (u->connection_unlink_hook_slot)
|
||||
pa_hook_slot_free(u->connection_unlink_hook_slot);
|
||||
|
||||
if (u->save_time_event) {
|
||||
u->core->mainloop->time_free(u->save_time_event);
|
||||
pa_database_sync(u->database);
|
||||
|
|
|
|||
|
|
@ -2397,31 +2397,31 @@ int pa__init(pa_module*m) {
|
|||
u->protocol = pa_native_protocol_get(m->core);
|
||||
pa_native_protocol_install_ext(u->protocol, m, extension_cb);
|
||||
|
||||
u->connection_unlink_hook_slot = pa_hook_connect(&pa_native_protocol_hooks(u->protocol)[PA_NATIVE_HOOK_CONNECTION_UNLINK], PA_HOOK_NORMAL, (pa_hook_cb_t) connection_unlink_hook_cb, u);
|
||||
pa_module_hook_connect(m, &pa_native_protocol_hooks(u->protocol)[PA_NATIVE_HOOK_CONNECTION_UNLINK], PA_HOOK_NORMAL, (pa_hook_cb_t) connection_unlink_hook_cb, u);
|
||||
|
||||
u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, subscribe_callback, u);
|
||||
|
||||
if (restore_device) {
|
||||
/* A little bit earlier than module-intended-roles ... */
|
||||
u->sink_input_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_new_hook_callback, u);
|
||||
u->source_output_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_new_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_new_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_new_hook_callback, u);
|
||||
}
|
||||
|
||||
if (restore_device && on_hotplug) {
|
||||
/* A little bit earlier than module-intended-roles ... */
|
||||
u->sink_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_put_hook_callback, u);
|
||||
u->source_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_put_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_put_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_put_hook_callback, u);
|
||||
}
|
||||
|
||||
if (restore_device && on_rescue) {
|
||||
/* A little bit earlier than module-intended-roles, module-rescue-streams, ... */
|
||||
u->sink_unlink_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_unlink_hook_callback, u);
|
||||
u->source_unlink_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) source_unlink_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_unlink_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) source_unlink_hook_callback, u);
|
||||
}
|
||||
|
||||
if (restore_volume || restore_muted) {
|
||||
u->sink_input_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_fixate_hook_callback, u);
|
||||
u->source_output_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_fixate_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_fixate_hook_callback, u);
|
||||
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_fixate_hook_callback, u);
|
||||
}
|
||||
|
||||
if (!(fname = pa_state_path("stream-volumes", true)))
|
||||
|
|
@ -2508,28 +2508,6 @@ void pa__done(pa_module*m) {
|
|||
if (u->subscription)
|
||||
pa_subscription_free(u->subscription);
|
||||
|
||||
if (u->sink_input_new_hook_slot)
|
||||
pa_hook_slot_free(u->sink_input_new_hook_slot);
|
||||
if (u->sink_input_fixate_hook_slot)
|
||||
pa_hook_slot_free(u->sink_input_fixate_hook_slot);
|
||||
if (u->source_output_new_hook_slot)
|
||||
pa_hook_slot_free(u->source_output_new_hook_slot);
|
||||
if (u->source_output_fixate_hook_slot)
|
||||
pa_hook_slot_free(u->source_output_fixate_hook_slot);
|
||||
|
||||
if (u->sink_put_hook_slot)
|
||||
pa_hook_slot_free(u->sink_put_hook_slot);
|
||||
if (u->source_put_hook_slot)
|
||||
pa_hook_slot_free(u->source_put_hook_slot);
|
||||
|
||||
if (u->sink_unlink_hook_slot)
|
||||
pa_hook_slot_free(u->sink_unlink_hook_slot);
|
||||
if (u->source_unlink_hook_slot)
|
||||
pa_hook_slot_free(u->source_unlink_hook_slot);
|
||||
|
||||
if (u->connection_unlink_hook_slot)
|
||||
pa_hook_slot_free(u->connection_unlink_hook_slot);
|
||||
|
||||
if (u->save_time_event)
|
||||
u->core->mainloop->time_free(u->save_time_event);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue