mirror of https://github.com/f4exb/sdrangel.git
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) :
|
SampleSourceFifo::SampleSourceFifo(uint32_t size, uint32_t samplesChunkSize) :
|
||||||
m_size(size),
|
m_size(size),
|
||||||
m_samplesChunkSize(samplesChunkSize),
|
m_samplesChunkSize(samplesChunkSize),
|
||||||
m_ir(0),
|
m_init(false)
|
||||||
m_iw(size/2)
|
|
||||||
{
|
{
|
||||||
assert(samplesChunkSize <= m_size/4);
|
assert(samplesChunkSize <= m_size/4);
|
||||||
m_data.resize(2*m_size);
|
m_data.resize(2*m_size);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SampleSourceFifo::~SampleSourceFifo()
|
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)
|
void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSamples)
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
@ -42,7 +50,12 @@ void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSa
|
||||||
|
|
||||||
int i_delta = m_iw - m_ir;
|
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)
|
if (i_delta < m_samplesChunkSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
|
|
||||||
unsigned int getChunkSize() const { return m_samplesChunkSize; }
|
unsigned int getChunkSize() const { return m_samplesChunkSize; }
|
||||||
|
|
||||||
|
void init();
|
||||||
/** begin read at current read point for the given length */
|
/** begin read at current read point for the given length */
|
||||||
void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
|
void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ private:
|
||||||
SampleVector m_data;
|
SampleVector m_data;
|
||||||
uint32_t m_iw;
|
uint32_t m_iw;
|
||||||
uint32_t m_ir;
|
uint32_t m_ir;
|
||||||
|
bool m_init;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in New Issue