summaryrefslogtreecommitdiffstats
path: root/src/tools/reserve.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:28:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:28:17 +0000
commit7a46c07230b8d8108c0e8e80df4522d0ac116538 (patch)
treed483300dab478b994fe199a5d19d18d74153718a /src/tools/reserve.h
parentInitial commit. (diff)
downloadpipewire-7a46c07230b8d8108c0e8e80df4522d0ac116538.tar.xz
pipewire-7a46c07230b8d8108c0e8e80df4522d0ac116538.zip
Adding upstream version 0.3.65.upstream/0.3.65upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/reserve.h')
-rw-r--r--src/tools/reserve.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/tools/reserve.h b/src/tools/reserve.h
new file mode 100644
index 0000000..c31e2d0
--- /dev/null
+++ b/src/tools/reserve.h
@@ -0,0 +1,82 @@
+/* DBus device reservation API
+ *
+ * Copyright © 2019 Wim Taymans
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef DEVICE_RESERVE_H
+#define DEVICE_RESERVE_H
+
+#include <dbus/dbus.h>
+#include <inttypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct rd_device;
+
+struct rd_device_callbacks {
+ /** the device is acquired by us */
+ void (*acquired) (void *data, struct rd_device *d);
+ /** request a release of the device */
+ void (*release) (void *data, struct rd_device *d, int forced);
+ /** the device is busy by someone else */
+ void (*busy) (void *data, struct rd_device *d, const char *name, int32_t priority);
+ /** the device is made available by someone else */
+ void (*available) (void *data, struct rd_device *d, const char *name);
+};
+
+/* create a new device and start watching */
+struct rd_device *
+rd_device_new(DBusConnection *connection, /**< Bus to watch */
+ const char *device_name, /**< The device to lock, e.g. "Audio0" */
+ const char *application_name, /**< A human readable name of the application,
+ * e.g. "PipeWire Server" */
+ int32_t priority, /**< The priority for this application.
+ * If unsure use 0 */
+ const struct rd_device_callbacks *callbacks, /**< Called when device name is acquired/released */
+ void *data);
+
+/** try to acquire the device */
+int rd_device_acquire(struct rd_device *d);
+
+/** request the owner to release the device */
+int rd_device_request_release(struct rd_device *d);
+
+/** complete the release of the device */
+int rd_device_complete_release(struct rd_device *d, int res);
+
+/** release a device */
+void rd_device_release(struct rd_device *d);
+
+/** destroy a device */
+void rd_device_destroy(struct rd_device *d);
+
+/* Set the application device name for an rd_device object. Returns 0
+ * on success, a negative errno style return value on error. */
+int rd_device_set_application_device_name(struct rd_device *d, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif