mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Issue #81 patches from @dovandung
This commit is contained in:
parent
9b1f6d7b6d
commit
2a9eadbf9a
@ -18,6 +18,7 @@ public:
|
||||
int channels;
|
||||
float peak;
|
||||
std::vector<float> data;
|
||||
std::mutex busy_update;
|
||||
|
||||
AudioThreadInput() :
|
||||
frequency(0), sampleRate(0), channels(0), peak(0) {
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
long long frequency;
|
||||
long long sampleRate;
|
||||
std::vector<liquid_float_complex> data;
|
||||
std::mutex busy_rw;
|
||||
|
||||
DemodulatorThreadIQData() :
|
||||
frequency(0), sampleRate(0) {
|
||||
|
@ -310,6 +310,8 @@ void DemodulatorThread::threadMain() {
|
||||
|
||||
if (ati && audioVisOutputQueue != NULL && audioVisOutputQueue->empty()) {
|
||||
|
||||
ati_vis->busy_update.lock();
|
||||
|
||||
int num_vis = DEMOD_VIS_SIZE;
|
||||
if (stereo) {
|
||||
ati_vis->channels = 2;
|
||||
@ -342,6 +344,8 @@ void DemodulatorThread::threadMain() {
|
||||
// std::cout << "Signal: " << agc_crcf_get_signal_level(agc) << " -- " << agc_crcf_get_rssi(agc) << "dB " << std::endl;
|
||||
}
|
||||
|
||||
ati_vis->busy_update.unlock();
|
||||
|
||||
audioVisOutputQueue->push(ati_vis);
|
||||
}
|
||||
if (!threadQueueControl->empty()) {
|
||||
|
@ -111,6 +111,9 @@ void SDRPostThread::threadMain() {
|
||||
}
|
||||
|
||||
if (iqVisualQueue.load() != NULL && iqVisualQueue.load()->empty()) {
|
||||
|
||||
visualDataOut->busy_rw.lock();
|
||||
|
||||
if (visualDataOut->data.size() < num_vis_samples) {
|
||||
if (visualDataOut->data.capacity() < num_vis_samples) {
|
||||
visualDataOut->data.reserve(num_vis_samples);
|
||||
@ -121,6 +124,9 @@ void SDRPostThread::threadMain() {
|
||||
visualDataOut->frequency = data_in->frequency;
|
||||
visualDataOut->sampleRate = data_in->sampleRate;
|
||||
visualDataOut->data.assign(dataOut.begin(), dataOut.begin() + num_vis_samples);
|
||||
|
||||
visualDataOut->busy_rw.unlock();
|
||||
|
||||
iqVisualQueue.load()->push(visualDataOut);
|
||||
}
|
||||
|
||||
|
@ -61,16 +61,21 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
if (!wxGetApp().getAudioVisualQueue()->empty()) {
|
||||
AudioThreadInput *demodAudioData;
|
||||
wxGetApp().getAudioVisualQueue()->pop(demodAudioData);
|
||||
if (demodAudioData && demodAudioData->data.size()) {
|
||||
if (waveform_points.size() != demodAudioData->data.size() * 2) {
|
||||
waveform_points.resize(demodAudioData->data.size() * 2);
|
||||
int iMax = demodAudioData->data.size();
|
||||
if (demodAudioData && iMax) {
|
||||
if (waveform_points.size() != iMax * 2) {
|
||||
waveform_points.resize(iMax * 2);
|
||||
}
|
||||
|
||||
for (int i = 0, iMax = demodAudioData->data.size(); i < iMax; i++) {
|
||||
demodAudioData->busy_update.lock();
|
||||
|
||||
for (int i = 0; i < iMax; i++) {
|
||||
waveform_points[i * 2 + 1] = demodAudioData->data[i] * 0.5f;
|
||||
waveform_points[i * 2] = ((double) i / (double) iMax);
|
||||
}
|
||||
|
||||
demodAudioData->busy_update.unlock();
|
||||
|
||||
setStereo(demodAudioData->channels == 2);
|
||||
} else {
|
||||
std::cout << "Incoming Demodulator data empty?" << std::endl;
|
||||
|
@ -110,6 +110,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
DemodulatorThreadIQData *iqData;
|
||||
wxGetApp().getIQVisualQueue()->pop(iqData);
|
||||
|
||||
iqData->busy_rw.lock();
|
||||
|
||||
if (iqData && iqData->data.size()) {
|
||||
setData(iqData);
|
||||
if (otherWaterfallCanvas) {
|
||||
@ -118,6 +120,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
} else {
|
||||
std::cout << "Incoming IQ data empty?" << std::endl;
|
||||
}
|
||||
|
||||
iqData->busy_rw.unlock();
|
||||
}
|
||||
|
||||
glContext->SetCurrent(*this);
|
||||
|
Loading…
Reference in New Issue
Block a user