2 * messagebuffer.h -- realtime-safe message interface for jackd.
4 * This function is included in libjack so backend drivers can use
5 * it, *not* for external client processes. The VERBOSE() and
6 * MESSAGE() macros are realtime-safe.
10 * Copyright (C) 2004 Rui Nuno Capela, Steve Harris
11 * Copyright (C) 2008 Nedko Arnaudov
12 * Copyright (C) 2008 Grame
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation; either version 2.1 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifndef __JackMessageBuffer__
31 #define __JackMessageBuffer__
33 #include "JackPlatformPlug.h"
34 #include "JackMutex.h"
35 #include "JackAtomic.h"
40 /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */
41 #define MB_BUFFERS 128
42 #define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1))
43 #define MB_BUFFERSIZE 256 /* message length limit */
48 char message
[MB_BUFFERSIZE
];
52 \brief Message buffer to be used from RT threads.
55 class JackMessageBuffer
: public JackRunnableInterface
60 volatile JackThreadInitCallback fInit
;
62 JackMessage fBuffers
[MB_BUFFERS
];
64 JackProcessSync fGuard
;
65 volatile unsigned int fInBuffer
;
66 volatile unsigned int fOutBuffer
;
80 // JackRunnableInterface interface
84 bool static Destroy();
86 void AddMessage(int level
, const char *message
);
87 int SetInitCallback(JackThreadInitCallback callback
, void *arg
);
89 static JackMessageBuffer
* fInstance
;
97 void JackMessageBufferAdd(int level
, const char *message
);