X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fpage_status.c;h=295217d1d938d2352704114794300e44f69f1801;hb=2b74d3078e1c7e23dc617ca51ac2adbdcb65fe76;hp=07993530a499e9ffd4b4197ab9c455360bdaa370;hpb=b9bc35b8268f383f71be77d7e90275c14c6f86f8;p=rugen diff --git a/src/page_status.c b/src/page_status.c index 0799353..295217d 100644 --- a/src/page_status.c +++ b/src/page_status.c @@ -43,6 +43,7 @@ typedef struct guint context; int unit; int count; + struct page_t *parent_page; } *page_status, page_status_t; @@ -51,6 +52,37 @@ static GtkWidget *this_page_get_widget( page ); /** Show the status associated to a unit. */ +static char* status_to_text( mvcp_status status ) +{ + switch( status->status ) + { + case unit_offline: return "offline"; break; + case unit_undefined: return "undefined"; break; + case unit_not_loaded: return "unloaded"; break; + case unit_stopped: return "stopped"; break; + case unit_playing: return "playing"; break; + case unit_paused: return "paused"; break; + case unit_disconnected: return "disconnect"; break; + case unit_unknown: return "unknown"; break; + } + return "unknown"; +} + +static void format_status_string(char* buf, int size, mvcp_status status , char* sep) +{ + char tc1[12], tc2[12], tc3[12]; + + snprintf( buf, size, + "[%s]%sIN:%s%sPOS:%s%sOUT:%s%s%s%s", + status_to_text( status ), sep, + frames2tc(status->in, status->fps, tc1), sep, + frames2tc(status->position, status->fps, tc2), sep, + frames2tc(status->out, status->fps, tc3), sep, + status->clip, sep + ); + +} + static int show_status( page_status this, mvcp_status status ) { GtkWidget *widget = this_page_get_widget( ( page )this ); @@ -58,38 +90,7 @@ static int show_status( page_status this, mvcp_status status ) char temp2[ 1024 ]; char label_name[ 256 ]; - sprintf( temp, "%05d %05d %05d %s [", status->in, status->position, status->out, status->clip ); - - switch( status->status ) - { - case unit_offline: - strcat( temp, "offline" ); - break; - case unit_undefined: - strcat( temp, "undefined" ); - break; - case unit_not_loaded: - strcat( temp, "unloaded" ); - break; - case unit_stopped: - strcat( temp, "stopped" ); - break; - case unit_playing: - strcat( temp, "playing" ); - break; - case unit_paused: - strcat( temp, "paused" ); - break; - case unit_disconnected: - strcat( temp, "disconnect" ); - break; - default: - strcat( temp, "unknown" ); - break; - } - - strcat( temp, "]" ); - + format_status_string(temp, sizeof(temp), status , "\n"); sprintf( label_name, "label_unit_%d", status->unit ); gdk_threads_enter(); @@ -97,6 +98,7 @@ 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 ); widget = lookup_widget( dv1394app_get_widget( this->app ), "statusbar" ); gtk_statusbar_pop( GTK_STATUSBAR( widget ), this->context ); @@ -209,10 +211,20 @@ static void *status_thread( void *arg ) 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]; + if ( mvcp_notifier_wait( notifier, &status ) != -1 ) { if ( status.status == unit_disconnected ) + { + this->app->eof[this->app->selected_unit] = 0; break; + } if ( show_status( this, &status ) ) show_units( this, TRUE ); } @@ -260,7 +272,7 @@ static GtkWidget *this_page_get_widget( page super ) { page_status this = ( page_status )super; if ( this->widget == NULL ) - this->widget = create_page_status( ); + this->widget = this->parent_page->get_widget(this->parent_page); return this->widget; } @@ -304,12 +316,13 @@ static void this_page_close( page super ) free( this ); } -page page_status_init( dv1394app app ) +page page_status_init( dv1394app app, struct page_t *parent_page ) { page_status this = calloc( 1, sizeof( page_status_t ) ); int index = 0; GtkWidget *widget; - + + this->parent_page = parent_page; this->parent.get_widget = this_page_get_widget; this->parent.get_toolbar_info = this_page_get_toolbar_info; this->parent.on_connect = this_page_on_connect;