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.

92 lines
3.0KB

  1. /*
  2. Copyright (C) 2004 Paul Davis
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __jack_thread_h__
  16. #define __jack_thread_h__
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. #ifdef WIN32
  22. #include <windows.h>
  23. typedef HANDLE pthread_t;
  24. #else
  25. #include <pthread.h>
  26. #endif
  27. /** @file thread.h
  28. *
  29. * Library functions to standardize thread creation for JACK and its
  30. * clients. These interfaces hide some system variations in the
  31. * handling of realtime scheduling and associated privileges.
  32. */
  33. /**
  34. * Attempt to enable realtime scheduling for a thread. On some
  35. * systems that may require special privileges.
  36. *
  37. * @param thread POSIX thread ID.
  38. * @param priority requested thread priority.
  39. *
  40. * @returns 0, if successful; EPERM, if the calling process lacks
  41. * required realtime privileges; otherwise some other error number.
  42. */
  43. int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
  44. /**
  45. * Create a thread for JACK or one of its clients. The thread is
  46. * created executing @a start_routine with @a arg as its sole
  47. * argument.
  48. *
  49. * @param client the JACK client for whom the thread is being created. May be
  50. * NULL if the client is being created within the JACK server.
  51. * @param thread place to return POSIX thread ID.
  52. * @param priority thread priority, if realtime.
  53. * @param realtime true for the thread to use realtime scheduling. On
  54. * some systems that may require special privileges.
  55. * @param start_routine function the thread calls when it starts.
  56. * @param arg parameter passed to the @a start_routine.
  57. *
  58. * @returns 0, if successful; otherwise some error number.
  59. */
  60. int jack_client_create_thread (jack_client_t* client,
  61. pthread_t *thread,
  62. int priority,
  63. int realtime, /* boolean */
  64. void *(*start_routine)(void*),
  65. void *arg);
  66. /**
  67. * Drop realtime scheduling for a thread.
  68. *
  69. * @param thread POSIX thread ID.
  70. *
  71. * @returns 0, if successful; otherwise an error number.
  72. */
  73. int jack_drop_real_time_scheduling (pthread_t thread);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif /* __jack_thread_h__ */