]> code.delx.au - pulseaudio/blob - src/modules/reserve.h
Merge commit 'origin/master-tx'
[pulseaudio] / src / modules / reserve.h
1 #ifndef fooreservehfoo
2 #define fooreservehfoo
3
4 /***
5 Copyright 2009 Lennart Poettering
6
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:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
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 ***/
27
28 #include <dbus/dbus.h>
29 #include <inttypes.h>
30
31 typedef struct rd_device rd_device;
32
33 /* Prototype for a function that is called whenever someone else wants
34 * your app to release the device you having locked. A return value <=
35 * 0 denies the request, a positive return value agrees to it. Before
36 * returning your application should close the device in question
37 * completely to make sure the new application may acceess it. */
38 typedef int (*rd_request_cb_t)(
39 rd_device *d,
40 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. */
41
42 /* Try to lock the device. Returns 0 on success, a negative errno
43 * style return value on error. The DBus error might be set as well if
44 * the error was caused D-Bus. */
45 int rd_acquire(
46 rd_device **d, /* On success a pointer to the newly allocated rd_device object will be filled in here */
47 DBusConnection *connection,
48 const char *device_name, /* The device to lock, e.g. "Audio0" */
49 const char *application_name, /* A human readable name of the application, e.g. "PulseAudio Sound Server" */
50 int32_t priority, /* The priority for this application. If unsure use 0 */
51 rd_request_cb_t request_cb, /* Will be called whenever someone asks that this device shall be released. May be NULL if priority is INT32_MAX */
52 DBusError *error); /* If we fail due to a D-Bus related issue the error will be filled in here. May be NULL. */
53
54 /* Unlock (if needed) and destroy a rd_device object again */
55 void rd_release(rd_device *d);
56
57 /* Set the application device name for a rd_device object Returns 0 on
58 * success, a negative errno style return value on error. */
59 int rd_set_application_device_name(rd_device *d, const char *name);
60
61 /* Attach a userdata pointer to a rd_device */
62 void rd_set_userdata(rd_device *d, void *userdata);
63
64 /* Query the userdata pointer from a rd_device. Returns NULL if no
65 * userdata was set. */
66 void* rd_get_userdata(rd_device *d);
67
68 #endif