Jack2
1.9.8
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
common
JackMessageBuffer.h
1
/*
2
* messagebuffer.h -- realtime-safe message interface for jackd.
3
*
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.
7
*/
8
9
/*
10
* Copyright (C) 2004 Rui Nuno Capela, Steve Harris
11
* Copyright (C) 2008 Nedko Arnaudov
12
* Copyright (C) 2008 Grame
13
*
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.
18
*
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.
23
*
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.
27
*
28
*/
29
30
#ifndef __JackMessageBuffer__
31
#define __JackMessageBuffer__
32
33
#include "JackPlatformPlug.h"
34
#include "JackMutex.h"
35
#include "JackAtomic.h"
36
37
namespace
Jack
38
{
39
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 */
44
45
struct
JackMessage
46
{
47
int
level;
48
char
message[MB_BUFFERSIZE];
49
};
50
55
class
JackMessageBuffer
:
public
JackRunnableInterface
56
{
57
58
private
:
59
60
JackThreadInitCallback fInit;
61
void
* fInitArg;
62
JackMessage
fBuffers[MB_BUFFERS];
63
JackThread
fThread;
64
JackProcessSync
fGuard;
65
volatile
unsigned
int
fInBuffer;
66
volatile
unsigned
int
fOutBuffer;
67
SInt32 fOverruns;
68
bool
fRunning;
69
70
void
Flush();
71
72
void
Start();
73
void
Stop();
74
75
public
:
76
77
JackMessageBuffer
();
78
~
JackMessageBuffer
();
79
80
// JackRunnableInterface interface
81
bool
Execute();
82
83
void
static
Create();
84
void
static
Destroy();
85
86
void
AddMessage(
int
level,
const
char
*message);
87
void
SetInitCallback(JackThreadInitCallback callback,
void
*arg);
88
89
static
JackMessageBuffer
* fInstance;
90
};
91
92
#ifdef __cplusplus
93
extern
"C"
94
{
95
#endif
96
97
void
JackMessageBufferAdd(
int
level,
const
char
*message);
98
99
#ifdef __cplusplus
100
}
101
#endif
102
103
};
104
105
#endif
Generated by
1.8.2