From 9d18a9a1e9033dcf16fddd3183510643737986d9 Mon Sep 17 00:00:00 2001 From: John Greb Date: Tue, 2 Dec 2014 16:57:42 +0000 Subject: [PATCH] Race condition. --- plugins/samplesource/fcd/fcdinput.cpp | 4 ++-- plugins/samplesource/fcd/fcdsource.cpp | 22 +++++++++++++++------- plugins/samplesource/fcd/fcdthread.cpp | 1 + plugins/samplesource/fcd/fcdthread.h | 2 +- plugins/samplesource/v4l/v4linput.cpp | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/plugins/samplesource/fcd/fcdinput.cpp b/plugins/samplesource/fcd/fcdinput.cpp index 6d0fc1545..c77aaf25f 100644 --- a/plugins/samplesource/fcd/fcdinput.cpp +++ b/plugins/samplesource/fcd/fcdinput.cpp @@ -93,8 +93,8 @@ bool FCDInput::startInput(int device) m_deviceDescription = QString("Funcube Dongle"); - if (!applySettings(m_generalSettings, m_settings, true)) - qCritical("FCD: Unable to set config at start"); +// if (!applySettings(m_generalSettings, m_settings, true)) +// qCritical("FCD: Unable to set config at start"); qDebug("FCDInput: start"); return true; diff --git a/plugins/samplesource/fcd/fcdsource.cpp b/plugins/samplesource/fcd/fcdsource.cpp index 72937163c..98b93db31 100644 --- a/plugins/samplesource/fcd/fcdsource.cpp +++ b/plugins/samplesource/fcd/fcdsource.cpp @@ -15,6 +15,7 @@ bool FCDThread::OpenSource(const char* cardname) { + bool fail = false; snd_pcm_hw_params_t* params; //fcd_rate = FCDPP_RATE; //fcd_channels =2; @@ -28,14 +29,21 @@ bool FCDThread::OpenSource(const char* cardname) snd_pcm_hw_params_alloca(¶ms); if ( snd_pcm_hw_params_any(fcd_handle, params) < 0 ) - qCritical("Funcube Dongle read settings failed"); - else if ( snd_pcm_hw_params(fcd_handle, params) < 0 ) - qCritical("Funcube Dongle write settings failed"); - // TODO: check actual samplerate, may be crippled firmware - - if ( snd_pcm_start(fcd_handle) < 0 ) + fail = true; + else if ( snd_pcm_hw_params(fcd_handle, params) < 0 ) { + fail = true; + // TODO: check actual samplerate, may be crippled firmware + } else { + if ( snd_pcm_start(fcd_handle) < 0 ) + fail = true; + } + if (fail) { qCritical("Funcube Dongle stream start failed"); - else qDebug("Funcube stream started"); + snd_pcm_close( fcd_handle ); + return false; + } else { + qDebug("Funcube stream started"); + } return true; } diff --git a/plugins/samplesource/fcd/fcdthread.cpp b/plugins/samplesource/fcd/fcdthread.cpp index 289b0e575..13cbd793e 100644 --- a/plugins/samplesource/fcd/fcdthread.cpp +++ b/plugins/samplesource/fcd/fcdthread.cpp @@ -22,6 +22,7 @@ FCDThread::FCDThread(SampleFifo* sampleFifo, QObject* parent) : QThread(parent), + fcd_handle(NULL), m_running(false), m_convertBuffer(BLOCKSIZE), m_sampleFifo(sampleFifo) diff --git a/plugins/samplesource/fcd/fcdthread.h b/plugins/samplesource/fcd/fcdthread.h index 743ffb127..d67bb9972 100644 --- a/plugins/samplesource/fcd/fcdthread.h +++ b/plugins/samplesource/fcd/fcdthread.h @@ -44,7 +44,7 @@ public: int work(int n_items); private: snd_pcm_format_t fcd_format; - snd_pcm_t* fcd_handle = NULL; + snd_pcm_t* fcd_handle; QMutex m_startWaitMutex; QWaitCondition m_startWaiter; diff --git a/plugins/samplesource/v4l/v4linput.cpp b/plugins/samplesource/v4l/v4linput.cpp index 0741eca5a..0d51a79f0 100644 --- a/plugins/samplesource/v4l/v4linput.cpp +++ b/plugins/samplesource/v4l/v4linput.cpp @@ -96,7 +96,7 @@ bool V4LInput::startInput(int device) qDebug("V4LInput: start"); MsgReportV4L::create(m_gains)->submit(m_guiMessageQueue); - applySettings(m_generalSettings, m_settings, true); +// applySettings(m_generalSettings, m_settings, true); return true; }