X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fpage_status.c;fp=src%2Fpage_status.c;h=555a7666ca59c00eeca39f791e61dae16e8d488e;hb=8df5e84b24ee6af0633a47521cd252eb7270b4e9;hp=295217d1d938d2352704114794300e44f69f1801;hpb=c139438a09381072403cdad55dedb8bb5d35486a;p=rugen diff --git a/src/page_status.c b/src/page_status.c index 295217d..555a766 100644 --- a/src/page_status.c +++ b/src/page_status.c @@ -203,33 +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 ) { char buf[32]; - if ( !this->app->eof[this->app->selected_unit] && - mvcp_unit_get( this->app->command, this->app->selected_unit, - "eof", buf, sizeof(buf) ) != -1) - this->app->eof[this->app->selected_unit] = buf[0]; + /* wait for any event from notifier */ + mvcp_notifier_wait( notifier, &status ); - if ( mvcp_notifier_wait( notifier, &status ) != -1 ) + /* get status for all units */ + for(i = 0; i < this->count; i++) { + 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[this->app->selected_unit] = 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 ); } } +break_unit_disconnected: + + free(statuses); + show_units( this, FALSE ); if ( !this->terminated )