Added 'timeOutMs' arg. to all calls to ui::ws::exec().
This commit is contained in:
parent
98ed33d2cc
commit
d5f75f961c
8
cwIo.cpp
8
cwIo.cpp
@ -2439,7 +2439,8 @@ cw::rc_t cw::io::stop( handle_t h )
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::io::exec( handle_t h, void* execCbArg )
|
||||
|
||||
cw::rc_t cw::io::exec( handle_t h, unsigned timeOutMs, void* execCbArg )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
io_t* p = _handleToPtr(h);
|
||||
@ -2447,8 +2448,9 @@ cw::rc_t cw::io::exec( handle_t h, void* execCbArg )
|
||||
if( p->wsUiH.isValid() )
|
||||
{
|
||||
ui::flushCache( ui::ws::uiHandle( p->wsUiH ));
|
||||
|
||||
// Note this call blocks on the websocket handle: See cwUi.h:ws:exec()
|
||||
rc = ui::ws::exec( p->wsUiH );
|
||||
rc = ui::ws::exec( p->wsUiH, timeOutMs );
|
||||
}
|
||||
|
||||
time::get(p->t0);
|
||||
@ -2490,7 +2492,7 @@ void cw::io::report( handle_t h )
|
||||
}
|
||||
|
||||
for(unsigned i=0; i<audioDeviceCount(h); ++i)
|
||||
printf("audio: %s\n", audioDeviceName(h,i));
|
||||
printf("audio: %s\n", cwStringNullGuard(audioDeviceName(h,i)));
|
||||
}
|
||||
|
||||
void cw::io::realTimeReport( handle_t h )
|
||||
|
5
cwIo.h
5
cwIo.h
@ -165,9 +165,10 @@ namespace cw
|
||||
rc_t pause( handle_t h );
|
||||
rc_t stop( handle_t h );
|
||||
|
||||
// Note that this call blocks on the the UI websocket handle.
|
||||
|
||||
// Note that this call blocks on the the UI websocket handle for up to 'timeOutMs'.
|
||||
// See ui:ws:exec().
|
||||
rc_t exec( handle_t h, void* execCbArg=nullptr );
|
||||
rc_t exec( handle_t h, unsigned timeOutMs, void* execCbArg=nullptr );
|
||||
|
||||
bool isShuttingDown( handle_t h );
|
||||
void report( handle_t h );
|
||||
|
@ -1024,8 +1024,16 @@ cw::rc_t cw::io::audio_midi::main( const object_t* cfg )
|
||||
// execute the io framework
|
||||
while( !isShuttingDown(app.ioH))
|
||||
{
|
||||
exec(app.ioH);
|
||||
sleepMs(50);
|
||||
const unsigned wsTimeOutMs = 50;
|
||||
time::spec_t t0 = time::current_time();
|
||||
|
||||
exec(app.ioH,wsTimeOutMs);
|
||||
|
||||
time::spec_t t1 = time::current_time();
|
||||
unsigned dMs = time::elapsedMs(t0,t1);
|
||||
|
||||
if( dMs < wsTimeOutMs )
|
||||
sleepMs(wsTimeOutMs-dMs);
|
||||
}
|
||||
|
||||
errLabel:
|
||||
|
@ -580,8 +580,16 @@ cw::rc_t cw::audio_midi_app::main( const object_t* cfg )
|
||||
// execute the io framework
|
||||
while( !isShuttingDown(app.ioH))
|
||||
{
|
||||
exec(app.ioH);
|
||||
sleepMs(50);
|
||||
const unsigned wsTimeOutMs = 50;
|
||||
time::spec_t t0 = time::current_time();
|
||||
|
||||
exec(app.ioH,wsTimeOutMs);
|
||||
|
||||
time::spec_t t1 = time::current_time();
|
||||
unsigned dMs = time::elapsedMs(t0,t1);
|
||||
|
||||
if( dMs < wsTimeOutMs )
|
||||
sleepMs(wsTimeOutMs-dMs);
|
||||
}
|
||||
|
||||
errLabel:
|
||||
|
@ -118,8 +118,16 @@ cw::rc_t cw::min_test( const object_t* cfg )
|
||||
// execuite the io framework
|
||||
while( !isShuttingDown(app.ioH))
|
||||
{
|
||||
exec(app.ioH);
|
||||
sleepMs(500);
|
||||
const unsigned wsTimeOutMs = 50;
|
||||
time::spec_t t0 = time::current_time();
|
||||
|
||||
exec(app.ioH,wsTimeOutMs);
|
||||
|
||||
time::spec_t t1 = time::current_time();
|
||||
unsigned dMs = time::elapsedMs(t0,t1);
|
||||
|
||||
if( dMs < wsTimeOutMs )
|
||||
sleepMs(wsTimeOutMs-dMs);
|
||||
|
||||
if( isKeyWaiting() )
|
||||
break;
|
||||
|
@ -372,6 +372,7 @@ namespace cw
|
||||
|
||||
const char* dflt_perf_label;
|
||||
unsigned dflt_perf_app_id;
|
||||
unsigned run_dur_secs;
|
||||
|
||||
|
||||
} app_t;
|
||||
@ -446,6 +447,7 @@ namespace cw
|
||||
"beg_play_loc", app->beg_play_loc,
|
||||
"end_play_loc", app->end_play_loc,
|
||||
"dflt_perf_label", app->dflt_perf_label,
|
||||
"run_dur_secs", app->run_dur_secs,
|
||||
"live_mode_fl", app->useLiveMidiFl,
|
||||
"enable_recording_fl", app->enableRecordFl,
|
||||
"midi_record_dir", midi_record_dir,
|
||||
@ -554,7 +556,7 @@ namespace cw
|
||||
app_t* app = (app_t*)arg;
|
||||
unsigned logUuId = uiFindElementUuId( app->ioH, kLogId);
|
||||
|
||||
uiSetLogLine( app->ioH, logUuId, text );
|
||||
//uiSetLogLine( app->ioH, logUuId, text );
|
||||
log::defaultOutput(nullptr,level,text);
|
||||
}
|
||||
|
||||
@ -711,6 +713,7 @@ namespace cw
|
||||
char* perf_fname = nullptr;
|
||||
char* meta_fname = nullptr;
|
||||
bool skip_fl = false;
|
||||
|
||||
// create the performance recording file path
|
||||
if((perf_fname = filesys::makeFn(dir,fname,nullptr,recording_folder,nullptr)) == nullptr )
|
||||
{
|
||||
@ -782,8 +785,11 @@ namespace cw
|
||||
|
||||
mem::release(meta_fname);
|
||||
mem::release(perf_fname);
|
||||
return rc;
|
||||
|
||||
if( meta_cfg != nullptr )
|
||||
meta_cfg->free();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc_t _parse_perf_recording_dir( app_t* app, const char* dir, const char* fname, const object_t* velTblCfg )
|
||||
@ -1813,7 +1819,7 @@ namespace cw
|
||||
|
||||
errLabel:
|
||||
if(rc != kOkRC )
|
||||
rc = cwLogError(rc,"Preset control index '%i' create failed.");
|
||||
rc = cwLogError(rc,"Preset control index '%i' create failed.", preset_idx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1900,7 +1906,7 @@ namespace cw
|
||||
// read the preset data file
|
||||
if((rc = preset_sel::read( app->psH, fn)) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(rc,"File write failed on preset select.");
|
||||
rc = cwLogError(rc,"File read failed on preset select.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
@ -3019,7 +3025,7 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
|
||||
break;
|
||||
|
||||
case kIoReportBtnId:
|
||||
io::report( app->ioH );
|
||||
io::realTimeReport( app->ioH );
|
||||
break;
|
||||
|
||||
case kNetPrintBtnId:
|
||||
@ -3586,6 +3592,7 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
|
||||
unsigned bigMapN = mapN + vtMapN;
|
||||
ui::appIdMap_t bigMap[ bigMapN ];
|
||||
double sysSampleRate = 0;
|
||||
time::spec_t start_time = time::current_time();
|
||||
|
||||
for(unsigned i=0; i<mapN; ++i)
|
||||
bigMap[i] = mapA[i];
|
||||
@ -3709,18 +3716,27 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
|
||||
// execute the io framework
|
||||
while( !io::isShuttingDown(app.ioH))
|
||||
{
|
||||
//time::spec_t t0;
|
||||
//time::get(t0);
|
||||
const unsigned wsTimeOutMs = 50;
|
||||
time::spec_t t0 = time::current_time();
|
||||
|
||||
unsigned timeOutMs = app.psNextFrag != nullptr ? 0 : wsTimeOutMs;
|
||||
|
||||
// This call may block on the websocket handle.
|
||||
io::exec(app.ioH);
|
||||
io::exec(app.ioH,timeOutMs);
|
||||
|
||||
//unsigned dMs = time::elapsedMs(t0);
|
||||
//if( dMs < 50 && app.psNextFrag == nullptr )
|
||||
//{
|
||||
// sleepMs( 50-dMs );
|
||||
//}
|
||||
time::spec_t t1 = time::current_time();
|
||||
unsigned dMs = time::elapsedMs(t0,t1);
|
||||
|
||||
if( dMs < wsTimeOutMs && app.psNextFrag == nullptr )
|
||||
{
|
||||
sleepMs( wsTimeOutMs-dMs );
|
||||
}
|
||||
|
||||
if( app.run_dur_secs != 0 && time::elapsedMs( start_time )/1000 > app.run_dur_secs )
|
||||
{
|
||||
printf("Run duration expired (%i secs). Shutting down.\n",app.run_dur_secs);
|
||||
io::stop(app.ioH);
|
||||
}
|
||||
}
|
||||
|
||||
// stop the io framework
|
||||
|
12
cwIoTest.cpp
12
cwIoTest.cpp
@ -308,8 +308,16 @@ cw::rc_t cw::io::test( const object_t* cfg )
|
||||
// execuite the io framework
|
||||
while( !isShuttingDown(app.ioH))
|
||||
{
|
||||
exec(app.ioH);
|
||||
sleepMs(50);
|
||||
const unsigned wsTimeOutMs = 50;
|
||||
time::spec_t t0 = time::current_time();
|
||||
|
||||
exec(app.ioH,wsTimeOutMs);
|
||||
|
||||
time::spec_t t1 = time::current_time();
|
||||
unsigned dMs = time::elapsedMs(t0,t1);
|
||||
|
||||
if( dMs < wsTimeOutMs )
|
||||
sleepMs(wsTimeOutMs-dMs);
|
||||
}
|
||||
|
||||
errLabel:
|
||||
|
@ -379,6 +379,7 @@ namespace cw
|
||||
cw::rc_t cw::ui::test( const object_t* cfg )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
unsigned wsTimeOutMs = 50;
|
||||
ui::ws::args_t args = {};
|
||||
|
||||
// Application Id's for the resource based UI elements.
|
||||
@ -437,7 +438,7 @@ cw::rc_t cw::ui::test( const object_t* cfg )
|
||||
//app->uiCfgFn = "/home/kevin/src/cwtest/src/libcw/html/uiTest/ui.cfg";
|
||||
|
||||
// create the UI server
|
||||
if((rc = srv::create(app->wsUiSrvH, args, app, _uiTestCallback, mapA, mapN, nullptr )) != kOkRC )
|
||||
if((rc = srv::create(app->wsUiSrvH, args, app, _uiTestCallback, mapA, mapN, wsTimeOutMs, nullptr )) != kOkRC )
|
||||
return rc;
|
||||
|
||||
if((rc = uiTestCreateUi( app )) != kOkRC )
|
||||
|
@ -56,7 +56,9 @@ cw::rc_t cw::websockSrv::create(
|
||||
int port,
|
||||
const websock::protocol_t* protocolA,
|
||||
unsigned protocolN,
|
||||
unsigned timeOutMs )
|
||||
unsigned timeOutMs,
|
||||
unsigned queueBlkCnt,
|
||||
unsigned queueBlkByteCnt )
|
||||
{
|
||||
rc_t rc;
|
||||
if((rc = destroy(h)) != kOkRC )
|
||||
@ -64,7 +66,7 @@ cw::rc_t cw::websockSrv::create(
|
||||
|
||||
websockSrv_t* p = mem::allocZ<websockSrv_t>();
|
||||
|
||||
if((rc = websock::create( p->_websockH, cbFunc, cbArg, physRootDir, dfltHtmlPageFn, port, protocolA, protocolN )) != kOkRC )
|
||||
if((rc = websock::create( p->_websockH, cbFunc, cbArg, physRootDir, dfltHtmlPageFn, port, protocolA, protocolN, queueBlkCnt, queueBlkByteCnt )) != kOkRC )
|
||||
goto errLabel;
|
||||
|
||||
|
||||
@ -176,6 +178,8 @@ cw::rc_t cw::websockSrvTest( const object_t* cfg )
|
||||
int port = 5687;
|
||||
unsigned rcvBufByteN = 128;
|
||||
unsigned xmtBufByteN = 128;
|
||||
unsigned queueBlkCnt = 3;
|
||||
unsigned queueBlkByteCnt= 4096;
|
||||
appCtx_t appCtx;
|
||||
|
||||
enum
|
||||
@ -198,7 +202,7 @@ cw::rc_t cw::websockSrvTest( const object_t* cfg )
|
||||
unsigned protocolN = sizeof(protocolA)/sizeof(protocolA[0]);
|
||||
|
||||
|
||||
if((rc = websockSrv::create( h, websockCb, &appCtx, physRootDir, dfltHtmlPageFn, port, protocolA, protocolN, timeOutMs )) != kOkRC )
|
||||
if((rc = websockSrv::create( h, websockCb, &appCtx, physRootDir, dfltHtmlPageFn, port, protocolA, protocolN, timeOutMs, queueBlkCnt, queueBlkByteCnt )) != kOkRC )
|
||||
return rc;
|
||||
|
||||
appCtx.wsH = websockSrv::websockHandle(h);
|
||||
|
@ -16,7 +16,9 @@ namespace cw {
|
||||
int port,
|
||||
const websock::protocol_t* protocolA,
|
||||
unsigned protocolN,
|
||||
unsigned websockTimeOutMs );
|
||||
unsigned websockTimeOutMs,
|
||||
unsigned queueBlkCnt,
|
||||
unsigned queueBlkByteCnt);
|
||||
|
||||
rc_t destroy( handle_t& h );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user