Skip to content

Commit

Permalink
remove pthread
Browse files Browse the repository at this point in the history
  • Loading branch information
jocover committed Jul 13, 2015
1 parent d605768 commit 6cf5f62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
31 changes: 7 additions & 24 deletions ExtIO_Hackrf/ExtIO_HackRF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
#include <commctrl.h>
#include <stdio.h>
#include <hackrf.h>
#include <time.h>
#include <new>
#include <pthread.h>
#include <TCHAR.h>


//---------------------------------------------------------------------------
#define EXTIO_EXPORTS 1
#define HWNAME "ExtIO HackRF"

typedef long clock_t;
static hackrf_device *device;
HWND h_dialog = NULL;
int result;
Expand Down Expand Up @@ -52,7 +52,7 @@ volatile int64_t glLOfreq = 101700000L;//Default 101.7Mhz
volatile bool gbStartHW = false;
volatile bool gbExit = false;
int amp = 0;
pthread_t bandwidth_thread;
HANDLE bandwidth_thread;
clock_t time_start, time_now;
volatile uint32_t byte_count = 0;
unsigned int lna_gain = 16, vga_gain = 8;
Expand Down Expand Up @@ -86,7 +86,7 @@ int hackrf_rx_callback(hackrf_transfer* transfer){
}


static void* usb_bandwidth(void* arg){
DWORD WINAPI usb_bandwidth(void* arg){
while (!gbExit){
uint32_t byte_count_now;
float rate;
Expand Down Expand Up @@ -145,29 +145,11 @@ BOOL APIENTRY DllMain(HMODULE hModule,
{
case DLL_PROCESS_ATTACH:
hInst = hModule;
#if PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
case DLL_THREAD_ATTACH:
#if PTW32_STATIC_LIB
pthread_win32_thread_attach_np();
#endif
break;

case DLL_THREAD_DETACH:
#if PTW32_STATIC_LIB
pthread_win32_thread_detach_np();
#endif
break;

case DLL_PROCESS_DETACH:
#if PTW32_STATIC_LIB
pthread_win32_thread_detach_np();
pthread_win32_process_detach_np();
#endif
break;


}
return TRUE;
}
Expand Down Expand Up @@ -347,8 +329,8 @@ bool EXTIO_API OpenHW(void)
return FALSE;
}
while (!hackrf_is_streaming(device));
pthread_create(&bandwidth_thread, NULL, usb_bandwidth, NULL);

// pthread_create(&bandwidth_thread, NULL, usb_bandwidth, NULL);
bandwidth_thread=CreateThread(NULL, 0, usb_bandwidth, NULL, 0, 0);
return TRUE;
}
//
Expand Down Expand Up @@ -429,6 +411,7 @@ extern "C"
void EXTIO_API CloseHW(void)
{
gbExit = true;
CloseHandle(bandwidth_thread);
if (device != NULL){
hackrf_close(device);
hackrf_exit();
Expand Down
9 changes: 5 additions & 4 deletions ExtIO_Hackrf/ExtIO_HackRF.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;EXTIO_EXPORTS;PTW32_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;EXTIO_EXPORTS;1PTW32_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
Expand All @@ -100,8 +100,9 @@
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>libusb-1.0.lib;pthread_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMTD.lib</IgnoreSpecificDefaultLibraries>
<AdditionalDependencies>libusb-1.0.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 6cf5f62

Please sign in to comment.