From 08602c661bae4fb0493023a5f32fd4daec84cd66 Mon Sep 17 00:00:00 2001 From: Ziga S Date: Wed, 29 Jun 2016 10:00:38 +0200 Subject: [PATCH] Updated CMake files for QTEditor cmake style. AudioOutput had previously stalled, mutex temporary removed(Q&D workaround, need for study OSX Audio Concurency). Removed some part of code in DemodBFM for OSX compilations. Code runs and was tested with HackRF. Note: There is need have investigate two potencial problems(DemodBFM bug and AudioOutput deadlocking?). --- CMakeLists.txt | 5 +---- fcdhid/CMakeLists.txt | 2 +- plugins/channel/demodbfm/CMakeLists.txt | 2 +- plugins/channel/demodbfm/rdsparser.cpp | 14 ++++++++++---- plugins/samplesource/hackrf/CMakeLists.txt | 2 +- sdrbase/audio/audiooutput.cpp | 13 ++++++++----- sdrbase/dsp/phaselock.cpp | 4 ++-- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d18226e65..76127f8c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,10 +61,7 @@ ENDIF() # MacOS Compatibility if(APPLE) - find_package(ICONV) - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") - + find_package(ICONV) endif(APPLE) ############################################################################## diff --git a/fcdhid/CMakeLists.txt b/fcdhid/CMakeLists.txt index 145f1f7d5..df44433ac 100644 --- a/fcdhid/CMakeLists.txt +++ b/fcdhid/CMakeLists.txt @@ -30,4 +30,4 @@ target_link_libraries(fcdhid ${ICONV_LIBRARY} ) -install(TARGETS fcdhid DESTINATION lib) \ No newline at end of file +install(TARGETS fcdhid DESTINATION lib) diff --git a/plugins/channel/demodbfm/CMakeLists.txt b/plugins/channel/demodbfm/CMakeLists.txt index 09899dc17..d509a8321 100644 --- a/plugins/channel/demodbfm/CMakeLists.txt +++ b/plugins/channel/demodbfm/CMakeLists.txt @@ -49,4 +49,4 @@ target_link_libraries(demodbfm qt5_use_modules(demodbfm Core Widgets OpenGL Multimedia) -install(TARGETS demodbfm DESTINATION lib/plugins/channel) \ No newline at end of file +install(TARGETS demodbfm DESTINATION lib/plugins/channel) diff --git a/plugins/channel/demodbfm/rdsparser.cpp b/plugins/channel/demodbfm/rdsparser.cpp index 89af931de..54c7705f6 100644 --- a/plugins/channel/demodbfm/rdsparser.cpp +++ b/plugins/channel/demodbfm/rdsparser.cpp @@ -526,15 +526,21 @@ void RDSParser::decode_type0(unsigned int *group, bool B) if (af_1) { - std::pair, bool> res = m_g0_alt_freq.insert(af_1/1e3); - m_g0_af_updated = m_g0_af_updated || res.second; + // @TODO: Find proper header or STL on OSX +#ifndef __APPLE__ + std::pair, bool> res = m_g0_alt_freq.insert(af_1/1e3); + m_g0_af_updated = m_g0_af_updated || res.second; +#endif no_af += 1; } if (af_2) { - std::pair, bool> res = m_g0_alt_freq.insert(af_2/1e3); - m_g0_af_updated = m_g0_af_updated || res.second; + // @TODO: Find proper header or STL on OSX +#ifndef __APPLE__ + std::pair, bool> res = m_g0_alt_freq.insert(af_2/1e3); + m_g0_af_updated = m_g0_af_updated || res.second; +#endif no_af += 2; } diff --git a/plugins/samplesource/hackrf/CMakeLists.txt b/plugins/samplesource/hackrf/CMakeLists.txt index bcc4ca783..bc47b71db 100644 --- a/plugins/samplesource/hackrf/CMakeLists.txt +++ b/plugins/samplesource/hackrf/CMakeLists.txt @@ -21,7 +21,7 @@ set(hackrf_FORMS ) include_directories( - . + . ${CMAKE_CURRENT_BINARY_DIR} ${LIBHACKRF_INCLUDE_DIR} ) diff --git a/sdrbase/audio/audiooutput.cpp b/sdrbase/audio/audiooutput.cpp index ce435f068..13bb3d97f 100644 --- a/sdrbase/audio/audiooutput.cpp +++ b/sdrbase/audio/audiooutput.cpp @@ -150,8 +150,12 @@ bool AudioOutput::open(OpenMode mode) qint64 AudioOutput::readData(char* data, qint64 maxLen) { - //qDebug("AudioOutput::readData: %lld", maxLen); - QMutexLocker mutexLocker(&m_mutex); + //qDebug("AudioOutput::readData: %lld", maxLen); + + // @TODO: Study this mutex on OSX, for now deadlocks possible +#ifndef __APPLE__ + QMutexLocker mutexLocker(&m_mutex); +#endif unsigned int framesPerBuffer = maxLen / 4; @@ -183,7 +187,7 @@ qint64 AudioOutput::readData(char* data, qint64 maxLen) if (samples != framesPerBuffer) { - //qDebug("AudioOutput::readData: read %d samples vs %d requested", samples, framesPerBuffer); + qDebug("AudioOutput::readData: read %d samples vs %d requested", samples, framesPerBuffer); } for (uint i = 0; i < samples; i++) @@ -195,8 +199,7 @@ qint64 AudioOutput::readData(char* data, qint64 maxLen) ++src; ++dst; } - } - + } // convert to int16 //std::vector::const_iterator src = m_mixBuffer.begin(); // Valgrind optim diff --git a/sdrbase/dsp/phaselock.cpp b/sdrbase/dsp/phaselock.cpp index 173e7c8f8..8c214f71c 100644 --- a/sdrbase/dsp/phaselock.cpp +++ b/sdrbase/dsp/phaselock.cpp @@ -182,7 +182,7 @@ void PhaseLock::process(const std::vector& samples_in, std::vector& // Convert I/Q ratio to estimate of phase error. Real phase_err; - if (phasor_i > abs(phasor_q)) { + if (phasor_i > std::abs(phasor_q)) { // We are within +/- 45 degrees from lock. // Use simple linear approximation of arctan. phase_err = phasor_q / phasor_i; @@ -278,7 +278,7 @@ void PhaseLock::process(const Real& sample_in, Real *samples_out) // Convert I/Q ratio to estimate of phase error. Real phase_err; - if (phasor_i > abs(phasor_q)) { + if (phasor_i > std::abs(phasor_q)) { // We are within +/- 45 degrees from lock. // Use simple linear approximation of arctan. phase_err = phasor_q / phasor_i;