SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
samplesinkfifodoublebuffered.cpp
Go to the documentation of this file.
1 // Copyright (C) 2016 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
19 
21  m_size(size),
22  m_signalThreshold(signalThreshold),
23  m_i(0),
24  m_count(0),
25  m_readIndex(0),
26  m_readCount(0)
27 {
28  assert(m_signalThreshold < m_size/2);
29  m_data.resize(2*m_size);
30 }
31 
33 {
34 }
35 
36 void SampleSinkFifoDoubleBuffered::getWriteIterator(SampleVector::iterator& it1)
37 {
38  it1 = m_data.begin() + m_i;
39 }
40 
41 void SampleSinkFifoDoubleBuffered::bumpIndex(SampleVector::iterator& it1)
42 {
44  m_i = (m_i+1) % m_size;
45  it1 = m_data.begin() + m_i;
46 
48  {
49  m_count++;
50  }
51  else
52  {
53  QMutexLocker mutexLocker(&m_mutex);
56  m_count = 0;
57  emit dataReady();
58  }
59 }
60 
61 void SampleSinkFifoDoubleBuffered::read(SampleVector::iterator& begin, SampleVector::iterator& end)
62 {
63  QMutexLocker mutexLocker(&m_mutex);
64 
65  begin = m_data.begin() + m_readIndex;
66  end = begin + m_readCount;
67 }
68 
void read(SampleVector::iterator &begin, SampleVector::iterator &end)
unsigned int uint32_t
Definition: rtptypes_win.h:46
void getWriteIterator(SampleVector::iterator &it1)
SampleSinkFifoDoubleBuffered(uint32_t size, uint32_t signalThreshold)
void bumpIndex(SampleVector::iterator &it1)