]> code.delx.au - pulseaudio/blobdiff - polyp/util.c
new configuration subsystem
[pulseaudio] / polyp / util.c
index 1dbb8697acc8321025c6d46ff16dca0d2d4ad0fb..039ec264ddd22205430a2786ff3dba4f414cc7cb 100644 (file)
@@ -268,6 +268,22 @@ pa_usec_t pa_age(const struct timeval *tv) {
     return pa_timeval_diff(&now, tv);
 }
 
+void pa_timeval_add(struct timeval *tv, pa_usec_t v) {
+    unsigned long secs;
+    assert(tv);
+    
+    secs = (v/1000000);
+    tv->tv_sec += (unsigned long) secs;
+    v -= secs*1000000;
+
+    tv->tv_usec += v;
+
+    while (tv->tv_usec >= 1000000) {
+        tv->tv_sec++;
+        tv->tv_usec -= 1000000;
+    }
+}
+
 #define NICE_LEVEL (-15)
 
 void pa_raise_priority(void) {
@@ -347,3 +363,13 @@ char *pa_path_get_filename(const char *p) {
 
     return (char*) p;
 }
+
+int pa_parse_boolean(const char *v) {
+    
+    if (!strcmp(v, "1") || !strcasecmp(v, "yes") || !strcasecmp(v, "y") || !strcasecmp(v, "on"))
+        return 1;
+    else if (!strcmp(v, "0") || !strcasecmp(v, "no") || !strcasecmp(v, "n") || !strcasecmp(v, "off"))
+        return 0;
+
+    return -1;
+}