diff options
-rw-r--r-- | reserve-test.c | 1 | ||||
-rw-r--r-- | reserve.c | 16 | ||||
-rw-r--r-- | reserve.h | 4 | ||||
-rw-r--r-- | reserve.txt | 17 |
4 files changed, 12 insertions, 26 deletions
diff --git a/reserve-test.c b/reserve-test.c index d90f420..9e63a99 100644 --- a/reserve-test.c +++ b/reserve-test.c @@ -71,7 +71,6 @@ int main(int argc, char *argv[]) { "Audio0", "ReserveTest", priority, - 1, request_cb, &error)) < 0) { @@ -62,7 +62,6 @@ static const char introspection[] = " <interface name=\"org.freedesktop.ReserveDevice1\">" " <method name=\"RequestRelease\">" " <arg name=\"priority\" type=\"i\" direction=\"in\"/>" - " <arg name=\"show_ui\" type=\"b\" direction=\"in\"/>" " <arg name=\"result\" type=\"b\" direction=\"out\"/>" " </method>" " <property name=\"Priority\" type=\"i\" access=\"read\"/>" @@ -129,13 +128,12 @@ static DBusHandlerResult object_handler( "RequestRelease")) { int32_t priority; - dbus_bool_t show_ui, ret; + dbus_bool_t ret; if (!dbus_message_get_args( m, &error, DBUS_TYPE_INT32, &priority, - DBUS_TYPE_BOOLEAN, &show_ui, DBUS_TYPE_INVALID)) goto invalid; @@ -144,7 +142,7 @@ static DBusHandlerResult object_handler( if (priority > d->priority && d->request_cb) { d->ref++; - if (d->request_cb(d, 0, show_ui) > 0) { + if (d->request_cb(d, 0) > 0) { ret = TRUE; d->gave_up = 1; } @@ -329,7 +327,7 @@ static DBusHandlerResult filter_handler( d->ref++; if (d->request_cb) - d->request_cb(d, 1, 0); + d->request_cb(d, 1); d->gave_up = 1; rd_release(d); @@ -377,7 +375,6 @@ int rd_acquire( const char *device_name, const char *application_name, int32_t priority, - int _show_ui, rd_request_cb_t request_cb, DBusError *error) { @@ -385,15 +382,13 @@ int rd_acquire( int r, k; DBusError _error; DBusMessage *m = NULL, *reply = NULL; - dbus_bool_t good, show_ui; + dbus_bool_t good; if (!error) error = &_error; dbus_error_init(error); - show_ui = _show_ui; - if (!_d) return -EINVAL; @@ -472,7 +467,6 @@ int rd_acquire( if (!dbus_message_append_args( m, DBUS_TYPE_INT32, &d->priority, - DBUS_TYPE_BOOLEAN, &show_ui, DBUS_TYPE_INVALID)) { r = -ENOMEM; goto fail; @@ -481,7 +475,7 @@ int rd_acquire( if (!(reply = dbus_connection_send_with_reply_and_block( d->connection, m, - show_ui ? 60*1000 : -1, /* when UI is shown, wait for a minute */ + -1, error))) { r = -EIO; goto fail; @@ -37,8 +37,7 @@ typedef struct rd_device rd_device; * completely to make sure the new application may acceess it. */ typedef int (*rd_request_cb_t)( rd_device *d, - int forced, /* Non-zero if an application forcibly took the lock away without asking. If this is the case then the return value of this call is ignored. */ - int show_ui); /* Non-zero if your application may show a UI before unlocking the device. */ + int forced); /* Non-zero if an application forcibly took the lock away without asking. If this is the case then the return value of this call is ignored. */ /* Try to lock the device. Returns 0 on success, a negative errno * style return value on error. The DBus error might be set as well if @@ -49,7 +48,6 @@ int rd_acquire( const char *device_name, /* The device to lock, e.g. "Audio0" */ const char *application_name, /* A human readable name of the application, e.g. "PulseAudio Sound Server" */ int32_t priority, /* The priority for this application. If unsure use 0 */ - int show_ui, /* Is it OK if the application that currently owns the device queries the user about this in the UI before allowing/denying the request? */ rd_request_cb_t request_cb, /* Will be called whenever someone asks that this device shall be released. May be NULL if priority is INT32_MAX */ DBusError *error); /* If we fail due to a D-Bus related issue the error will be filled in here. May be NULL. */ diff --git a/reserve.txt b/reserve.txt index d25989c..0006a6a 100644 --- a/reserve.txt +++ b/reserve.txt @@ -37,7 +37,7 @@ INTERFACE DEFINITION org.freedesktop.ReserviceDevice1 Methods: - BOOL RequestRelease(INT32 priority, BOOL show_ui) (mandatory) + BOOL RequestRelease(INT32 priority) (mandatory) Ask the current owner of the device to release the device for take-over. The application @@ -51,16 +51,12 @@ INTERFACE DEFINITION the service should return FALSE and do nothing further. - If show_ui is TRUE the current owner may - release the device after some form of user - interaction. If show_ui is FALSE the current - owner must reply quickly and without user - interaction. - The current owner doesn't need to base its decision whether to return TRUE or FALSE solely on the value of priority. It may take - other facts into consideration. + other facts into consideration. However this + function is supposed to return quickly, + i.e. no user interaction shall be involved. Properties: INT32 Priority (optional) @@ -130,10 +126,9 @@ LOGIC further access to the device. An application shall watch for - org.freedesktop.DBus.NameOwnerChanged signals and give up + org.freedesktop.DBus.LostName signals and give up device access in case its service name is forcibly taken - away. This signal may also be used to monitor which - application currently owns the audio device. + away. While an application holds the service name it may exclusively access the device. It doesn't need to always keep it open |