diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-03-20 19:30:37 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-03-20 19:30:37 +0100 |
commit | f5c8990d1868f30ed3c13945f7bedb83e2093c11 (patch) | |
tree | 10c669f43db18f1754f6085ede25cb03235403b3 /src | |
parent | 77a1db16b996e079cd565f7d0baf9fe81ca88ccd (diff) |
make sure we dispatch messages in order
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/bluetooth/bluetooth-util.c | 17 | ||||
-rw-r--r-- | src/modules/dbus-util.c | 16 | ||||
-rw-r--r-- | src/modules/dbus-util.h | 3 |
3 files changed, 20 insertions, 16 deletions
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c index ccc8bee3..369b08a8 100644 --- a/src/modules/bluetooth/bluetooth-util.c +++ b/src/modules/bluetooth/bluetooth-util.c @@ -114,18 +114,18 @@ void pa_bluetooth_device_free(pa_bluetooth_device *d) { static pa_bool_t device_is_loaded(pa_bluetooth_device *d) { pa_assert(d); - /* FIXME: e83621724d7939b97b4f01f0d7e965d61ef8e55e, f1daa282f030e4e2381341e0f65faca47c4b891b is borked, probably needs to be reversed */ - - return d->device_info_valid && (d->audio_sink_info_valid || d->headset_info_valid); + return + d->device_info_valid && + d->audio_sink_info_valid && + d->headset_info_valid; } static pa_bool_t device_is_audio(pa_bluetooth_device *d) { pa_assert(d); pa_assert(d->device_info_valid); - pa_assert(d->audio_sink_info_valid || d->headset_info_valid); - - /* FIXME: e83621724d7939b97b4f01f0d7e965d61ef8e55e, f1daa282f030e4e2381341e0f65faca47c4b891b is borked, probably needs to be reversed */ + pa_assert(d->audio_sink_info_valid); + pa_assert(d->headset_info_valid); return d->device_info_valid > 0 && (d->audio_sink_info_valid > 0 || d->headset_info_valid > 0); @@ -303,7 +303,6 @@ static void run_callback(pa_bluetooth_discovery *y, pa_bluetooth_device *d, pa_b return; y->callback(y->userdata, d, good); - } static void get_properties_reply(DBusPendingCall *pending, void *userdata) { @@ -395,7 +394,7 @@ static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, pa_bl pa_assert_se(dbus_connection_send_with_reply(y->connection, m, &call, -1)); - p = pa_dbus_pending_new(m, call, y, d); + p = pa_dbus_pending_new(y->connection, m, call, y, d); PA_LLIST_PREPEND(pa_dbus_pending, y->pending, p); dbus_pending_call_set_notify(call, func, p, NULL); @@ -656,12 +655,10 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us } else if (dbus_message_has_interface(m, "org.bluez.Headset")) { if (parse_audio_property(y, &d->headset_connected, &arg_i) < 0) goto fail; - d->headset_info_valid = 1; } else if (dbus_message_has_interface(m, "org.bluez.AudioSink")) { if (parse_audio_property(y, &d->audio_sink_connected, &arg_i) < 0) goto fail; - d->audio_sink_info_valid = 1; } pa_assert_se(y->mode == MODE_DISCOVER); diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c index d51befb9..e2d45803 100644 --- a/src/modules/dbus-util.c +++ b/src/modules/dbus-util.c @@ -383,12 +383,19 @@ void pa_dbus_remove_matches(DBusConnection *c, ...) { va_end(ap); } -pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data) { +pa_dbus_pending *pa_dbus_pending_new( + DBusConnection *c, + DBusMessage *m, + DBusPendingCall *pending, + void *context_data, + void *call_data) { + pa_dbus_pending *p; pa_assert(pending); p = pa_xnew(pa_dbus_pending, 1); + p->connection = c; p->message = m; p->pending = pending; p->context_data = context_data; @@ -402,9 +409,8 @@ pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, v void pa_dbus_pending_free(pa_dbus_pending *p) { pa_assert(p); - if (p->pending) { + if (p->pending) dbus_pending_call_cancel(p->pending); /* p->pending is freed by cancel() */ - } if (p->message) dbus_message_unref(p->message); @@ -415,8 +421,8 @@ void pa_dbus_pending_free(pa_dbus_pending *p) { void pa_dbus_sync_pending_list(pa_dbus_pending **p) { pa_assert(p); - while (*p) - dbus_pending_call_block((*p)->pending); + while (*p && dbus_connection_read_write_dispatch((*p)->connection, -1)) + ; } void pa_dbus_free_pending_list(pa_dbus_pending **p) { diff --git a/src/modules/dbus-util.h b/src/modules/dbus-util.h index 90abbc7b..554f41a4 100644 --- a/src/modules/dbus-util.h +++ b/src/modules/dbus-util.h @@ -46,6 +46,7 @@ typedef struct pa_dbus_pending pa_dbus_pending; struct userdata; /* We leave the actual definition to the caller */ struct pa_dbus_pending { + DBusConnection *connection; DBusMessage *message; DBusPendingCall *pending; @@ -55,7 +56,7 @@ struct pa_dbus_pending { PA_LLIST_FIELDS(pa_dbus_pending); }; -pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data); +pa_dbus_pending *pa_dbus_pending_new(DBusConnection *c, DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data); void pa_dbus_pending_free(pa_dbus_pending *p); /* Sync up a list of pa_dbus_pending_call objects */ |