]> code.delx.au - pulseaudio/commitdiff
add new pa_proplist_setf() API function
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Apr 2008 13:49:04 +0000 (13:49 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Apr 2008 13:49:04 +0000 (13:49 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2230 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulse/proplist.c
src/pulse/proplist.h

index 31fd10d5c0fe04f21f1aaf87e9bfa6e2d9a898dc..33bd274f8d97a2578619b79a0e2b0194a8ca6b7f 100644 (file)
@@ -102,6 +102,28 @@ int pa_proplist_sets(pa_proplist *p, const char *key, const char *value) {
     return 0;
 }
 
+/** Will accept only valid UTF-8 */
+int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) {
+    va_list ap;
+    int r;
+    char *t;
+
+    pa_assert(p);
+    pa_assert(key);
+
+    if (!property_name_valid(key) || !pa_utf8_valid(format))
+        return -1;
+
+    va_start(ap, format);
+    t = pa_vsprintf_malloc(format, ap);
+    va_end(ap);
+
+    r = pa_proplist_sets(p, key, t);
+
+    pa_xfree(t);
+    return r;
+}
+
 int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes) {
     struct property *prop;
     pa_bool_t add = FALSE;
index 2137916726fc11ad98c4ef8d65009084b26dd80e..7c3423fae52afc9180dd03ba02ce8a6b0d07cace 100644 (file)
 #define PA_PROP_DEVICE_CONNECTOR            "device.connector"
 #define PA_PROP_DEVICE_ACCESS_MODE          "device.access_mode"
 #define PA_PROP_DEVICE_MASTER_DEVICE        "device.master_device"
+#define PA_PROP_DEVICE_BUFFER_NFRAGMENTS    "device.buffer.nfragments"
+#define PA_PROP_DEVICE_BUFFER_FRAGMENT_SIZE "device.buffer.fragment_size"
 
 /** A property list object. Basically a dictionary with UTF-8 strings
  * as keys and arbitrary data as values. \since 0.9.11 */
@@ -117,6 +119,13 @@ void pa_proplist_free(pa_proplist* p);
  * UTF-8. \since 0.9.11 */
 int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
 
+/** Append a new string entry to the property list, possibly
+ * overwriting an already existing entry with the same key. An
+ * internal copy of the data passed is made. Will accept only valid
+ * UTF-8. The data can be passed as printf()-style format string with
+ * arguments. \since 0.9.11 */
+int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4);
+
 /** Append a new arbitrary data entry to the property list, possibly
  * overwriting an already existing entry with the same key. An
  * internal copy of the data passed is made. \since 0.9.11 */