Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,16 +30,62 @@ | |
#ifndef __VIRTUAL_INPUT | ||
#define __VIRTUAL_INPUT | ||
|
||
#include <memory> | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
#include "dab-constants.h" | ||
#include "radio-controller.h" | ||
#include "ringbuffer.h" | ||
|
||
enum class CDeviceID { | ||
UNKNOWN, NULLDEVICE, AIRSPY, RAWFILE, RTL_SDR, RTL_TCP, SOAPYSDR}; | ||
|
||
class CVirtualInput : public InputInterface { | ||
public: | ||
virtual ~CVirtualInput() {} | ||
virtual CDeviceID getID(void) = 0; | ||
public: | ||
virtual ~CVirtualInput() {} | ||
virtual CDeviceID getID(void) = 0; | ||
|
||
void writeRecordBufferToFile(std::string &fileanme) { | ||
if(!recordBuffer) | ||
return; | ||
|
||
std::ofstream rawStream(fileanme, std::ios::binary); | ||
int test = recordBuffer->GetRingBufferReadAvailable(); | ||
|
||
while(recordBuffer->GetRingBufferReadAvailable() > 0) { | ||
size_t data_tmpSize = 0; | ||
if(recordBuffer->GetRingBufferReadAvailable() > 1024) | ||
data_tmpSize = 1024; | ||
else | ||
data_tmpSize = static_cast<size_t>(recordBuffer->GetRingBufferReadAvailable()); | ||
|
||
uint8_t data_tmp[data_tmpSize]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gvanem
Contributor
|
||
recordBuffer->getDataFromBuffer(data_tmp, data_tmpSize); | ||
rawStream.write((char *) data_tmp, data_tmpSize); | ||
} | ||
rawStream.close(); | ||
} | ||
|
||
void initRecordBuffer(uint32_t size) { | ||
// The ring buffer size has to be power of 2 | ||
uint32_t bitCount = ceil(log2(size)); | ||
uint32_t bufferSize = pow(2, bitCount); | ||
|
||
recordBuffer.reset(new RingBuffer<uint8_t>(bufferSize)); | ||
} | ||
|
||
protected: | ||
void putIntoRecordBuffer(uint8_t &data, uint32_t size) { | ||
if(!recordBuffer) | ||
return; | ||
|
||
recordBuffer->putDataIntoBuffer(&data, static_cast<int>(size)); | ||
std::clog << "CVirtualInput: GetRingBufferReadAvailable() " << recordBuffer->GetRingBufferReadAvailable() << std::endl; | ||
} | ||
|
||
private: | ||
std::unique_ptr<RingBuffer<uint8_t>> recordBuffer; | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Controls 2.3 | ||
import QtQuick.Layouts 1.1 | ||
|
||
|
||
// Import custom styles | ||
import "../texts" | ||
import "../components" | ||
|
||
ViewBaseFrame { | ||
labelText: qsTr("I/Q RAW Recorder (experimental)") | ||
|
||
property bool isStart: false | ||
property int ringeBufferSize: 0 | ||
|
||
content: ColumnLayout { | ||
RowLayout { | ||
TextStandart { | ||
text: qsTr("Ring buffer length [s]") | ||
} | ||
|
||
WTumbler { | ||
id: ringeBufferSetting | ||
model: [5, 10, 60, 120, 240] | ||
} | ||
|
||
WButton { | ||
text: isStart ? qsTr("Save ringe buffer") : qsTr("Init") | ||
|
||
onPressed: { | ||
ringeBufferSize = parseInt(ringeBufferSetting.currentItem.text) * 2048 * 1024 | ||
|
||
if(!isStart) | ||
radioController.initRecorder(ringeBufferSize) | ||
else | ||
radioController.triggerRecorder("") | ||
|
||
isStart = !isStart | ||
} | ||
} | ||
} | ||
|
||
TextStandart { | ||
text: "Ringe buffer size [MB]: " + (ringeBufferSize / 1000000) | ||
} | ||
} | ||
} |
I get a stack-overflow here when pressing the Save ring buffer button. Can we be certain that the elementType is
uint8_t
for all uses of theIQRingBuffer
?