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.

98 lines
3.2KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2008 Grame
  4. Copyright (C) 2013 Samsung Electronics
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. */
  17. #ifndef __JackAndroidThread__
  18. #define __JackAndroidThread__
  19. #include "JackThread.h"
  20. #include <pthread.h>
  21. namespace Jack
  22. {
  23. /* use 512KB stack per thread - the default is way too high to be feasible
  24. * with mlockall() on many systems */
  25. #define THREAD_STACK 524288
  26. enum
  27. {
  28. PTHREAD_CANCEL_DEFERRED,
  29. PTHREAD_CANCEL_ASYNCHRONOUS
  30. };
  31. /*!
  32. \brief The POSIX thread base class.
  33. */
  34. class SERVER_EXPORT JackAndroidThread : public detail::JackThreadInterface
  35. {
  36. protected:
  37. jack_native_thread_t fThread;
  38. static void* ThreadHandler(void* arg);
  39. static void thread_exit_handler(int sig);
  40. public:
  41. JackAndroidThread(JackRunnableInterface* runnable, bool real_time, int priority, int cancellation)
  42. : JackThreadInterface(runnable, priority, real_time, cancellation), fThread((jack_native_thread_t)NULL)
  43. {}
  44. JackAndroidThread(JackRunnableInterface* runnable, int cancellation = PTHREAD_CANCEL_ASYNCHRONOUS)
  45. : JackThreadInterface(runnable, 0, false, cancellation), fThread((jack_native_thread_t)NULL)
  46. {}
  47. int Start();
  48. int StartSync();
  49. int Kill();
  50. int Stop();
  51. void Terminate();
  52. int AcquireRealTime(); // Used when called from another thread
  53. int AcquireSelfRealTime(); // Used when called from thread itself
  54. int AcquireRealTime(int priority); // Used when called from another thread
  55. int AcquireSelfRealTime(int priority); // Used when called from thread itself
  56. int DropRealTime(); // Used when called from another thread
  57. int DropSelfRealTime(); // Used when called from thread itself
  58. jack_native_thread_t GetThreadID();
  59. bool IsThread();
  60. static int AcquireRealTimeImp(jack_native_thread_t thread, int priority);
  61. static int AcquireRealTimeImp(jack_native_thread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint)
  62. {
  63. return JackAndroidThread::AcquireRealTimeImp(thread, priority);
  64. }
  65. static int DropRealTimeImp(jack_native_thread_t thread);
  66. static int StartImp(jack_native_thread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg);
  67. static int StopImp(jack_native_thread_t thread);
  68. static int KillImp(jack_native_thread_t thread);
  69. };
  70. SERVER_EXPORT void ThreadExit();
  71. } // end of namespace
  72. #endif