Issue #81 patches from @dovandung

This commit is contained in:
Charles J. Cliffe 2015-05-27 23:22:19 -04:00
parent 9b1f6d7b6d
commit 2a9eadbf9a
6 changed files with 25 additions and 4 deletions

View File

@ -18,6 +18,7 @@ public:
int channels; int channels;
float peak; float peak;
std::vector<float> data; std::vector<float> data;
std::mutex busy_update;
AudioThreadInput() : AudioThreadInput() :
frequency(0), sampleRate(0), channels(0), peak(0) { frequency(0), sampleRate(0), channels(0), peak(0) {

View File

@ -61,6 +61,7 @@ public:
long long frequency; long long frequency;
long long sampleRate; long long sampleRate;
std::vector<liquid_float_complex> data; std::vector<liquid_float_complex> data;
std::mutex busy_rw;
DemodulatorThreadIQData() : DemodulatorThreadIQData() :
frequency(0), sampleRate(0) { frequency(0), sampleRate(0) {

View File

@ -310,6 +310,8 @@ void DemodulatorThread::threadMain() {
if (ati && audioVisOutputQueue != NULL && audioVisOutputQueue->empty()) { if (ati && audioVisOutputQueue != NULL && audioVisOutputQueue->empty()) {
ati_vis->busy_update.lock();
int num_vis = DEMOD_VIS_SIZE; int num_vis = DEMOD_VIS_SIZE;
if (stereo) { if (stereo) {
ati_vis->channels = 2; 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; // 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); audioVisOutputQueue->push(ati_vis);
} }
if (!threadQueueControl->empty()) { if (!threadQueueControl->empty()) {

View File

@ -111,6 +111,9 @@ void SDRPostThread::threadMain() {
} }
if (iqVisualQueue.load() != NULL && iqVisualQueue.load()->empty()) { if (iqVisualQueue.load() != NULL && iqVisualQueue.load()->empty()) {
visualDataOut->busy_rw.lock();
if (visualDataOut->data.size() < num_vis_samples) { if (visualDataOut->data.size() < num_vis_samples) {
if (visualDataOut->data.capacity() < num_vis_samples) { if (visualDataOut->data.capacity() < num_vis_samples) {
visualDataOut->data.reserve(num_vis_samples); visualDataOut->data.reserve(num_vis_samples);
@ -121,6 +124,9 @@ void SDRPostThread::threadMain() {
visualDataOut->frequency = data_in->frequency; visualDataOut->frequency = data_in->frequency;
visualDataOut->sampleRate = data_in->sampleRate; visualDataOut->sampleRate = data_in->sampleRate;
visualDataOut->data.assign(dataOut.begin(), dataOut.begin() + num_vis_samples); visualDataOut->data.assign(dataOut.begin(), dataOut.begin() + num_vis_samples);
visualDataOut->busy_rw.unlock();
iqVisualQueue.load()->push(visualDataOut); iqVisualQueue.load()->push(visualDataOut);
} }

View File

@ -61,16 +61,21 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
if (!wxGetApp().getAudioVisualQueue()->empty()) { if (!wxGetApp().getAudioVisualQueue()->empty()) {
AudioThreadInput *demodAudioData; AudioThreadInput *demodAudioData;
wxGetApp().getAudioVisualQueue()->pop(demodAudioData); wxGetApp().getAudioVisualQueue()->pop(demodAudioData);
if (demodAudioData && demodAudioData->data.size()) { int iMax = demodAudioData->data.size();
if (waveform_points.size() != demodAudioData->data.size() * 2) { if (demodAudioData && iMax) {
waveform_points.resize(demodAudioData->data.size() * 2); 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 + 1] = demodAudioData->data[i] * 0.5f;
waveform_points[i * 2] = ((double) i / (double) iMax); waveform_points[i * 2] = ((double) i / (double) iMax);
} }
demodAudioData->busy_update.unlock();
setStereo(demodAudioData->channels == 2); setStereo(demodAudioData->channels == 2);
} else { } else {
std::cout << "Incoming Demodulator data empty?" << std::endl; std::cout << "Incoming Demodulator data empty?" << std::endl;

View File

@ -110,6 +110,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
DemodulatorThreadIQData *iqData; DemodulatorThreadIQData *iqData;
wxGetApp().getIQVisualQueue()->pop(iqData); wxGetApp().getIQVisualQueue()->pop(iqData);
iqData->busy_rw.lock();
if (iqData && iqData->data.size()) { if (iqData && iqData->data.size()) {
setData(iqData); setData(iqData);
if (otherWaterfallCanvas) { if (otherWaterfallCanvas) {
@ -118,6 +120,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} else { } else {
std::cout << "Incoming IQ data empty?" << std::endl; std::cout << "Incoming IQ data empty?" << std::endl;
} }
iqData->busy_rw.unlock();
} }
glContext->SetCurrent(*this); glContext->SetCurrent(*this);