[pulseaudio-commits] src/pulsecore

Lennart Poettering lennart at kemper.freedesktop.org
Tue May 15 07:08:46 PDT 2012


 src/pulsecore/rtkit.c |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/pulsecore/rtkit.h |   17 +++++++
 2 files changed, 136 insertions(+)

New commits:
commit c50cffc016413e4d6f35f5bb2f8b17f05b4516d0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue May 15 16:08:40 2012 +0200

    rtkit: update drop-in files

diff --git a/src/pulsecore/rtkit.c b/src/pulsecore/rtkit.c
index aecc4e3..a7dc3d9 100644
--- a/src/pulsecore/rtkit.c
+++ b/src/pulsecore/rtkit.c
@@ -2,6 +2,7 @@
 
 /***
   Copyright 2009 Lennart Poettering
+  Copyright 2010 David Henningsson <diwic at ubuntu.com>
 
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
@@ -56,6 +57,112 @@ static int translate_error(const char *name) {
         return -EIO;
 }
 
+static long long rtkit_get_int_property(DBusConnection *connection, const char* propname, long long* propval) {
+        DBusMessage *m = NULL, *r = NULL;
+        DBusMessageIter iter, subiter;
+        dbus_int64_t i64;
+        dbus_int32_t i32;
+        DBusError error;
+        int current_type;
+        long long ret;
+        const char * interfacestr = "org.freedesktop.RealtimeKit1";
+
+        dbus_error_init(&error);
+
+        if (!(m = dbus_message_new_method_call(
+                              RTKIT_SERVICE_NAME,
+                              RTKIT_OBJECT_PATH,
+                              "org.freedesktop.DBus.Properties",
+                              "Get"))) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        if (!dbus_message_append_args(
+                            m,
+                            DBUS_TYPE_STRING, &interfacestr,
+                            DBUS_TYPE_STRING, &propname,
+                            DBUS_TYPE_INVALID)) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        if (!(r = dbus_connection_send_with_reply_and_block(connection, m, -1, &error))) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+        if (dbus_set_error_from_message(&error, r)) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+        ret = -EBADMSG;
+        dbus_message_iter_init(r, &iter);
+        while ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) {
+
+                if (current_type == DBUS_TYPE_VARIANT) {
+                        dbus_message_iter_recurse(&iter, &subiter);
+
+                        while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID) {
+
+                                if (current_type == DBUS_TYPE_INT32) {
+                                        dbus_message_iter_get_basic(&subiter, &i32);
+                                        *propval = i32;
+                                        ret = 0;
+                                }
+
+                                if (current_type == DBUS_TYPE_INT64) {
+                                        dbus_message_iter_get_basic(&subiter, &i64);
+                                        *propval = i64;
+                                        ret = 0;
+                                }
+
+                                dbus_message_iter_next (&subiter);
+                         }
+                }
+                dbus_message_iter_next (&iter);
+        }
+
+finish:
+
+        if (m)
+                dbus_message_unref(m);
+
+        if (r)
+                dbus_message_unref(r);
+
+        dbus_error_free(&error);
+
+        return ret;
+}
+
+int rtkit_get_max_realtime_priority(DBusConnection *connection) {
+        long long retval;
+        int err;
+
+        err = rtkit_get_int_property(connection, "MaxRealtimePriority", &retval);
+        return err < 0 ? err : retval;
+}
+
+int rtkit_get_min_nice_level(DBusConnection *connection, int* min_nice_level) {
+        long long retval;
+        int err;
+
+        err = rtkit_get_int_property(connection, "MinNiceLevel", &retval);
+        if (err >= 0)
+                *min_nice_level = retval;
+        return err;
+}
+
+long long rtkit_get_rttime_usec_max(DBusConnection *connection) {
+        long long retval;
+        int err;
+
+        err = rtkit_get_int_property(connection, "RTTimeUSecMax", &retval);
+        return err < 0 ? err : retval;
+}
+
 int rtkit_make_realtime(DBusConnection *connection, pid_t thread, int priority) {
         DBusMessage *m = NULL, *r = NULL;
         dbus_uint64_t u64;
@@ -186,4 +293,16 @@ int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_
         return -ENOTSUP;
 }
 
+int rtkit_get_max_realtime_priority(DBusConnection *connection) {
+        return -ENOTSUP;
+}
+
+int rtkit_get_min_nice_level(DBusConnection *connection, int* min_nice_level) {
+        return -ENOTSUP;
+}
+
+long long rtkit_get_rttime_usec_max(DBusConnection *connection) {
+        return -ENOTSUP;
+}
+
 #endif
diff --git a/src/pulsecore/rtkit.h b/src/pulsecore/rtkit.h
index 2081b4e..ac4d599 100644
--- a/src/pulsecore/rtkit.h
+++ b/src/pulsecore/rtkit.h
@@ -5,6 +5,7 @@
 
 /***
   Copyright 2009 Lennart Poettering
+  Copyright 2010 David Henningsson <diwic at ubuntu.com>
 
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
@@ -55,6 +56,22 @@ int rtkit_make_realtime(DBusConnection *system_bus, pid_t thread, int priority);
  * on success.*/
 int rtkit_make_high_priority(DBusConnection *system_bus, pid_t thread, int nice_level);
 
+/* Return the maximum value of realtime priority available. Realtime requests
+ * above this value will fail. A negative value is an errno style error code.
+ */
+int rtkit_get_max_realtime_priority(DBusConnection *system_bus);
+
+/* Retreive the minimum value of nice level available. High prio requests
+ * below this value will fail. The returned value is a negative errno
+ * style error code, or 0 on success.*/
+int rtkit_get_min_nice_level(DBusConnection *system_bus, int* min_nice_level);
+
+/* Return the maximum value of RLIMIT_RTTIME to set before attempting a
+ * realtime request. A negative value is an errno style error code.
+ */
+long long rtkit_get_rttime_usec_max(DBusConnection *system_bus);
+
+
 #ifdef __cplusplus
 }
 #endif



More information about the pulseaudio-commits mailing list