mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
dbus: remove filter functions only if they were actually set before
This fixes an assert when destructing modules that have not been fully initialized. https://bugzilla.redhat.com/show_bug.cgi?id=548525
This commit is contained in:
parent
5e2a80c7e3
commit
66dbca1e06
7 changed files with 34 additions and 34 deletions
|
|
@ -37,6 +37,7 @@ struct pa_bluetooth_discovery {
|
|||
PA_LLIST_HEAD(pa_dbus_pending, pending);
|
||||
pa_hashmap *devices;
|
||||
pa_hook hook;
|
||||
pa_bool_t filter_added;
|
||||
};
|
||||
|
||||
static void get_properties_reply(DBusPendingCall *pending, void *userdata);
|
||||
|
|
@ -788,6 +789,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
|
|||
pa_log_error("Failed to add filter function");
|
||||
goto fail;
|
||||
}
|
||||
y->filter_added = TRUE;
|
||||
|
||||
if (pa_dbus_add_matches(
|
||||
pa_dbus_connection_get(y->connection), &err,
|
||||
|
|
@ -856,7 +858,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
|
|||
"type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
|
||||
"type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'", NULL);
|
||||
|
||||
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
|
||||
if (y->filter_added)
|
||||
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
|
||||
|
||||
pa_dbus_connection_unref(y->connection);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ struct userdata {
|
|||
|
||||
int stream_write_type;
|
||||
int service_write_type, service_read_type;
|
||||
|
||||
pa_bool_t filter_added;
|
||||
};
|
||||
|
||||
#define FIXED_LATENCY_PLAYBACK_A2DP (25*PA_USEC_PER_MSEC)
|
||||
|
|
@ -2405,6 +2407,7 @@ int pa__init(pa_module* m) {
|
|||
pa_log_error("Failed to add filter function");
|
||||
goto fail;
|
||||
}
|
||||
u->filter_added = TRUE;
|
||||
|
||||
speaker = pa_sprintf_malloc("type='signal',sender='org.bluez',interface='org.bluez.Headset',member='SpeakerGainChanged',path='%s'", u->path);
|
||||
mike = pa_sprintf_malloc("type='signal',sender='org.bluez',interface='org.bluez.Headset',member='MicrophoneGainChanged',path='%s'", u->path);
|
||||
|
|
@ -2494,7 +2497,9 @@ void pa__done(pa_module *m) {
|
|||
pa_xfree(mike);
|
||||
}
|
||||
|
||||
dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
|
||||
if (u->filter_added)
|
||||
dbus_connection_remove_filter(pa_dbus_connection_get(u->connection), filter_cb, u);
|
||||
|
||||
pa_dbus_connection_unref(u->connection);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ struct userdata {
|
|||
unsigned n_found;
|
||||
unsigned n_unknown;
|
||||
|
||||
pa_bool_t muted;
|
||||
pa_bool_t muted:1;
|
||||
pa_bool_t filter_added:1;
|
||||
};
|
||||
|
||||
static void update_volume(struct userdata *u) {
|
||||
|
|
@ -358,9 +359,10 @@ static int add_matches(struct userdata *u, pa_bool_t add) {
|
|||
} else
|
||||
dbus_bus_remove_match(pa_dbus_connection_get(u->dbus_connection), filter2, &e);
|
||||
|
||||
if (add)
|
||||
if (add) {
|
||||
pa_assert_se(dbus_connection_add_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u, NULL));
|
||||
else
|
||||
u->filter_added = TRUE;
|
||||
} else if (u->filter_added)
|
||||
dbus_connection_remove_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u);
|
||||
|
||||
r = 0;
|
||||
|
|
@ -393,9 +395,6 @@ int pa__init(pa_module*m) {
|
|||
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
|
||||
u->hci = pa_xstrdup(pa_modargs_get_value(ma, "hci", DEFAULT_HCI));
|
||||
u->hci_path = pa_sprintf_malloc("/org/bluez/%s", u->hci);
|
||||
u->n_found = u->n_unknown = 0;
|
||||
u->muted = FALSE;
|
||||
|
||||
u->bondings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
|
||||
if (!(u->dbus_connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &e))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue