From 64169bc168b22bd1086d9e1868c82d9cc161d178 Mon Sep 17 00:00:00 2001
From: f4exb <f4exb06@gmail.com>
Date: Mon, 12 Nov 2018 17:22:19 +0100
Subject: [PATCH] Windows: MSVC2017: changes in sdrbase (3) serialdv

---
 exports/export.h               | 12 ++++++++++++
 sdrbase/dsp/dvserialengine.cpp |  6 ++++--
 sdrbase/dsp/dvserialworker.cpp |  5 +++--
 sdrbase/sdrbase.pro            |  5 +++--
 serialdv/serialdv.pro          |  4 ++++
 5 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/exports/export.h b/exports/export.h
index 10b79fea5..cda4f61f8 100644
--- a/exports/export.h
+++ b/exports/export.h
@@ -102,6 +102,18 @@
 #  define QRTPLIB_API
 #endif
 
+/* the 'SERIALDV_API' controls the import/export of 'serialdv' symbols
+ */
+#if !defined(sdrangel_STATIC)
+#  ifdef serialdv_EXPORTS
+#    define SERIALDV_API __SDR_EXPORT
+#  else
+#    define SERIALDV_API __SDR_IMPORT
+#  endif
+#else
+#  define SERIALDV_API
+#endif
+
 /* the 'SWG_API' controls the import/export of 'swagger' symbols
  */
 #if !defined(sdrangel_STATIC)
diff --git a/sdrbase/dsp/dvserialengine.cpp b/sdrbase/dsp/dvserialengine.cpp
index ddb4370b9..5aba10314 100644
--- a/sdrbase/dsp/dvserialengine.cpp
+++ b/sdrbase/dsp/dvserialengine.cpp
@@ -16,14 +16,16 @@
 ///////////////////////////////////////////////////////////////////////////////////
 
 #include <stdlib.h>
-#include <dirent.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
+#ifndef _MSC_VER
+#include <dirent.h>
+#include <unistd.h>
 #include <libgen.h>
+#endif
 
 #ifndef __WINDOWS__
 #include <termios.h>
diff --git a/sdrbase/dsp/dvserialworker.cpp b/sdrbase/dsp/dvserialworker.cpp
index e72f0f5db..cc5f04b56 100644
--- a/sdrbase/dsp/dvserialworker.cpp
+++ b/sdrbase/dsp/dvserialworker.cpp
@@ -15,7 +15,8 @@
 // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 ///////////////////////////////////////////////////////////////////////////////////
 
-#include <unistd.h>
+#include <chrono>
+#include <thread>
 
 #include "dsp/dvserialworker.h"
 #include "audio/audiofifo.h"
@@ -60,7 +61,7 @@ void DVSerialWorker::process()
 
     while (m_running)
     {
-        sleep(1);
+        std::this_thread::sleep_for(std::chrono::seconds(1));
     }
 
     qDebug("DVSerialWorker::process: stopped");
diff --git a/sdrbase/sdrbase.pro b/sdrbase/sdrbase.pro
index 1dd573aeb..2cb0d17e4 100644
--- a/sdrbase/sdrbase.pro
+++ b/sdrbase/sdrbase.pro
@@ -40,10 +40,11 @@ CONFIG(MSVC):INCLUDEPATH += "C:\softs\boost_1_66_0"
 
 CONFIG(MINGW32):INCLUDEPATH += "C:\softs\serialDV"
 CONFIG(MINGW64):INCLUDEPATH += "C:\softs\serialDV"
+CONFIG(MSVC):INCLUDEPATH += "C:\softs\serialDV"
 
 CONFIG(macx):INCLUDEPATH += "../../../boost_1_64_0"
 
-MINGW32 || MINGW64 {
+MINGW32 || MINGW64 || MSVC {
     HEADERS += \
         dsp/dvserialengine.h \
         dsp/dvserialworker.h
@@ -224,7 +225,7 @@ HEADERS  += audio/audiodevicemanager.h\
         webapi/webapiserver.h\
         mainparser.h
 
-MINGW32 || MINGW64 {
+MINGW32 || MINGW64 || MSVC {
     LIBS += -L../serialdv/$${build_subdir} -lserialdv
 }
 LIBS += -L../httpserver/$${build_subdir} -lhttpserver
diff --git a/serialdv/serialdv.pro b/serialdv/serialdv.pro
index e1b141383..48b7a38c9 100644
--- a/serialdv/serialdv.pro
+++ b/serialdv/serialdv.pro
@@ -9,10 +9,14 @@ QT += core
 TEMPLATE = lib
 TARGET = serialdv
 
+CONFIG(MSVC):DEFINES += serialdv_EXPORTS
+
 CONFIG(MINGW32):LIBSERIALDVSRC = "C:\softs\serialDV"
 CONFIG(MINGW64):LIBSERIALDVSRC = "C:\softs\serialDV"
+CONFIG(MSVC):LIBSERIALDVSRC = "C:\softs\serialDV"
 
 INCLUDEPATH += $$LIBSERIALDVSRC
+INCLUDEPATH += ../exports
 
 DEFINES += __WINDOWS__=1