Fixes for Windows compilation suggested by Faizan Naqvi (Tili).
Added names for thread priorities. Fixed the way some channels handle timestamps (broken by the delta->full API change). git-svn-id: http://voip.null.ro/svn/yate@536 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
aed52e0a0b
commit
fbe5346930
|
@ -84,6 +84,15 @@ static pthread_key_t current_key;
|
|||
static pthread_once_t current_key_once = PTHREAD_ONCE_INIT;
|
||||
#endif
|
||||
|
||||
static TokenDict s_prio[] = {
|
||||
{ "lowest", Thread::Lowest },
|
||||
{ "low", Thread::Low },
|
||||
{ "normal", Thread::Normal },
|
||||
{ "high", Thread::High },
|
||||
{ "highest", Thread::Highest },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
ObjList threads;
|
||||
Mutex tmutex(true);
|
||||
|
||||
|
@ -413,11 +422,20 @@ Thread::Thread(const char* name, Priority prio)
|
|||
: m_private(0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Debugger debug("Thread::Thread","(\"%s\") [%p]",name,this);
|
||||
Debugger debug("Thread::Thread","(\"%s\",%d) [%p]",name,prio,this);
|
||||
#endif
|
||||
m_private = ThreadPrivate::create(this,name,prio);
|
||||
}
|
||||
|
||||
Thread::Thread(const char *name, const char* prio)
|
||||
: m_private(0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Debugger debug("Thread::Thread","(\"%s\",\"%s\") [%p]",name,prio,this);
|
||||
#endif
|
||||
m_private = ThreadPrivate::create(this,name,priority(prio));
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
{
|
||||
DDebug(DebugAll,"Thread::~Thread() [%p]",this);
|
||||
|
@ -544,6 +562,16 @@ void Thread::usleep(unsigned long usec, bool exitCheck)
|
|||
check();
|
||||
}
|
||||
|
||||
Thread::Priority Thread::priority(const char* name, Thread::Priority defvalue)
|
||||
{
|
||||
return (Thread::Priority)lookup(name,s_prio,defvalue);
|
||||
}
|
||||
|
||||
const char* Thread::priority(Thread::Priority prio)
|
||||
{
|
||||
return lookup(prio,s_prio);
|
||||
}
|
||||
|
||||
void Thread::preExec()
|
||||
{
|
||||
#ifdef THREAD_KILL
|
||||
|
|
|
@ -238,7 +238,7 @@ void ExtModSource::run()
|
|||
if (r <= 0)
|
||||
continue;
|
||||
DataBlock buf(data,r,false);
|
||||
Forward(buf,m_total);
|
||||
Forward(buf,m_total/2);
|
||||
buf.clear(false);
|
||||
m_total += r;
|
||||
tpos += (r*1000000ULL/m_brate);
|
||||
|
|
|
@ -1561,7 +1561,7 @@ BOOL YateH323AudioSource::Write(const void *buf, PINDEX len)
|
|||
{
|
||||
if (!m_exit) {
|
||||
m_data.assign((void *)buf,len,false);
|
||||
Forward(m_data,len/2);
|
||||
Forward(m_data);
|
||||
m_data.clear(false);
|
||||
writeDelay.Delay(len/16);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ void MOHSource::run()
|
|||
XDebug("MOH",DebugAll,"Sleeping for " FMT64 " usec",dly);
|
||||
::usleep((unsigned long)dly);
|
||||
}
|
||||
Forward(m_data,m_data.length()*8000/m_brate);
|
||||
Forward(m_data);
|
||||
tpos += (r*1000000ULL/m_brate);
|
||||
} while (r > 0);
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ void OssSource::run()
|
|||
XDebug("OssSource",DebugAll,"Sleeping for " FMT64 " usec",dly);
|
||||
Thread::usleep((unsigned long)dly);
|
||||
}
|
||||
Forward(data,data.length()/2);
|
||||
Forward(data);
|
||||
m_total += r;
|
||||
tpos += (r*1000000ULL/m_brate);
|
||||
} while (r > 0);
|
||||
|
|
|
@ -65,10 +65,10 @@ static void evalFunc(String &str)
|
|||
else if (str == "random") {
|
||||
str.clear();
|
||||
for (unsigned int i = 0; i < par.length(); i++) {
|
||||
if (par[i] == '?')
|
||||
if (par.at(i) == '?')
|
||||
str << (int)(::random() % 10);
|
||||
else
|
||||
str << par[i];
|
||||
str << par.at(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -445,7 +445,7 @@ Tone* ToneSource::buildDtmf(const String& dtmf, int len, int gap)
|
|||
t->data = 0;
|
||||
t++;
|
||||
|
||||
int c = dtmf[i];
|
||||
int c = dtmf.at(i);
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
c -= '0';
|
||||
else if (c == '*')
|
||||
|
|
|
@ -326,8 +326,16 @@ void WpConsumer::Consume(const DataBlock &data, unsigned long tStamp)
|
|||
put(buf[i]);
|
||||
}
|
||||
|
||||
static Thread::Priority cfgPriority(Configuration& cfg, const String& sect)
|
||||
{
|
||||
String tmp(cfg.getValue(sect,"thread"));
|
||||
if (tmp.null())
|
||||
tmp = cfg.getValue("general","thread");
|
||||
return Thread::priority(tmp);
|
||||
}
|
||||
|
||||
WpData::WpData(WpSpan* span, const char* card, const char* device, Configuration& cfg, const String& sect)
|
||||
: Thread("WpData"), m_span(span), m_fd(INVALID_HANDLE_VALUE),
|
||||
: Thread("WpData",cfgPriority(cfg,sect)), m_span(span), m_fd(INVALID_HANDLE_VALUE),
|
||||
m_buffer(0), m_chans(0), m_samples(50), m_rdError(0), m_wrError(0)
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpData::WpData(%p,'%s','%s') [%p]",
|
||||
|
|
|
@ -113,7 +113,7 @@ private:
|
|||
class WpData : public Thread
|
||||
{
|
||||
public:
|
||||
WpData(WpSpan* span, const char* card, const char* device);
|
||||
WpData(WpSpan* span, const char* card, const char* device, Thread::Priority prio);
|
||||
~WpData();
|
||||
virtual void run();
|
||||
private:
|
||||
|
@ -428,8 +428,10 @@ void WpConsumer::Consume(const DataBlock &data, unsigned long tStamp)
|
|||
put(buf[i]);
|
||||
}
|
||||
|
||||
WpData::WpData(WpSpan* span, const char* card, const char* device)
|
||||
: Thread("WpData"), m_span(span), m_fd(INVALID_HANDLE_VALUE), m_chans(0)
|
||||
|
||||
|
||||
WpData::WpData(WpSpan* span, const char* card, const char* device, Thread::Priority prio)
|
||||
: Thread("WpData",prio), m_span(span), m_fd(INVALID_HANDLE_VALUE), m_chans(0)
|
||||
{
|
||||
DDebug(&__plugin,DebugAll,"WpData::WpData(%p) [%p]",span,this);
|
||||
HANDLE fd = wp_open(card,device);
|
||||
|
@ -544,6 +546,15 @@ bool WpChan::openData(const char* format, int echoTaps)
|
|||
return true;
|
||||
}
|
||||
|
||||
static Thread::Priority cfgPriority(Configuration& cfg, const String& sect)
|
||||
{
|
||||
String tmp(cfg.getValue(sect,"thread"));
|
||||
if (tmp.null())
|
||||
tmp = cfg.getValue("general","thread");
|
||||
return Thread::priority(tmp);
|
||||
}
|
||||
|
||||
|
||||
PriSpan* WpDriver::createSpan(PriDriver* driver, int span, int first, int chans, Configuration& cfg, const String& sect)
|
||||
{
|
||||
Debug(this,DebugAll,"WpDriver::createSpan(%p,%d,%d,%d) [%p]",driver,span,first,chans,this);
|
||||
|
@ -563,7 +574,7 @@ PriSpan* WpDriver::createSpan(PriDriver* driver, int span, int first, int chans,
|
|||
WpWriter* wr = new WpWriter(ps,card,dev);
|
||||
WpReader* rd = new WpReader(ps,card,dev);
|
||||
dev = cfg.getValue(sect,"bgroup","IF1");
|
||||
WpData* dat = new WpData(ps,card,dev);
|
||||
WpData* dat = new WpData(ps,card,dev,cfgPriority(cfg,sect));
|
||||
wr->startup();
|
||||
rd->startup();
|
||||
dat->startup();
|
||||
|
|
25
yateclass.h
25
yateclass.h
|
@ -35,7 +35,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#ifndef _WINDOWS
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define _WINDOWS
|
||||
#endif
|
||||
#endif
|
||||
|
@ -2508,6 +2508,22 @@ public:
|
|||
inline bool isCurrent() const
|
||||
{ return current() == this; }
|
||||
|
||||
|
||||
/**
|
||||
* Convert a priority name to a thread priority level
|
||||
* @param name Name of the requested level
|
||||
* @param defvalue Priority to return in case of an invalid name
|
||||
* @return A thread priority level
|
||||
*/
|
||||
static Priority priority(const char* name, Priority defvalue = Normal);
|
||||
|
||||
/**
|
||||
* Convert a priority level to a textual name
|
||||
* @param prio Priority level to convert
|
||||
* @return Name of the level or NULL if an invalid argument was provided
|
||||
*/
|
||||
static const char* priority(Priority prio);
|
||||
|
||||
/**
|
||||
* Kills all other running threads. Ouch!
|
||||
* Must be called from the main thread or it does nothing.
|
||||
|
@ -2528,6 +2544,13 @@ protected:
|
|||
*/
|
||||
Thread(const char *name = 0, Priority prio = Normal);
|
||||
|
||||
/**
|
||||
* Creates and starts a new thread
|
||||
* @param name Static name of the thread (for debugging purpose only)
|
||||
* @param prio Thread priority level name
|
||||
*/
|
||||
Thread(const char *name, const char* prio);
|
||||
|
||||
/**
|
||||
* The destructor is called when the thread terminates
|
||||
*/
|
||||
|
|
|
@ -59,7 +59,7 @@ struct ImageInfo {
|
|||
/**
|
||||
* A structure to hold information about a data format.
|
||||
*/
|
||||
struct FormatInfo {
|
||||
struct YATE_API FormatInfo {
|
||||
/**
|
||||
* Standard no-blanks lowercase format name
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue