mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Serial DV support. Implemented without audio upsampling to 48k
This commit is contained in:
		
							parent
							
								
									be1a4caae1
								
							
						
					
					
						commit
						4daa54b8b7
					
				| @ -174,7 +174,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto | ||||
| 
 | ||||
| 	    if (m_dsdDecoder.mbeDVReady()) | ||||
| 	    { | ||||
| 	        DSPEngine::instance()->push(); | ||||
| 	        DSPEngine::instance()->pushMbeFrame(m_dsdDecoder.getMbeDVFrame(), m_dsdDecoder.getMbeRateIndex(), m_running.m_volume, &m_audioFifo); | ||||
| 	        m_dsdDecoder.resetMbeDV(); | ||||
| 	    } | ||||
| 	} | ||||
|  | ||||
| @ -79,10 +79,10 @@ public: | ||||
| 
 | ||||
| 	void setDVSerialSupport(bool support); | ||||
| 
 | ||||
| 	void push() | ||||
| 	void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo) | ||||
| 	{ | ||||
| #ifdef DSD_USE_SERIALDV | ||||
| 	    m_dvSerialEngine.push(); | ||||
| 	    m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, audioFifo); | ||||
| #endif | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -178,7 +178,7 @@ bool DVSerialEngine::scan() | ||||
|             connect(controller.worker, SIGNAL(finished()), controller.thread, SLOT(quit())); | ||||
|             connect(controller.worker, SIGNAL(finished()), controller.worker, SLOT(deleteLater())); | ||||
|             connect(controller.thread, SIGNAL(finished()), controller.thread, SLOT(deleteLater())); | ||||
|             connect(&controller.worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), controller.worker, SLOT(handleTest())); | ||||
|             connect(&controller.worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), controller.worker, SLOT(handleInputMessages())); | ||||
|             controller.thread->start(); | ||||
| 
 | ||||
|             m_controllers.push_back(controller); | ||||
| @ -202,7 +202,7 @@ void DVSerialEngine::release() | ||||
| 
 | ||||
|     while (it != m_controllers.end()) | ||||
|     { | ||||
|         disconnect(&it->worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), it->worker, SLOT(handleTest())); | ||||
|         disconnect(&it->worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), it->worker, SLOT(handleInputMessages())); | ||||
|         it->worker->stop(); | ||||
|         it->thread->wait(100); | ||||
|         it->worker->m_inputMessageQueue.clear(); | ||||
| @ -214,13 +214,23 @@ void DVSerialEngine::release() | ||||
|     m_controllers.clear(); | ||||
| } | ||||
| 
 | ||||
| void DVSerialEngine::push() | ||||
| void DVSerialEngine::pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo) | ||||
| { | ||||
|     std::vector<DVSerialController>::iterator it = m_controllers.begin(); | ||||
| 
 | ||||
|     while (it != m_controllers.end()) | ||||
|     { | ||||
|         it->worker->m_inputMessageQueue.push(DVSerialWorker::MsgTest::create()); | ||||
|         if (it->worker->m_inputMessageQueue.size() < 2) | ||||
|         { | ||||
|             it->worker->m_inputMessageQueue.push(DVSerialWorker::MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, audioFifo)); | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
|         ++it; | ||||
|     } | ||||
| 
 | ||||
|     if (it == m_controllers.end()) | ||||
|     { | ||||
|         qDebug("DVSerialEngine::pushMbeFrame: no DV serial device available. MBE frame dropped"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -38,7 +38,7 @@ public: | ||||
|     void release(); | ||||
| 
 | ||||
|     int getNbDevices() const { return m_controllers.size(); } | ||||
|     void push(); | ||||
|     void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo); | ||||
| 
 | ||||
| private: | ||||
|     struct DVSerialController | ||||
|  | ||||
| @ -63,7 +63,25 @@ void DVSerialWorker::stop() | ||||
|     m_running = false; | ||||
| } | ||||
| 
 | ||||
| void DVSerialWorker::handleTest() | ||||
| void DVSerialWorker::handleInputMessages() | ||||
| { | ||||
|     qDebug("DVSerialWorker::handleTest"); | ||||
|     Message* message; | ||||
| 
 | ||||
|     while ((message = m_inputMessageQueue.pop()) != 0) | ||||
|     { | ||||
|         qDebug("DVSerialWorker::handleInputMessages: message"); | ||||
| 
 | ||||
|         if (MsgMbeDecode::match(*message)) | ||||
|         { | ||||
|             MsgMbeDecode *decodeMsg = (MsgMbeDecode *) message; | ||||
|             int dBVolume = (decodeMsg->getVolumeIndex() - 50) / 5; | ||||
| 
 | ||||
|             if (m_dvController.decode(m_audioSamples, decodeMsg->getMbeFrame(), decodeMsg->getMbeRate(), dBVolume)) | ||||
|             { | ||||
|                 decodeMsg->getAudioFifo()->write((const quint8 *) m_audioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, 10); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         delete message; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -40,27 +40,6 @@ public: | ||||
|         MsgTest() {} | ||||
|     }; | ||||
| 
 | ||||
|     DVSerialWorker(); | ||||
|     ~DVSerialWorker(); | ||||
| 
 | ||||
|     bool open(const std::string& serialDevice); | ||||
|     void close(); | ||||
|     void process(); | ||||
|     void stop(); | ||||
| 
 | ||||
|     void postTest() | ||||
|     { | ||||
|         //emit inputMessageReady();
 | ||||
|         m_inputMessageQueue.push(MsgTest::create()); | ||||
|     } | ||||
| 
 | ||||
|     MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
 | ||||
| 
 | ||||
| signals: | ||||
|     void inputMessageReady(); | ||||
|     void finished(); | ||||
| 
 | ||||
| private: | ||||
|     class MsgMbeDecode : public Message | ||||
|     { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| @ -94,14 +73,35 @@ private: | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     DVSerialWorker(); | ||||
|     ~DVSerialWorker(); | ||||
| 
 | ||||
|     bool open(const std::string& serialDevice); | ||||
|     void close(); | ||||
|     void process(); | ||||
|     void stop(); | ||||
| 
 | ||||
|     void postTest() | ||||
|     { | ||||
|         //emit inputMessageReady();
 | ||||
|         m_inputMessageQueue.push(MsgTest::create()); | ||||
|     } | ||||
| 
 | ||||
|     MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
 | ||||
| 
 | ||||
| signals: | ||||
|     void inputMessageReady(); | ||||
|     void finished(); | ||||
| 
 | ||||
| public slots: | ||||
|     void handleInputMessages(); | ||||
| 
 | ||||
| private: | ||||
|     SerialDV::DVController m_dvController; | ||||
|     bool m_running; | ||||
|     int m_currentGainIn; | ||||
|     int m_currentGainOut; | ||||
|     short m_audioSamples[SerialDV::MBE_AUDIO_BLOCK_SIZE]; | ||||
| 
 | ||||
| private slots: | ||||
|     void handleTest(); | ||||
| }; | ||||
| 
 | ||||
| #endif /* SDRBASE_DSP_DVSERIALWORKER_H_ */ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user