Commit 5323ee14 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

dbus-device-reservation: emit forced 'release' signal when name is lost and pending task is NULL

parent d11c67fe
......@@ -160,13 +160,18 @@ on_name_lost (GDBusConnection *connection, const gchar *name,
/* Unregister object */
wp_dbus_device_reservation_unregister_object (self);
/* Trigger the acquired task */
/* If pending task is set, it means that we could not acquire the device, so
* just return the pending task with an error. If pending task is not set, it
* means that another audio server acquired the device with replacement, so we
* trigger the release signal with forced set to TRUE */
if (self->pending_task) {
GError *error = g_error_new (WP_DOMAIN_LIBRARY,
"dbus name lost before acquiring (connection=%p)", connection);
g_task_return_error (self->pending_task, error);
g_clear_object (&self->pending_task);
} else {
g_signal_emit (self, device_reservation_signals[SIGNAL_RELEASE], 0, TRUE);
......@@ -34,8 +34,9 @@ static void
on_device_done (WpCore *core, GAsyncResult *res, WpReserveDevice *self)
if (self->reservation)
wp_dbus_device_reservation_complete_release (self->reservation,
wp_dbus_device_reservation_complete_release (self->reservation, TRUE);
wp_warning_object (self, "release not completed");
static void
......@@ -89,7 +90,8 @@ on_reservation_release (WpDbusDeviceReservation *reservation, gboolean forced,
wp_proxy_set_param (device, "Profile", profile);
/* Complete release on done */
/* Only complete the release if not forced */
if (!forced)
wp_core_sync (core, NULL, (GAsyncReadyCallback)on_device_done, self);
......@@ -40,6 +40,7 @@ on_reservation_release (WpDbusDeviceReservation *reservation,
gboolean forced, TestDbusFixture *self)
wp_dbus_device_reservation_release (reservation);
if (!forced)
wp_dbus_device_reservation_complete_release (reservation, TRUE);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment