cmThread.h/c: cmSleepMs() and cmSleepUs() and replaced all references to usleep() in many files.
This commit is contained in:
parent
1be3fa2240
commit
b3b492f094
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "cmApBuf.h" // only needed for cmApBufTest().
|
#include "cmApBuf.h" // only needed for cmApBufTest().
|
||||||
|
|
||||||
//#include <unistd.h> // usleep
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -338,7 +337,6 @@ cmAgRC_t cmApAggDeviceStart( unsigned aggDevIdx )
|
|||||||
if( cmApDeviceStart( physDevIdx ) != kOkApRC )
|
if( cmApDeviceStart( physDevIdx ) != kOkApRC )
|
||||||
return cmErrMsg(&_cmAg.err,kPhysDevStartFailAgRC,"The physical device (index:%i '%s') start failed.",physDevIdx,cmStringNullGuard(cmApDeviceLabel(physDevIdx)));
|
return cmErrMsg(&_cmAg.err,kPhysDevStartFailAgRC,"The physical device (index:%i '%s') start failed.",physDevIdx,cmStringNullGuard(cmApDeviceLabel(physDevIdx)));
|
||||||
|
|
||||||
//usleep(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ap->startedFl = true;
|
ap->startedFl = true;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "cmAudioPort.h"
|
#include "cmAudioPort.h"
|
||||||
#include "cmAudioFileDev.h"
|
#include "cmAudioFileDev.h"
|
||||||
|
|
||||||
#include <unistd.h> // usleep()
|
|
||||||
|
|
||||||
#ifdef OS_OSX
|
#ifdef OS_OSX
|
||||||
#include "osx/clock_gettime_stub.h"
|
#include "osx/clock_gettime_stub.h"
|
||||||
@ -168,7 +167,7 @@ bool _cmAudioDevThreadFunc(void* param)
|
|||||||
// if the execution time has not yet arrived
|
// if the execution time has not yet arrived
|
||||||
if( dusec > 0 )
|
if( dusec > 0 )
|
||||||
{
|
{
|
||||||
usleep(dusec);
|
cmSleepUs(dusec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the thread is still running
|
// if the thread is still running
|
||||||
|
@ -130,7 +130,7 @@ bool cmApNrtThreadFunc(void* param)
|
|||||||
{
|
{
|
||||||
cmApNrtDev_t* dp = (cmApNrtDev_t*)param;
|
cmApNrtDev_t* dp = (cmApNrtDev_t*)param;
|
||||||
|
|
||||||
usleep( dp->cbPeriodMs * 1000 );
|
cmSleepUs( dp->cbPeriodMs * 1000 );
|
||||||
|
|
||||||
|
|
||||||
cmApAudioPacket_t pkt;
|
cmApAudioPacket_t pkt;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#include <sys/time.h> // gettimeofday()
|
#include <sys/time.h> // gettimeofday()
|
||||||
#include <unistd.h> // usleep()
|
|
||||||
//#include <time.h> // clock_gettime()
|
|
||||||
#include "cmPrefix.h"
|
#include "cmPrefix.h"
|
||||||
#include "cmGlobal.h"
|
#include "cmGlobal.h"
|
||||||
#include "cmRpt.h"
|
#include "cmRpt.h"
|
||||||
@ -13,6 +11,7 @@
|
|||||||
#include "cmMidiPort.h"
|
#include "cmMidiPort.h"
|
||||||
#include "cmMidiFile.h"
|
#include "cmMidiFile.h"
|
||||||
#include "cmMidiFilePlay.h"
|
#include "cmMidiFilePlay.h"
|
||||||
|
#include "cmThread.h" // cmSleepUs()
|
||||||
|
|
||||||
#ifdef OS_OSX
|
#ifdef OS_OSX
|
||||||
#include "osx/clock_gettime_stub.h"
|
#include "osx/clock_gettime_stub.h"
|
||||||
@ -293,7 +292,7 @@ void _cmMfpTestTimer()
|
|||||||
|
|
||||||
for(i=0; i<n; ++i)
|
for(i=0; i<n; ++i)
|
||||||
{
|
{
|
||||||
usleep(suspendUsecs);
|
cmSleepUs(suspendUsecs);
|
||||||
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME,&t1);
|
clock_gettime(CLOCK_REALTIME,&t1);
|
||||||
@ -358,7 +357,7 @@ cmMfpRC_t cmMfpTest( const char* fn, cmCtx_t* ctx )
|
|||||||
//for(i=0; i<n; ++i)
|
//for(i=0; i<n; ++i)
|
||||||
while(rc != kEndOfFileMfpRC)
|
while(rc != kEndOfFileMfpRC)
|
||||||
{
|
{
|
||||||
usleep(suspendUsecs);
|
cmSleepUs(suspendUsecs);
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME,&t1);
|
clock_gettime(CLOCK_REALTIME,&t1);
|
||||||
t1.tv_sec -= base.tv_sec;
|
t1.tv_sec -= base.tv_sec;
|
||||||
|
17
cmThread.c
17
cmThread.c
@ -60,7 +60,7 @@ void* _cmThThreadCallback(void* param)
|
|||||||
|
|
||||||
if( t->state == kPausedThId )
|
if( t->state == kPausedThId )
|
||||||
{
|
{
|
||||||
usleep( t->pauseMicroSecs );
|
cmSleepUs( t->pauseMicroSecs );
|
||||||
|
|
||||||
if( cmIsFlag(t->doFlags,kDoRunThFl) )
|
if( cmIsFlag(t->doFlags,kDoRunThFl) )
|
||||||
{
|
{
|
||||||
@ -104,8 +104,8 @@ cmThRC_t _cmThWaitForState( cmThThread_t* t, unsigned stateId )
|
|||||||
|
|
||||||
while( t->state != stateId && waitTimeMicroSecs < t->waitMicroSecs )
|
while( t->state != stateId && waitTimeMicroSecs < t->waitMicroSecs )
|
||||||
{
|
{
|
||||||
//usleep( t->waitMicroSecs );
|
//cmSleepUs( t->waitMicroSecs );
|
||||||
usleep( 15000 );
|
cmSleepUs( 15000 );
|
||||||
waitTimeMicroSecs += 15000; //t->waitMicroSecs;
|
waitTimeMicroSecs += 15000; //t->waitMicroSecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1671,7 +1671,7 @@ bool _cmTsQueueCb0(void* param)
|
|||||||
printf("in error %i\n",p->id);
|
printf("in error %i\n",p->id);
|
||||||
|
|
||||||
|
|
||||||
usleep(100*1000);
|
cmSleepUs(100*1000);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1794,7 +1794,7 @@ bool _cmTs1p1cCb0(void* param)
|
|||||||
|
|
||||||
++p->id;
|
++p->id;
|
||||||
|
|
||||||
usleep(100*1000);
|
cmSleepUs(100*1000);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1905,7 +1905,7 @@ bool _cmTsMp1cCb0(void* param)
|
|||||||
else
|
else
|
||||||
printf("in error %i\n",p->id);
|
printf("in error %i\n",p->id);
|
||||||
|
|
||||||
usleep(100*1000);
|
cmSleepUs(100*1000);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1995,3 +1995,8 @@ void cmTsMp1cTest( cmRpt_t* rpt )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmSleepUs( unsigned microseconds )
|
||||||
|
{ usleep(microseconds); }
|
||||||
|
|
||||||
|
void cmSleepMs( unsigned milliseconds )
|
||||||
|
{ cmSleepUs(milliseconds*1000); }
|
||||||
|
@ -270,6 +270,10 @@ extern "C" {
|
|||||||
bool cmTsMp1cIsValid( cmTsMp1cH_t h );
|
bool cmTsMp1cIsValid( cmTsMp1cH_t h );
|
||||||
|
|
||||||
|
|
||||||
|
// Sleep functions
|
||||||
|
void cmSleepUs( unsigned microseconds );
|
||||||
|
void cmSleepMs( unsigned milliseconds );
|
||||||
|
|
||||||
|
|
||||||
void cmTsQueueTest( cmRpt_t* rpt );
|
void cmTsQueueTest( cmRpt_t* rpt );
|
||||||
void cmTs1p1cTest( cmRpt_t* rpt );
|
void cmTs1p1cTest( cmRpt_t* rpt );
|
||||||
|
@ -98,7 +98,7 @@ cmDspRC_t _cmDspSysNetSend( cmDsp_t* p, unsigned remoteNetNodeId, unsigned subSe
|
|||||||
|
|
||||||
if( cmUdpNetSendById(p->netH, remoteNetNodeId, &m, sizeof(m) ) == kOkUnRC )
|
if( cmUdpNetSendById(p->netH, remoteNetNodeId, &m, sizeof(m) ) == kOkUnRC )
|
||||||
{
|
{
|
||||||
//usleep(p->sendWaitMs*1000);
|
//cmSleepUs(p->sendWaitMs*1000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -223,7 +223,7 @@ cmDspRC_t _cmDspSysNetSendConnRequests( cmDsp_t* p, unsigned dstNetNodeId )
|
|||||||
if( p->netVerbosity > 1 )
|
if( p->netVerbosity > 1 )
|
||||||
cmRptPrintf(p->err.rpt,"Sync: send req to %i\n",rp->dstNetNodeId);
|
cmRptPrintf(p->err.rpt,"Sync: send req to %i\n",rp->dstNetNodeId);
|
||||||
|
|
||||||
//usleep(p->sendWaitMs*1000); // wait between transmissions
|
//cmSleepUs(p->sendWaitMs*1000); // wait between transmissions
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ bool _cmDspSysNetSyncThreadCb( void* param )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// prevent the thread from burning too much time
|
// prevent the thread from burning too much time
|
||||||
usleep(p->sendWaitMs*1000);
|
cmSleepUs(p->sendWaitMs*1000);
|
||||||
|
|
||||||
// check if all nodes have completed transmission to this node
|
// check if all nodes have completed transmission to this node
|
||||||
nodeFl = _cmDspSysNetCheckNetNodeStatus(p);
|
nodeFl = _cmDspSysNetCheckNetNodeStatus(p);
|
||||||
|
Loading…
Reference in New Issue
Block a user