2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
liblscp - LinuxSampler Control Protocol API |
liblscp - LinuxSampler Control Protocol API |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This library is free software; you can redistribute it and/or |
This library is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU Lesser General Public |
modify it under the terms of the GNU Lesser General Public |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
Lesser General Public License for more details. |
Lesser General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU Lesser General Public |
You should have received a copy of the GNU General Public License along |
18 |
License along with this library; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
50 |
|
|
51 |
typedef enum _lscp_status_t |
typedef enum _lscp_status_t |
52 |
{ |
{ |
53 |
LSCP_OK = 0, |
LSCP_OK = 0, |
54 |
LSCP_FAILED = -1, |
LSCP_FAILED = -1, |
55 |
LSCP_ERROR = -2, |
LSCP_ERROR = -2, |
56 |
LSCP_WARNING = -3, |
LSCP_WARNING = -3, |
57 |
LSCP_TIMEOUT = -4, |
LSCP_TIMEOUT = -4, |
58 |
LSCP_QUIT = -5 |
LSCP_QUIT = -5 |
59 |
|
|
60 |
} lscp_status_t; |
} lscp_status_t; |
61 |
|
|
77 |
#endif |
#endif |
78 |
|
|
79 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
80 |
|
// Simple condition variables (FIXME: probably incorrect on WIN32). |
81 |
|
|
82 |
|
#if defined(WIN32) |
83 |
|
typedef HANDLE lscp_cond_t; |
84 |
|
#define lscp_cond_init(c) { (c) = CreateEvent(NULL, FALSE, FALSE, NULL); } |
85 |
|
#define lscp_cond_destroy(c) if (c) { CloseHandle(c); } |
86 |
|
#define lscp_cond_wait(c, m) { lscp_mutex_unlock(m); WaitForSingleObject((c), INFINITE); lscp_mutex_lock(m); } |
87 |
|
#define lscp_cond_signal(c) SetEvent(c) |
88 |
|
#else |
89 |
|
typedef pthread_cond_t lscp_cond_t; |
90 |
|
#define lscp_cond_init(c) pthread_cond_init(&(c), NULL) |
91 |
|
#define lscp_cond_destroy(c) pthread_cond_destroy(&(c)) |
92 |
|
#define lscp_cond_wait(c, m) pthread_cond_wait(&(c), &(m)) |
93 |
|
#define lscp_cond_signal(c) pthread_cond_signal(&(c)) |
94 |
|
#endif |
95 |
|
|
96 |
|
//------------------------------------------------------------------------- |
97 |
// Threads. |
// Threads. |
98 |
|
|
99 |
struct _lscp_thread_t; |
struct _lscp_thread_t; |
108 |
lscp_status_t lscp_thread_destroy (lscp_thread_t *pThread); |
lscp_status_t lscp_thread_destroy (lscp_thread_t *pThread); |
109 |
|
|
110 |
#if defined(WIN32) |
#if defined(WIN32) |
|
#define lscp_thread_exit() pthread_exit(NULL) |
|
|
#else |
|
111 |
#define lscp_thread_exit() ExitThread(0) |
#define lscp_thread_exit() ExitThread(0) |
112 |
|
#else |
113 |
|
#define lscp_thread_exit() pthread_exit(NULL) |
114 |
#endif |
#endif |
115 |
|
|
116 |
#if defined(__cplusplus) |
#if defined(__cplusplus) |