kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Remove fl_thread wrappers
rodzic
667f672480
commit
e944abb6b4
|
|
@ -22,7 +22,7 @@ using namespace std;
|
|||
FSEL* FSEL::inst = 0;
|
||||
static std::string filename;
|
||||
#if FSEL_THREAD
|
||||
static Fl_Thread fsel_thread;
|
||||
static pthread_t fsel_thread;
|
||||
sem_t fsel_sem;
|
||||
#endif
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ const char* FSEL::get_file(void)
|
|||
#endif
|
||||
|
||||
#if FSEL_THREAD
|
||||
if (fl_create_thread(fsel_thread, thread_func, this) != 0) {
|
||||
if (pthread_create(&fsel_thread, NULL, thread_func, this) != 0) {
|
||||
fl_alert("%s", "could not create file selector thread");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include "threads.h"
|
||||
#include "complex.h"
|
||||
|
||||
class Digiscope : public Fl_Widget {
|
||||
|
|
@ -61,7 +60,7 @@ public:
|
|||
DOMWF,
|
||||
BLANK
|
||||
};
|
||||
Fl_Mutex *mutex;
|
||||
|
||||
private:
|
||||
scope_mode _mode;
|
||||
double _buf[MAX_LEN];
|
||||
|
|
|
|||
|
|
@ -66,15 +66,15 @@ private:
|
|||
struct fsignal
|
||||
{
|
||||
typedef void result_type;
|
||||
Fl_Mutex *m;
|
||||
Fl_Cond *c;
|
||||
pthread_mutex_t* m;
|
||||
pthread_cond_t* c;
|
||||
|
||||
fsignal(Fl_Mutex *m_, Fl_Cond *c_) : m(m_), c(c_) { }
|
||||
fsignal(pthread_mutex_t* m_, pthread_cond_t* c_) : m(m_), c(c_) { }
|
||||
void operator()(void) const
|
||||
{
|
||||
fl_lock(m);
|
||||
fl_cond_signal(c);
|
||||
fl_unlock(m);
|
||||
pthread_mutex_lock(m);
|
||||
pthread_cond_signal(c);
|
||||
pthread_mutex_unlock(m);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -123,17 +123,17 @@ public:
|
|||
break;
|
||||
sched_yield();
|
||||
}
|
||||
Fl_Mutex m = PTHREAD_MUTEX_INITIALIZER;
|
||||
Fl_Cond c = PTHREAD_COND_INITIALIZER;
|
||||
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t c = PTHREAD_COND_INITIALIZER;
|
||||
fsignal s(&m, &c);
|
||||
fl_lock(&m);
|
||||
pthread_mutex_lock(&m);
|
||||
for (;;) {
|
||||
if (request(s))
|
||||
break;
|
||||
sched_yield();
|
||||
}
|
||||
fl_cond_wait(&c, &m);
|
||||
fl_unlock(&m);
|
||||
pthread_cond_wait(&c, &m);
|
||||
pthread_mutex_unlock(&m);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,66 +1,10 @@
|
|||
//
|
||||
// "$Id: threads.h 4748 2006-01-15 02:26:54Z mike $"
|
||||
//
|
||||
// Simple threading API for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2006 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// Inline classes to provide portable support for threads and mutexes.
|
||||
//
|
||||
// FLTK does not use this (it has an internal mutex implementation
|
||||
// that is used if Fl::lock() is called). This header file's only
|
||||
// purpose is so we can write portable demo programs. It may be useful
|
||||
// or an inspiration to people who want to try writing multithreaded
|
||||
// programs themselves.
|
||||
//
|
||||
// FLTK has no multithreaded support unless the main thread calls Fl::lock().
|
||||
// This main thread is the only thread allowed to call Fl::run() or Fl::wait().
|
||||
// From then on FLTK will be locked except when the main thread is actually
|
||||
// waiting for events from the user. Other threads must call Fl::lock() and
|
||||
// Fl::unlock() to surround calls to FLTK (such as to change widgets or
|
||||
// redraw them).
|
||||
|
||||
#ifndef Threads_H
|
||||
# define Threads_H
|
||||
#ifndef THREADS_H_
|
||||
#define THREADS_H_
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_t Fl_Thread;
|
||||
typedef pthread_mutex_t Fl_Mutex;
|
||||
typedef pthread_cond_t Fl_Cond;
|
||||
|
||||
extern int fl_create_thread(Fl_Thread & t, void *(*f)(void *), void* p);
|
||||
extern int fl_mutex_init(Fl_Mutex * m);
|
||||
extern int fl_cond_init(Fl_Cond * c);
|
||||
extern int fl_cond_wait(Fl_Cond *c, Fl_Mutex *m);
|
||||
extern int fl_cond_signal(Fl_Cond *c);
|
||||
extern int fl_cond_bcast(Fl_Cond *c);
|
||||
extern int fl_lock(Fl_Mutex *m);
|
||||
extern int fl_unlock(Fl_Mutex *m);
|
||||
extern int fl_join(Fl_Thread t);
|
||||
|
||||
#include <semaphore.h>
|
||||
#if !HAVE_SEM_TIMEDWAIT
|
||||
# include <time.h>
|
||||
|
|
@ -71,30 +15,28 @@ int sem_timedwait_rel(sem_t* sem, double rel_timeout);
|
|||
int pthread_cond_timedwait_rel(pthread_cond_t* cond, pthread_mutex_t* mutex, double rel_timeout);
|
||||
|
||||
// 3 threads use qrunner
|
||||
enum { UNKNOWN_TID = -1, TRX_TID, QRZ_TID, RIGCTL_TID,
|
||||
enum { UNKNOWN_TID = -1, TRX_TID, QRZ_TID, RIGCTL_TID,
|
||||
#if USE_XMLRPC
|
||||
XMLRPC_TID,
|
||||
#endif
|
||||
ARQ_TID, ARQSOCKET_TID,
|
||||
FLMAIN_TID, NUM_THREADS,
|
||||
FLMAIN_TID, NUM_THREADS,
|
||||
NUM_QRUNNER_THREADS = NUM_THREADS - 1 };
|
||||
|
||||
#if USE_TLS
|
||||
extern __thread int thread_id_;
|
||||
# define THREAD_ID_TYPE __thread int
|
||||
# define CREATE_THREAD_ID() thread_id_ = UNKNOWN_TID
|
||||
# define SET_THREAD_ID(x) thread_id_ = (x)
|
||||
# define GET_THREAD_ID() thread_id_
|
||||
#else
|
||||
extern pthread_key_t thread_id_;
|
||||
# define THREAD_ID_TYPE pthread_key_t
|
||||
# define CREATE_THREAD_ID() pthread_key_create(&thread_id_, 0);
|
||||
# define SET_THREAD_ID(x) pthread_setspecific(thread_id_, (void *)(x))
|
||||
# define GET_THREAD_ID() (int)pthread_getspecific(thread_id_)
|
||||
#endif // USE_TLS
|
||||
|
||||
extern THREAD_ID_TYPE thread_id_;
|
||||
|
||||
#include "fl_lock.h"
|
||||
|
||||
#endif // !Threads_h
|
||||
|
||||
//
|
||||
// End of "$Id: threads.h 4748 2006-01-15 02:26:54Z mike $".
|
||||
//
|
||||
#endif // !THREADS_H_
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ extern void signal_modem_ready(void);
|
|||
|
||||
extern void macro_timer(void *);
|
||||
|
||||
extern Fl_Thread trx_thread;
|
||||
extern state_t trx_state;
|
||||
extern modem *active_modem;
|
||||
extern cRsId *ReedSolomon;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ bool isTxChar = false;
|
|||
bool isCmdChar = false;
|
||||
bool processCmd = false;
|
||||
|
||||
static Fl_Thread* arq_socket_thread = 0;
|
||||
static pthread_t* arq_socket_thread = 0;
|
||||
ARQ_SOCKET_Server* ARQ_SOCKET_Server::inst = 0;
|
||||
|
||||
Socket arqclient;
|
||||
|
|
@ -286,16 +286,19 @@ bool isSocketConnected = false;
|
|||
ARQ_SOCKET_Server::ARQ_SOCKET_Server()
|
||||
{
|
||||
server_socket = new Socket;
|
||||
arq_socket_thread = new Fl_Thread;
|
||||
arq_socket_thread = new pthread_t;
|
||||
run = true;
|
||||
}
|
||||
|
||||
ARQ_SOCKET_Server::~ARQ_SOCKET_Server()
|
||||
{
|
||||
run = false;
|
||||
pthread_kill(*arq_socket_thread, SIGUSR2);
|
||||
pthread_join(*arq_socket_thread, NULL);
|
||||
delete arq_socket_thread;
|
||||
if (arq_socket_thread) {
|
||||
pthread_kill(*arq_socket_thread, SIGUSR2);
|
||||
pthread_join(*arq_socket_thread, NULL);
|
||||
delete arq_socket_thread;
|
||||
arq_socket_thread = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ARQ_SOCKET_Server::start(const char* node, const char* service)
|
||||
|
|
@ -324,8 +327,7 @@ bool ARQ_SOCKET_Server::start(const char* node, const char* service)
|
|||
return false;
|
||||
}
|
||||
|
||||
fl_create_thread(*arq_socket_thread, thread_func, NULL);
|
||||
return true;
|
||||
return !pthread_create(arq_socket_thread, NULL, thread_func, NULL);
|
||||
}
|
||||
|
||||
void ARQ_SOCKET_Server::stop(void)
|
||||
|
|
@ -510,13 +512,12 @@ char arq_get_char()
|
|||
// Implementation using thread vice the fldigi timeout facility
|
||||
// ============================================================================
|
||||
|
||||
static Fl_Thread arq_thread;
|
||||
static pthread_t arq_thread;
|
||||
|
||||
static void *arq_loop(void *args);
|
||||
|
||||
static bool arq_exit = false;
|
||||
static bool arq_enabled;
|
||||
static int arq_dummy;
|
||||
|
||||
static void *arq_loop(void *args)
|
||||
{
|
||||
|
|
@ -553,7 +554,7 @@ void arq_init()
|
|||
if (!ARQ_SOCKET_Server::start( progdefaults.arq_address.c_str(), progdefaults.arq_port.c_str() ))
|
||||
return;
|
||||
|
||||
if (fl_create_thread(arq_thread, arq_loop, &arq_dummy) < 0) {
|
||||
if (pthread_create(&arq_thread, NULL, arq_loop, NULL) < 0) {
|
||||
fl_message("arq init: pthread_create failed");
|
||||
return;
|
||||
}
|
||||
|
|
@ -571,7 +572,7 @@ void arq_close(void)
|
|||
arq_exit = true;
|
||||
|
||||
// and then wait for it to die
|
||||
fl_join(arq_thread);
|
||||
pthread_join(arq_thread, NULL);
|
||||
arq_enabled = false;
|
||||
|
||||
arq_exit = false;
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ enum TAG { \
|
|||
ZIP, COUNTRY,LATD, LOND, GRID, \
|
||||
DOB };
|
||||
|
||||
int qrzdummy;
|
||||
Fl_Thread QRZ_thread;
|
||||
pthread_t QRZ_thread;
|
||||
bool QRZ_exit = false;
|
||||
bool QRZ_enabled = false;
|
||||
|
||||
|
|
@ -517,7 +516,7 @@ void QRZ_CD_query()
|
|||
void QRZinit(void)
|
||||
{
|
||||
QRZ_enabled = false;
|
||||
if (fl_create_thread(QRZ_thread, CALLSIGNloop, &qrzdummy) < 0) {
|
||||
if (pthread_create(&QRZ_thread, NULL, CALLSIGNloop, NULL) < 0) {
|
||||
fl_message("QRZ init: pthread_create failed");
|
||||
return;
|
||||
}
|
||||
|
|
@ -530,7 +529,7 @@ void QRZclose(void)
|
|||
// tell the QRZ thread to kill it self
|
||||
QRZ_exit = true;
|
||||
// and then wait for it to die
|
||||
fl_join(QRZ_thread);
|
||||
pthread_join(QRZ_thread, NULL);
|
||||
QRZ_enabled = false;
|
||||
QRZ_exit = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,76 +1,8 @@
|
|||
//
|
||||
// "$Id: threads.cxx 4748 2006-01-15 02:26:54Z mike $"
|
||||
//
|
||||
// Simple threading API for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2006 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// FLTK has no multithreaded support unless the main thread calls Fl::lock().
|
||||
// This main thread is the only thread allowed to call Fl::run() or Fl::wait().
|
||||
// From then on FLTK will be locked except when the main thread is actually
|
||||
// waiting for events from the user. Other threads must call Fl::lock() and
|
||||
// Fl::unlock() to surround calls to FLTK (such as to change widgets or
|
||||
// redraw them).
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "threads.h"
|
||||
|
||||
int fl_create_thread(Fl_Thread & t, void *(*f) (void *), void* p) {
|
||||
return pthread_create((pthread_t*)&t, NULL, f, p);
|
||||
}
|
||||
|
||||
int fl_mutex_init(Fl_Mutex * m) {
|
||||
return pthread_mutex_init( (pthread_mutex_t*) m, 0);
|
||||
}
|
||||
|
||||
int fl_cond_init(Fl_Cond * c) {
|
||||
return pthread_cond_init( (pthread_cond_t *) c, 0);
|
||||
}
|
||||
|
||||
int fl_cond_wait(Fl_Cond *c, Fl_Mutex *m) {
|
||||
return pthread_cond_wait( (pthread_cond_t *) c, (pthread_mutex_t *) m );
|
||||
}
|
||||
|
||||
int fl_cond_signal(Fl_Cond *c) {
|
||||
return pthread_cond_signal( (pthread_cond_t *) c);
|
||||
}
|
||||
|
||||
int fl_cond_bcast(Fl_Cond *c) {
|
||||
return pthread_cond_broadcast( (pthread_cond_t *) c);
|
||||
}
|
||||
|
||||
int fl_lock(Fl_Mutex *m) {
|
||||
return pthread_mutex_lock((pthread_mutex_t*)m);
|
||||
}
|
||||
|
||||
int fl_unlock(Fl_Mutex *m) {
|
||||
return pthread_mutex_unlock((pthread_mutex_t*)m);
|
||||
}
|
||||
|
||||
int fl_join (Fl_Thread t) {
|
||||
return pthread_join ((pthread_t) t, 0);
|
||||
}
|
||||
THREAD_ID_TYPE thread_id_;
|
||||
|
||||
#include "timeops.h"
|
||||
|
||||
|
|
@ -122,9 +54,3 @@ int pthread_cond_timedwait_rel(pthread_cond_t* cond, pthread_mutex_t* mutex, dou
|
|||
|
||||
return pthread_cond_timedwait(cond, mutex, &t);
|
||||
}
|
||||
|
||||
#if USE_TLS
|
||||
__thread int thread_id_;
|
||||
#else
|
||||
pthread_key_t thread_id_;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ struct rpc_method
|
|||
typedef list<rpc_method> methods_t;
|
||||
methods_t* methods = 0;
|
||||
|
||||
static Fl_Thread* server_thread;
|
||||
static pthread_t* server_thread;
|
||||
|
||||
XML_RPC_Server* XML_RPC_Server::inst = 0;
|
||||
|
||||
|
|
@ -81,16 +81,18 @@ XML_RPC_Server::XML_RPC_Server()
|
|||
{
|
||||
server_socket = new Socket;
|
||||
add_methods();
|
||||
|
||||
server_thread = new Fl_Thread;
|
||||
server_thread = new pthread_t;
|
||||
run = true;
|
||||
}
|
||||
XML_RPC_Server::~XML_RPC_Server()
|
||||
{
|
||||
run = false;
|
||||
pthread_kill(*server_thread, SIGUSR2);
|
||||
pthread_join(*server_thread, NULL);
|
||||
delete server_thread;
|
||||
if (server_thread) {
|
||||
pthread_kill(*server_thread, SIGUSR2);
|
||||
pthread_join(*server_thread, NULL);
|
||||
delete server_thread;
|
||||
server_thread = 0;
|
||||
}
|
||||
delete methods;
|
||||
methods = 0;
|
||||
}
|
||||
|
|
@ -112,7 +114,7 @@ void XML_RPC_Server::start(const char* node, const char* service)
|
|||
return;
|
||||
}
|
||||
|
||||
fl_create_thread(*server_thread, thread_func, NULL);
|
||||
pthread_create(server_thread, NULL, thread_func, NULL);
|
||||
}
|
||||
|
||||
void XML_RPC_Server::stop(void)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static Fl_Mutex hamlib_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static Fl_Thread hamlib_thread;
|
||||
static pthread_mutex_t hamlib_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t hamlib_thread;
|
||||
|
||||
static bool hamlib_exit = false;
|
||||
|
||||
|
|
@ -48,8 +48,6 @@ static long int hamlib_freq;
|
|||
static rmode_t hamlib_rmode = RIG_MODE_USB;
|
||||
static pbwidth_t hamlib_pbwidth = 3000;
|
||||
|
||||
static int dummy = 0;
|
||||
|
||||
static void *hamlib_loop(void *args);
|
||||
|
||||
void show_error(const char* msg1, const char* msg2 = 0)
|
||||
|
|
@ -177,7 +175,7 @@ bool hamlib_init(bool bPtt)
|
|||
hamlib_exit = false;
|
||||
hamlib_bypass = false;
|
||||
|
||||
if (fl_create_thread(hamlib_thread, hamlib_loop, &dummy) < 0) {
|
||||
if (pthread_create(&hamlib_thread, NULL, hamlib_loop, NULL) < 0) {
|
||||
show_error(__func__, "pthread_create failed");
|
||||
xcvr->close();
|
||||
return false;
|
||||
|
|
@ -217,7 +215,7 @@ void hamlib_set_ptt(int ptt)
|
|||
return;
|
||||
if (!hamlib_ptt)
|
||||
return;
|
||||
fl_lock(&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
try {
|
||||
xcvr->setPTT(ptt ? RIG_PTT_ON : RIG_PTT_OFF);
|
||||
hamlib_bypass = ptt ? true : false;
|
||||
|
|
@ -226,14 +224,14 @@ void hamlib_set_ptt(int ptt)
|
|||
show_error("Rig PTT", Ex.what());
|
||||
hamlib_ptt = false;
|
||||
}
|
||||
fl_unlock(&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
}
|
||||
|
||||
void hamlib_set_qsy(long long f, long long fmid)
|
||||
{
|
||||
if (xcvr->isOnLine() == false)
|
||||
return;
|
||||
fl_lock(&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
double fdbl = f;
|
||||
hamlib_qsy = false;
|
||||
try {
|
||||
|
|
@ -251,14 +249,14 @@ void hamlib_set_qsy(long long f, long long fmid)
|
|||
show_error("QSY", Ex.what());
|
||||
hamlib_passes = 0;
|
||||
}
|
||||
fl_unlock(&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
}
|
||||
|
||||
int hamlib_setfreq(long f)
|
||||
{
|
||||
if (xcvr->isOnLine() == false)
|
||||
return -1;
|
||||
fl_lock(&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
try {
|
||||
xcvr->setFreq(f);
|
||||
wf->rfcarrier(f);//(hamlib_freq);
|
||||
|
|
@ -267,7 +265,7 @@ int hamlib_setfreq(long f)
|
|||
show_error("SetFreq", Ex.what());
|
||||
hamlib_passes = 0;
|
||||
}
|
||||
fl_unlock(&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +273,7 @@ int hamlib_setmode(rmode_t m)
|
|||
{
|
||||
if (xcvr->isOnLine() == false)
|
||||
return -1;
|
||||
fl_lock(&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
try {
|
||||
hamlib_rmode = xcvr->getMode(hamlib_pbwidth);
|
||||
xcvr->setMode(m, hamlib_pbwidth);
|
||||
|
|
@ -285,7 +283,7 @@ int hamlib_setmode(rmode_t m)
|
|||
show_error("Set Mode", Ex.what());
|
||||
hamlib_passes = 0;
|
||||
}
|
||||
fl_unlock(&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +291,7 @@ int hamlib_setwidth(pbwidth_t w)
|
|||
{
|
||||
if (xcvr->isOnLine() == false)
|
||||
return -1;
|
||||
fl_lock(&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
try {
|
||||
hamlib_rmode = xcvr->getMode(hamlib_pbwidth);
|
||||
xcvr->setMode(hamlib_rmode, w);
|
||||
|
|
@ -303,7 +301,7 @@ int hamlib_setwidth(pbwidth_t w)
|
|||
show_error("Set Width", Ex.what());
|
||||
hamlib_passes = 0;
|
||||
}
|
||||
fl_unlock(&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +330,7 @@ static void *hamlib_loop(void *args)
|
|||
if (hamlib_bypass)
|
||||
continue;
|
||||
// hamlib locked while accessing hamlib serial i/o
|
||||
fl_lock (&hamlib_mutex);
|
||||
pthread_mutex_lock(&hamlib_mutex);
|
||||
|
||||
if (need_freq) {
|
||||
freq_t f;
|
||||
|
|
@ -341,7 +339,7 @@ static void *hamlib_loop(void *args)
|
|||
freq = (long int) f;
|
||||
freqok = true;
|
||||
if (freq == 0) {
|
||||
fl_unlock (&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -363,7 +361,7 @@ static void *hamlib_loop(void *args)
|
|||
modeok = false;
|
||||
}
|
||||
}
|
||||
fl_unlock (&hamlib_mutex);
|
||||
pthread_mutex_unlock(&hamlib_mutex);
|
||||
|
||||
if (hamlib_exit)
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@
|
|||
#define PTT_OFF false
|
||||
#define PTT_ON true
|
||||
|
||||
static int dummy;
|
||||
|
||||
static Fl_Thread rigMEM_thread;
|
||||
static pthread_t rigMEM_thread;
|
||||
static bool rigMEM_exit = false;
|
||||
static bool rigMEM_enabled;
|
||||
|
||||
|
|
@ -95,7 +93,7 @@ void rigMEM_init(void)
|
|||
TogglePTT = false;
|
||||
rigMEMisPTT = false;
|
||||
|
||||
if (fl_create_thread(rigMEM_thread, rigMEM_loop, &dummy) < 0) {
|
||||
if (pthread_create(&rigMEM_thread, NULL, rigMEM_loop, NULL) < 0) {
|
||||
fl_message("rigMEM init: pthread_create failed");
|
||||
return;
|
||||
}
|
||||
|
|
@ -111,7 +109,7 @@ void rigMEM_close(void)
|
|||
rigMEM_exit = true;
|
||||
|
||||
// and then wait for it to die
|
||||
fl_join(rigMEM_thread);
|
||||
pthread_join(rigMEM_thread, NULL);
|
||||
rigMEM_enabled = false;
|
||||
rigMEM_exit = false;
|
||||
|
||||
|
|
@ -216,7 +214,7 @@ void rigMEM_init(void)
|
|||
TogglePTT = false;
|
||||
rigMEMisPTT = false;
|
||||
|
||||
if (fl_create_thread(rigMEM_thread, rigMEM_loop, &dummy) < 0) {
|
||||
if (pthread_create(&rigMEM_thread, NULL, rigMEM_loop, NULL) < 0) {
|
||||
fl_message("rigMEM init: pthread_create failed");
|
||||
return;
|
||||
}
|
||||
|
|
@ -234,7 +232,7 @@ void rigMEM_close(void)
|
|||
rigMEM_exit = true;
|
||||
|
||||
// and then wait for it to die
|
||||
fl_join(rigMEM_thread);
|
||||
pthread_join(rigMEM_thread, NULL);
|
||||
LOG_DEBUG("rigMEM down");
|
||||
rigMEM_enabled = false;
|
||||
rigMEM_exit = false;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ using namespace std;
|
|||
|
||||
|
||||
Cserial rigio;
|
||||
static Fl_Mutex rigCAT_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static Fl_Thread rigCAT_thread;
|
||||
static pthread_mutex_t rigCAT_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t rigCAT_thread;
|
||||
|
||||
static bool rigCAT_exit = false;
|
||||
static bool rigCAT_open = false;
|
||||
|
|
@ -51,7 +51,6 @@ static string sRigWidth = "";
|
|||
static string sRigMode = "";
|
||||
static long long llFreq = 0;
|
||||
|
||||
static int dummy = 0;
|
||||
static bool nonCATrig = false;
|
||||
long long noCATfreq = 0L;
|
||||
string noCATmode = "USB";
|
||||
|
|
@ -470,17 +469,17 @@ void rigCAT_setfreq(long long f)
|
|||
if (preply->SYMBOL == modeCmd.ok) {
|
||||
XMLIOS rTemp = *preply;
|
||||
// send the command
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, rTemp.size);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
return;
|
||||
}
|
||||
preply++;
|
||||
}
|
||||
} else {
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, 0);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -633,17 +632,17 @@ void rigCAT_setmode(const string& md)
|
|||
if (preply->SYMBOL == modeCmd.ok) {
|
||||
XMLIOS rTemp = *preply;
|
||||
// send the command
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, rTemp.size);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
return;
|
||||
}
|
||||
preply++;
|
||||
}
|
||||
} else {
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, 0);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -797,17 +796,17 @@ void rigCAT_setwidth(const string& w)
|
|||
if (preply->SYMBOL == modeCmd.ok) {
|
||||
XMLIOS rTemp = *preply;
|
||||
// send the command
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, rTemp.size);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
return;
|
||||
}
|
||||
preply++;
|
||||
}
|
||||
} else {
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, 0);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -923,21 +922,21 @@ void rigCAT_sendINIT()
|
|||
if (preply->SYMBOL == modeCmd.ok) {
|
||||
XMLIOS rTemp = *preply;
|
||||
// send the command
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, rTemp.size);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
return;
|
||||
}
|
||||
preply++;
|
||||
}
|
||||
} else {
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
hexout(strCmd, 0);
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
// fl_lock(&rigCAT_mutex);
|
||||
// pthread_mutex_lock(&rigCAT_mutex);
|
||||
// hexout(strCmd, 0);
|
||||
// fl_unlock(&rigCAT_mutex);
|
||||
// pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
|
||||
bool rigCAT_init()
|
||||
|
|
@ -974,7 +973,7 @@ bool rigCAT_init()
|
|||
rigCAT_bypass = false;
|
||||
rigCAT_exit = false;
|
||||
|
||||
if (fl_create_thread(rigCAT_thread, rigCAT_loop, &dummy) < 0) {
|
||||
if (pthread_create(&rigCAT_thread, NULL, rigCAT_loop, NULL) < 0) {
|
||||
LOG_ERROR("pthread_create failed");
|
||||
rigio.ClosePort();
|
||||
return false;
|
||||
|
|
@ -1000,9 +999,9 @@ void rigCAT_close(void)
|
|||
count--;
|
||||
if (!count) {
|
||||
LOG_ERROR("RigCAT stuck");
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
rigio.ClosePort();
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1018,7 +1017,7 @@ void rigCAT_set_ptt(int ptt)
|
|||
{
|
||||
if (rigCAT_open == false)
|
||||
return;
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
if (ptt) {
|
||||
rigCAT_pttON();
|
||||
rigCAT_bypass = true;
|
||||
|
|
@ -1026,7 +1025,7 @@ void rigCAT_set_ptt(int ptt)
|
|||
rigCAT_pttOFF();
|
||||
rigCAT_bypass = false;
|
||||
}
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
}
|
||||
|
||||
#ifndef RIGCATTEST
|
||||
|
|
@ -1075,9 +1074,9 @@ static void *rigCAT_loop(void *args)
|
|||
if (rigCAT_exit == true)
|
||||
break;
|
||||
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
freq = rigCAT_getfreq();
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
|
||||
if ((freq > 0) && (freq != llFreq)) {
|
||||
llFreq = freq;
|
||||
|
|
@ -1090,9 +1089,9 @@ static void *rigCAT_loop(void *args)
|
|||
if (rigCAT_exit == true)
|
||||
break;
|
||||
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
sWidth = rigCAT_getwidth();
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
|
||||
if (sWidth.size() && sWidth != sRigWidth) {
|
||||
sRigWidth = sWidth;
|
||||
|
|
@ -1104,9 +1103,9 @@ static void *rigCAT_loop(void *args)
|
|||
if (rigCAT_exit == true)
|
||||
break;
|
||||
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
sMode = rigCAT_getmode();
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
|
||||
if (sMode.size() && sMode != sRigMode) {
|
||||
sRigMode = sMode;
|
||||
|
|
@ -1132,9 +1131,9 @@ static void *rigCAT_loop(void *args)
|
|||
activate_rig_menu_item(false);
|
||||
FL_UNLOCK();
|
||||
|
||||
fl_lock(&rigCAT_mutex);
|
||||
pthread_mutex_lock(&rigCAT_mutex);
|
||||
rigio.ClosePort();
|
||||
fl_unlock(&rigCAT_mutex);
|
||||
pthread_mutex_unlock(&rigCAT_mutex);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ void trx_tune_loop();
|
|||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
Fl_Mutex trx_cond_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
Fl_Cond trx_cond = PTHREAD_COND_INITIALIZER;
|
||||
Fl_Thread trx_thread;
|
||||
pthread_mutex_t trx_cond_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t trx_cond = PTHREAD_COND_INITIALIZER;
|
||||
pthread_t trx_thread;
|
||||
state_t trx_state;
|
||||
bool restartOK = false;
|
||||
bool trx_wait = false;
|
||||
|
|
@ -78,7 +78,6 @@ ringbuffer<double> trxrb(ceil2(NUMMEMBUFS * SCBLOCKSIZE));
|
|||
ringbuffer<double>::vector_type rbvec[2];
|
||||
bool bHistory = false;
|
||||
|
||||
static int dummy = 0;
|
||||
static bool trxrunning = false;
|
||||
|
||||
static bool rsid_detecting = false;
|
||||
|
|
@ -512,7 +511,7 @@ void trx_start(void)
|
|||
trx_state = STATE_RX;
|
||||
_trx_tune = 0;
|
||||
active_modem = 0;
|
||||
if (fl_create_thread(trx_thread, trx_loop, &dummy) < 0) {
|
||||
if (pthread_create(&trx_thread, NULL, trx_loop, NULL) < 0) {
|
||||
LOG_ERROR("pthread_create failed");
|
||||
trxrunning = false;
|
||||
exit(1);
|
||||
|
|
@ -546,7 +545,7 @@ void wait_modem_ready_prep(void)
|
|||
LOG_ERROR("trx thread called wait_modem_ready_prep!");
|
||||
#endif
|
||||
|
||||
fl_lock(&trx_cond_mutex);
|
||||
pthread_mutex_lock(&trx_cond_mutex);
|
||||
}
|
||||
|
||||
void wait_modem_ready_cmpl(void)
|
||||
|
|
@ -556,8 +555,8 @@ void wait_modem_ready_cmpl(void)
|
|||
LOG_ERROR("trx thread called wait_modem_ready_cmpl!");
|
||||
#endif
|
||||
|
||||
fl_cond_wait(&trx_cond, &trx_cond_mutex);
|
||||
fl_unlock(&trx_cond_mutex);
|
||||
pthread_cond_wait(&trx_cond, &trx_cond_mutex);
|
||||
pthread_mutex_unlock(&trx_cond_mutex);
|
||||
}
|
||||
|
||||
void signal_modem_ready(void)
|
||||
|
|
@ -567,8 +566,8 @@ void signal_modem_ready(void)
|
|||
LOG_ERROR("thread %d called signal_modem_ready!", GET_THREAD_ID());
|
||||
#endif
|
||||
|
||||
fl_lock(&trx_cond_mutex);
|
||||
fl_cond_bcast(&trx_cond);
|
||||
fl_unlock(&trx_cond_mutex);
|
||||
pthread_mutex_lock(&trx_cond_mutex);
|
||||
pthread_cond_broadcast(&trx_cond);
|
||||
pthread_mutex_unlock(&trx_cond_mutex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@
|
|||
#include "Viewer.h"
|
||||
#include "macros.h"
|
||||
|
||||
Fl_Mutex wf_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
extern modem *active_modem;
|
||||
|
||||
static RGB RGByellow = {254,254,0};
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue