[f2a96d]: libkwave / SampleFIFO.h Maximize Restore History

Download this file

SampleFIFO.h    79 lines (63 with data), 2.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*************************************************************************
SampleFIFO.h - simple FIFO, tuned for sample_t
-------------------
begin : Sun Apr 11 2004
copyright : (C) 2004 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _SAMPLE_FIFO_H_
#define _SAMPLE_FIFO_H_
#include "config.h"
#include <qvaluevector.h>
#include <qmutex.h>
#include "libkwave/KwaveSampleArray.h"
class SampleFIFO
{
public:
/** Constructor */
SampleFIFO();
/** Destructor */
virtual ~SampleFIFO();
/**
* Reset the FIFO. This destroys the content and sets
* all pointers to their initial value.
*/
virtual void flush();
/**
* puts samples into the FIFO
*
* @param buffer reference to an array of samples to feed in
*/
virtual void put(const Kwave::SampleArray &source);
/**
* gets and removes samples from the FIFO
*
* @param buffer reference to an array of samples to be filled
* @return number of received samples
*/
virtual unsigned int get(Kwave::SampleArray &buffer);
/**
* Returns the number of samples that can be read out.
* @see m_written
*/
virtual unsigned int length();
private:
/** list of buffers with sample data */
QValueVector<Kwave::SampleArray> m_buffer;
/**
* number of samples that have already been read out
* from the first buffer (head, first one to read out)
*/
unsigned int m_read_offset;
/** mutex for access to the FIFO (recursive) */
QMutex m_lock;
};
#endif /* _SAMPLE_FIFO_H_ */