jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.4KB

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