reset line to avoid duplicating last item
[rugen] / src / page_status.c
index 1047ec6..c526a29 100644 (file)
@@ -87,7 +87,6 @@ static int show_status( page_status this, mvcp_status status )
 {
        GtkWidget *widget = this_page_get_widget( ( page )this );
        char temp[ 1024 ] = "";
-       char temp2[ 1024 ];
        char label_name[ 256 ];
 
        format_status_string(temp, sizeof(temp), status , "\n");
@@ -98,11 +97,26 @@ static int show_status( page_status this, mvcp_status status )
        gtk_label_set_text( GTK_LABEL( widget ), temp );
        if ( status->unit == dv1394app_get_selected_unit( this->app ) )
        {
-               format_status_string(temp, sizeof(temp), status , " ");
-               sprintf( temp2, "U%d - %s", status->unit, temp );
+               char tc[12];
+
+               snprintf( temp, sizeof(temp), "U%d - [%s] %s",
+                       status->unit,
+                       status_to_text( status ),
+                       status->clip);
                widget = lookup_widget( dv1394app_get_widget( this->app ), "statusbar" );
                gtk_statusbar_pop( GTK_STATUSBAR( widget ), this->context );
-               gtk_statusbar_push( GTK_STATUSBAR( widget ), this->context, temp2 );
+               gtk_statusbar_push( GTK_STATUSBAR( widget ), this->context, temp );
+
+               widget = lookup_widget( dv1394app_get_widget( this->app ), "bbt_label_1a" );
+               snprintf( temp, sizeof(temp), "POS: %s",
+                       frames2tc(status->position, status->fps, tc));
+               gtk_label_set_text( GTK_LABEL( widget ), temp );
+
+               widget = lookup_widget( dv1394app_get_widget( this->app ), "bbt_label_1b" );
+               snprintf( temp, sizeof(temp), "REM: %s",
+                       frames2tc(status->out - status->position, status->fps, tc));
+               gtk_label_set_text( GTK_LABEL( widget ), temp );
+
                dv1394app_show_status( this->app, status );
        }
        gdk_flush();
@@ -203,31 +217,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 )