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.

70 lines
3.2KB

  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. typedef struct rd_device rd_device;
  26. /* Prototype for a function that is called whenever someone else wants
  27. * your application to release the device it has locked. A return
  28. * value <= 0 denies the request, a positive return value agrees to
  29. * it. Before returning your application should close the device in
  30. * question completely to make sure the new application may access
  31. * it. */
  32. typedef int (*rd_request_cb_t)(
  33. rd_device *d,
  34. 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. */
  35. /* Try to lock the device. Returns 0 on success, a negative errno
  36. * style return value on error. The DBus error might be set as well if
  37. * the error was caused D-Bus. */
  38. int rd_acquire(
  39. rd_device **d, /* On success a pointer to the newly allocated rd_device object will be filled in here */
  40. DBusConnection *connection,
  41. const char *device_name, /* The device to lock, e.g. "Audio0" */
  42. const char *application_name, /* A human readable name of the application, e.g. "PulseAudio Sound Server" */
  43. int32_t priority, /* The priority for this application. If unsure use 0 */
  44. 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 */
  45. DBusError *error); /* If we fail due to a D-Bus related issue the error will be filled in here. May be NULL. */
  46. /* Unlock (if needed) and destroy an rd_device object again */
  47. void rd_release(rd_device *d);
  48. /* Set the application device name for an rd_device object. Returns 0
  49. * on success, a negative errno style return value on error. */
  50. int rd_set_application_device_name(rd_device *d, const char *name);
  51. /* Attach a userdata pointer to an rd_device */
  52. void rd_set_userdata(rd_device *d, void *userdata);
  53. /* Query the userdata pointer from an rd_device. Returns NULL if no
  54. * userdata was set. */
  55. void* rd_get_userdata(rd_device *d);
  56. #endif