mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
Tx ph.1: fixed source sink initialization
This commit is contained in:
parent
c7bec82677
commit
4e446b9c7a
@ -20,17 +20,25 @@
|
||||
SampleSourceFifo::SampleSourceFifo(uint32_t size, uint32_t samplesChunkSize) :
|
||||
m_size(size),
|
||||
m_samplesChunkSize(samplesChunkSize),
|
||||
m_ir(0),
|
||||
m_iw(size/2)
|
||||
m_init(false)
|
||||
{
|
||||
assert(samplesChunkSize <= m_size/4);
|
||||
m_data.resize(2*m_size);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
SampleSourceFifo::~SampleSourceFifo()
|
||||
{}
|
||||
|
||||
void SampleSourceFifo::init()
|
||||
{
|
||||
memset(&m_data[0], 0, sizeof(2*m_size*sizeof(Sample)));
|
||||
m_ir = 0;
|
||||
m_iw = m_samplesChunkSize*2;
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSamples)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
@ -42,7 +50,12 @@ void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSa
|
||||
|
||||
int i_delta = m_iw - m_ir;
|
||||
|
||||
if (i_delta > 0)
|
||||
if (m_init)
|
||||
{
|
||||
emit dataWrite();
|
||||
m_init = false;
|
||||
}
|
||||
else if (i_delta > 0)
|
||||
{
|
||||
if (i_delta < m_samplesChunkSize)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
unsigned int getChunkSize() const { return m_samplesChunkSize; }
|
||||
|
||||
void init();
|
||||
/** begin read at current read point for the given length */
|
||||
void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
|
||||
|
||||
@ -47,6 +48,7 @@ private:
|
||||
SampleVector m_data;
|
||||
uint32_t m_iw;
|
||||
uint32_t m_ir;
|
||||
bool m_init;
|
||||
QMutex m_mutex;
|
||||
|
||||
signals:
|
||||
|
Loading…
Reference in New Issue
Block a user