Add JackWaitCallbackDriver
[jack2.git] / dbus / reserve.h
blob6e16a07d8169d69ff0b476feb23490d1346b6297
1 #ifndef fooreservehfoo
2 #define fooreservehfoo
4 /***
5 Copyright 2009 Lennart Poettering
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation files
9 (the "Software"), to deal in the Software without restriction,
10 including without limitation the rights to use, copy, modify, merge,
11 publish, distribute, sublicense, and/or sell copies of the Software,
12 and to permit persons to whom the Software is furnished to do so,
13 subject to the following conditions:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 SOFTWARE.
26 ***/
28 #include <dbus/dbus.h>
29 #include <inttypes.h>
31 # ifndef INT32_MIN
32 # define INT32_MIN (-2147483647-1)
33 # endif
34 # ifndef INT32_MAX
35 # define INT32_MAX (2147483647)
36 # endif
38 typedef struct rd_device rd_device;
40 /* Prototype for a function that is called whenever someone else wants
41 * your application to release the device it has locked. A return
42 * value <= 0 denies the request, a positive return value agrees to
43 * it. Before returning your application should close the device in
44 * question completely to make sure the new application may access
45 * it. */
46 typedef int (*rd_request_cb_t)(
47 rd_device *d,
48 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. */
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
54 /* Try to lock the device. Returns 0 on success, a negative errno
55 * style return value on error. The DBus error might be set as well if
56 * the error was caused D-Bus. */
57 int rd_acquire(
58 rd_device **d, /* On success a pointer to the newly allocated rd_device object will be filled in here */
59 DBusConnection *connection,
60 const char *device_name, /* The device to lock, e.g. "Audio0" */
61 const char *application_name, /* A human readable name of the application, e.g. "PulseAudio Sound Server" */
62 int32_t priority, /* The priority for this application. If unsure use 0 */
63 rd_request_cb_t request_cb, /* Will be called whenever someone requests that this device shall be released. May be NULL if priority is INT32_MAX */
64 DBusError *error); /* If we fail due to a D-Bus related issue the error will be filled in here. May be NULL. */
66 /* Unlock (if needed) and destroy an rd_device object again */
67 void rd_release(rd_device *d);
69 /* Set the application device name for an rd_device object. Returns 0
70 * on success, a negative errno style return value on error. */
71 int rd_set_application_device_name(rd_device *d, const char *name);
73 /* Attach a userdata pointer to an rd_device */
74 void rd_set_userdata(rd_device *d, void *userdata);
76 /* Query the userdata pointer from an rd_device. Returns NULL if no
77 * userdata was set. */
78 void* rd_get_userdata(rd_device *d);
80 #ifdef __cplusplus
81 } /* extern "C" */
82 #endif
84 #endif