| 608 | } |
| 609 | |
| 610 | static void UpdateState( hb_work_private_t * r ) |
| 611 | { |
| 612 | hb_state_t state; |
| 613 | uint64_t now; |
| 614 | double avg; |
| 615 | |
| 616 | if (!r->job->indepth_scan || !r->start_found) |
| 617 | { |
| 618 | // Only update state when sync.c is not handling state updates |
| 619 | return; |
| 620 | } |
| 621 | |
| 622 | now = hb_get_date(); |
| 623 | if( !r->st_first ) |
| 624 | { |
| 625 | r->st_first = now; |
| 626 | } |
| 627 | |
| 628 | hb_get_state2(r->job->h, &state); |
| 629 | #define p state.param.working |
| 630 | state.state = HB_STATE_WORKING; |
| 631 | p.progress = (float) r->last_pts / (float) r->duration; |
| 632 | if( p.progress > 1.0 ) |
| 633 | { |
| 634 | p.progress = 1.0; |
| 635 | } |
| 636 | p.rate_cur = 0.0; |
| 637 | p.rate_avg = 0.0; |
| 638 | if (now > r->st_first) |
| 639 | { |
| 640 | int eta; |
| 641 | |
| 642 | avg = 1000.0 * (double)r->last_pts / (now - r->st_first); |
| 643 | eta = (r->duration - r->last_pts) / avg; |
| 644 | if (eta < 0) |
| 645 | { |
| 646 | eta = 0; |
| 647 | } |
| 648 | p.eta_seconds = eta; |
| 649 | p.hours = eta / 3600; |
| 650 | p.minutes = ( eta % 3600 ) / 60; |
| 651 | p.seconds = eta % 60; |
| 652 | } |
| 653 | else |
| 654 | { |
| 655 | p.hours = -1; |
| 656 | p.minutes = -1; |
| 657 | p.seconds = -1; |
| 658 | } |
| 659 | #undef p |
| 660 | |
| 661 | hb_set_state( r->job->h, &state ); |
| 662 | } |
| 663 | |
| 664 | /*********************************************************************** |
| 665 | * GetFifoForId |
no test coverage detected