X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fpage_status.c;h=555a7666ca59c00eeca39f791e61dae16e8d488e;hb=53125cf7f5524730c9830ea33e36aa63eb1019cf;hp=1047ec6bf8cd87d90ef2b028a7b52f0634f915a8;hpb=5a44a194cba7a21fd18990f7041c864f78d2b793;p=rugen diff --git a/src/page_status.c b/src/page_status.c index 1047ec6..555a766 100644 --- a/src/page_status.c +++ b/src/page_status.c @@ -203,31 +203,53 @@ static void show_units( page_status this, gboolean active ) static void *status_thread( void *arg ) { + int i; page_status this = arg; mvcp_notifier notifier = mvcp_get_notifier( this->status ); mvcp_status_t status; + mvcp_status_t *statuses; show_units( this, TRUE ); - + + statuses = malloc(sizeof(mvcp_status_t) * this->count); + memset(statuses, 0, sizeof(mvcp_status_t) * this->count); + while ( !this->terminated ) { - if ( mvcp_notifier_wait( notifier, &status ) != -1 ) + char buf[32]; + + /* wait for any event from notifier */ + mvcp_notifier_wait( notifier, &status ); + + /* get status for all units */ + for(i = 0; i < this->count; i++) { - char buf[32]; + mvcp_notifier_get( notifier, &status, i); if ( status.status == unit_disconnected ) + goto break_unit_disconnected; + + if( memcmp(&status, &statuses[i], sizeof(mvcp_status_t)) || !this->app->eof[i]) { - this->app->eof = 0; - break; + /* save status */ + statuses[i] = status; + + /* save eof status */ + if ( !this->app->eof[i] && mvcp_unit_get( this->app->command, i, + "eof", buf, sizeof(buf) ) != -1) + this->app->eof[i] = buf[0]; + + /* send status update */ + if ( show_status( this, &status ) ) + show_units( this, TRUE ); } - if ( show_status( this, &status ) ) - show_units( this, TRUE ); - if ( !this->app->eof && mvcp_unit_get( this->app->command, this->app->selected_unit, - "eof", buf, sizeof(buf) ) != -1) - this->app->eof = buf[0]; } } +break_unit_disconnected: + + free(statuses); + show_units( this, FALSE ); if ( !this->terminated )