| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 10:07:41 +01:00
										 |  |  | // Copyright (C) 2015-2020 Edouard Griffiths, F4EXB <f4exb06@gmail.com>          //
 | 
					
						
							|  |  |  | // Copyright (C) 2023 Jon Beniston, M7RCE <jon@beniston.com>                     //
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:57:41 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							| 
									
										
										
										
											2015-08-09 10:33:04 +02:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2024-10-21 17:11:55 +01:00
										 |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  | #include <QFile>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | #include "fileinputworker.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-08 10:02:36 +02:00
										 |  |  | #include "dsp/samplesinkfifo.h"
 | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | #include "util/messagequeue.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(FileInputWorker::MsgReportEOF, Message) | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:42:34 +00:00
										 |  |  | FileInputWorker::FileInputWorker( | 
					
						
							|  |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  |         QFile *samplesStream, | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |         std::ifstream *samplesStream, | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |         SampleSinkFifo* sampleFifo, | 
					
						
							|  |  |  |         const QTimer& timer, | 
					
						
							|  |  |  |         MessageQueue *fileInputMessageQueue, | 
					
						
							|  |  |  |         QObject* parent) : | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | 	QObject(parent), | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	m_running(false), | 
					
						
							|  |  |  | 	m_ifstream(samplesStream), | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  | 	m_fileBuf(nullptr), | 
					
						
							|  |  |  | 	m_convertBuf(nullptr), | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	m_bufsize(0), | 
					
						
							|  |  |  | 	m_chunksize(0), | 
					
						
							|  |  |  | 	m_sampleFifo(sampleFifo), | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	m_samplesCount(0), | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 	m_timer(timer), | 
					
						
							|  |  |  | 	m_fileInputMessageQueue(fileInputMessageQueue), | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |     m_samplerate(0), | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 	m_samplesize(0), | 
					
						
							|  |  |  | 	m_samplebytes(0), | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |     m_throttlems(FILESOURCE_THROTTLE_MS), | 
					
						
							|  |  |  |     m_throttleToggle(false) | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | FileInputWorker::~FileInputWorker() | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (m_running) { | 
					
						
							|  |  |  | 		stopWork(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  | 	if (m_fileBuf) { | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 		free(m_fileBuf); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  | 	if (m_convertBuf) { | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 		free(m_convertBuf); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::startWork() | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  | 	qDebug() << "FileInputThread::startWork: "; | 
					
						
							| 
									
										
										
										
											2016-10-08 10:02:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:42:34 +00:00
										 |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  |     if (m_ifstream->isOpen()) | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |     if (m_ifstream->is_open()) | 
					
						
							| 
									
										
										
										
											2023-01-02 15:42:34 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |         qDebug() << "FileInputThread::startWork: file stream open, starting..."; | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         m_elapsedTimer.start(); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |         connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | 		m_running = true; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |         qDebug() << "FileInputThread::startWork: file stream closed, not starting."; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::stopWork() | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  | 	qDebug() << "FileInputThread::stopWork"; | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 	disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	m_running = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::setSampleRateAndSize(int samplerate, quint32 samplesize) | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  | 	qDebug() << "FileInputThread::setSampleRateAndSize:" | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 			<< " new rate:" << samplerate | 
					
						
							|  |  |  | 			<< " new size:" << samplesize | 
					
						
							|  |  |  | 			<< " old rate:" << m_samplerate | 
					
						
							|  |  |  | 			<< " old size:" << m_samplesize; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 	if ((samplerate != m_samplerate) || (samplesize != m_samplesize)) | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		if (m_running) { | 
					
						
							|  |  |  | 			stopWork(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 		m_samplerate = samplerate; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 		m_samplesize = samplesize; | 
					
						
							|  |  |  | 		m_samplebytes = m_samplesize > 16 ? sizeof(int32_t) : sizeof(int16_t); | 
					
						
							|  |  |  |         m_chunksize = (m_samplerate * 2 * m_samplebytes * m_throttlems) / 1000; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         setBuffers(m_chunksize); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 00:10:23 +02:00
										 |  |  | 	//m_samplerate = samplerate;
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::setBuffers(std::size_t chunksize) | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (chunksize > m_bufsize) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_bufsize = chunksize; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         int nbSamples = m_bufsize/(2 * m_samplebytes); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  |         if (!m_fileBuf) | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |             qDebug() << "FileInputThread::setBuffers: Allocate file buffer"; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             m_fileBuf = (quint8*) malloc(m_bufsize); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |             qDebug() << "FileInputThread::setBuffers: Re-allocate file buffer"; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             quint8 *buf = m_fileBuf; | 
					
						
							|  |  |  |             m_fileBuf = (quint8*) realloc((void*) m_fileBuf, m_bufsize); | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (!m_fileBuf) { | 
					
						
							|  |  |  |                 free(buf); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  |         if (!m_convertBuf) | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |             qDebug() << "FileInputThread::setBuffers: Allocate conversion buffer"; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             m_convertBuf = (quint8*) malloc(nbSamples*sizeof(Sample)); | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |             qDebug() << "FileInputThread::setBuffers: Re-allocate conversion buffer"; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             quint8 *buf = m_convertBuf; | 
					
						
							|  |  |  |             m_convertBuf = (quint8*) realloc((void*) m_convertBuf, nbSamples*sizeof(Sample)); | 
					
						
							| 
									
										
										
										
											2020-07-11 06:56:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (!m_convertBuf) { | 
					
						
							|  |  |  |                 free(buf); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-08 00:59:04 +02:00
										 |  |  |         qDebug() << "FileInputThread::setBuffers: size: " << m_bufsize | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |                 << " #samples: " << nbSamples; | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::tick() | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (m_running) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         qint64 throttlems = m_elapsedTimer.restart(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (throttlems != m_throttlems) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             m_throttlems = throttlems; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             m_chunksize = 2 * m_samplebytes * ((m_samplerate * (m_throttlems+(m_throttleToggle ? 1 : 0))) / 1000); | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |             m_throttleToggle = !m_throttleToggle; | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |             setBuffers(m_chunksize); | 
					
						
							| 
									
										
										
										
											2016-03-14 01:43:21 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:42:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  | 		// read samples directly feeding the SampleFifo (no callback)
 | 
					
						
							|  |  |  | 		qint64 bytesRead = m_ifstream->read(reinterpret_cast<char*>(m_fileBuf), m_chunksize); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_ifstream->atEnd()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             writeToSampleFifo(m_fileBuf, (qint32) bytesRead); | 
					
						
							|  |  |  |             MsgReportEOF *message = MsgReportEOF::create(); | 
					
						
							|  |  |  |             m_fileInputMessageQueue->push(message); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             writeToSampleFifo(m_fileBuf, (qint32) m_chunksize); | 
					
						
							|  |  |  |             m_samplesCount += m_chunksize / (2 * m_samplebytes); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 		// read samples directly feeding the SampleFifo (no callback)
 | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 		m_ifstream->read(reinterpret_cast<char*>(m_fileBuf), m_chunksize); | 
					
						
							| 
									
										
										
										
											2016-10-08 10:02:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |         if (m_ifstream->eof()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         	writeToSampleFifo(m_fileBuf, (qint32) m_ifstream->gcount()); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |         	MsgReportEOF *message = MsgReportEOF::create(); | 
					
						
							|  |  |  |         	m_fileInputMessageQueue->push(message); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  |         	writeToSampleFifo(m_fileBuf, (qint32) m_chunksize); | 
					
						
							|  |  |  |     		m_samplesCount += m_chunksize / (2 * m_samplebytes); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-01-02 15:42:34 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-11 06:45:16 +02:00
										 |  |  | void FileInputWorker::writeToSampleFifo(const quint8* buf, qint32 nbBytes) | 
					
						
							| 
									
										
										
										
											2018-01-25 18:39:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (m_samplesize == 16) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (SDR_RX_SAMP_SZ == 16) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			m_sampleFifo->write(buf, nbBytes); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (SDR_RX_SAMP_SZ == 24) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			FixReal *convertBuf = (FixReal *) m_convertBuf; | 
					
						
							|  |  |  | 			const int16_t *fileBuf = (int16_t *) buf; | 
					
						
							|  |  |  | 			int nbSamples = nbBytes / (2 * m_samplebytes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (int is = 0; is < nbSamples; is++) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				convertBuf[2*is]   = fileBuf[2*is] << 8; | 
					
						
							|  |  |  | 				convertBuf[2*is+1] = fileBuf[2*is+1] << 8; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			m_sampleFifo->write((quint8*) convertBuf, nbSamples*sizeof(Sample)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (m_samplesize == 24) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (SDR_RX_SAMP_SZ == 24) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			m_sampleFifo->write(buf, nbBytes); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (SDR_RX_SAMP_SZ == 16) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			FixReal *convertBuf = (FixReal *) m_convertBuf; | 
					
						
							|  |  |  | 			const int32_t *fileBuf = (int32_t *) buf; | 
					
						
							|  |  |  | 			int nbSamples = nbBytes / (2 * m_samplebytes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (int is = 0; is < nbSamples; is++) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				convertBuf[2*is]   = fileBuf[2*is] >> 8; | 
					
						
							|  |  |  | 				convertBuf[2*is+1] = fileBuf[2*is+1] >> 8; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			m_sampleFifo->write((quint8*) convertBuf, nbSamples*sizeof(Sample)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |