kradio4
r778
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
src
multibuffer.h
Go to the documentation of this file.
1
/***************************************************************************
2
multibuffer.h
3
-------------------
4
begin : Sat Aug 20 2005
5
copyright : (C) 2005 by Martin Witte
6
email : emw-kradio@nocabal.de
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef KRADIO_MULTIBUFFER_H
19
#define KRADIO_MULTIBUFFER_H
20
21
#ifdef HAVE_CONFIG_H
22
#include <config.h>
23
#endif
24
25
#include <QtCore/QSemaphore>
26
#include <QtCore/QString>
27
#include <kdemacros.h>
28
29
class
KDE_EXPORT
MultiBuffer
30
{
31
public
:
32
MultiBuffer
(
size_t
n_buffers,
size_t
buffersize);
33
~
MultiBuffer
();
34
35
char
*lockWriteBuffer (
size_t
&bufferSize);
36
bool
unlockWriteBuffer (
size_t
bufferSize);
// return value: complete buffer full / ready for read
37
void
unlockAllWriteBuffers();
38
char
*wait4ReadBuffer (
size_t
&buffer_fill);
39
char
*getCurrentReadBuffer(
size_t
&buffer_fill)
const
;
40
41
const
QString &
getErrorString
()
const
{
return
m_errorString; }
42
bool
hasError
()
const
{
return
m_error; }
43
void
resetError();
44
45
size_t
getWriteBufferFill
()
const
{
return
(m_currentReadBuffer != m_currentWriteBuffer) ? m_buffersFill[m_currentWriteBuffer] : 0; }
46
size_t
getAvailableWriteBuffer()
const
;
47
size_t
getAvailableReadBuffers()
const
;
48
size_t
getCurrentReadBufferIdx
()
const
{
return
m_currentReadBuffer; }
49
size_t
getCurrentWriteBufferIdx
()
const
{
return
m_currentWriteBuffer; }
50
51
protected
:
52
53
size_t
m_nBuffers
;
54
size_t
m_BufferSize
;
55
56
char
**
m_buffers
;
57
size_t
*
m_buffersFill
;
58
size_t
m_currentReadBuffer
;
59
size_t
m_currentWriteBuffer
;
60
QSemaphore
m_readLock
;
61
62
QString
m_errorString
;
63
bool
m_error
;
64
};
65
66
#endif
Generated by
1.8.1.2