mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 13:11:20 -05:00 
			
		
		
		
	SDRdaemon plugin: Ensure a minimal size of the main buffer depending on frame size so that auto follow ups work fine
This commit is contained in:
		
							parent
							
								
									0ffc02102e
								
							
						
					
					
						commit
						b7a4c468fc
					
				@ -27,6 +27,7 @@ const int SDRdaemonBuffer::m_udpPayloadSize = 512;
 | 
			
		||||
const int SDRdaemonBuffer::m_sampleSize = 2;
 | 
			
		||||
const int SDRdaemonBuffer::m_iqSampleSize = 2 * m_sampleSize;
 | 
			
		||||
const int SDRdaemonBuffer::m_rawBufferLengthSeconds = 8; // should be even
 | 
			
		||||
const int SDRdaemonBuffer::m_rawBufferMinNbFrames = 50;
 | 
			
		||||
 | 
			
		||||
SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
 | 
			
		||||
	m_throttlemsNominal(throttlems),
 | 
			
		||||
@ -95,6 +96,11 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t rawSize = sampleRate * m_iqSampleSize * m_rawBufferLengthSeconds; // store worth of this seconds of samples at this sample rate
 | 
			
		||||
 | 
			
		||||
	if ((m_frameSize > 0) && (rawSize / m_frameSize < m_rawBufferMinNbFrames))
 | 
			
		||||
	{
 | 
			
		||||
		rawSize = m_rawBufferMinNbFrames * m_frameSize; // ensure a minimal size of this times the write block size so that auto follow ups work fine
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rawSize != m_rawSize)
 | 
			
		||||
	{
 | 
			
		||||
		m_rawSize = rawSize;
 | 
			
		||||
@ -109,6 +115,7 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate)
 | 
			
		||||
 | 
			
		||||
		qDebug() << "SDRdaemonBuffer::updateBufferSize:"
 | 
			
		||||
			<< " sampleRate: " << sampleRate
 | 
			
		||||
			<< " m_frameSize: " << m_frameSize
 | 
			
		||||
			<< " m_rawSize: " << m_rawSize;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -221,7 +228,11 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
 | 
			
		||||
				m_lz4 = false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			m_frameSize = frameSize;
 | 
			
		||||
			if (frameSize != m_frameSize) {
 | 
			
		||||
				m_frameSize = frameSize;
 | 
			
		||||
				updateBufferSize(m_sampleRate);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			m_sync = true;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
 | 
			
		||||
@ -111,6 +111,7 @@ public:
 | 
			
		||||
	static const int m_sampleSize;
 | 
			
		||||
	static const int m_iqSampleSize;
 | 
			
		||||
	static const int m_rawBufferLengthSeconds;
 | 
			
		||||
	static const int m_rawBufferMinNbFrames; //!< Minimum number of frames for the length of buffer
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	void updateBufferSize(uint32_t sampleRate);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user