struct file *file;
dvd_file_t *vob;
+ unsigned f;
+#define SRCF_ALLPROGRESS 1u
uint32_t last_pos, limit, nsectors, ndone;
struct timeval last_time;
double wsum, wcount;
const char *mapfile; FILE *mapfp;
};
-#define SOURCE_INIT { 0, -1, 0, 0, 0, 0, 0, 0, { 0, 0 }, 0.0, 0.0, 0, 0 }
+#define SOURCE_INIT { 0, -1, 0, 0, 0, 0, 0, 0, 0, { 0, 0 }, 0.0, 0.0, 0, 0 }
static void report_progress(struct source *src, uint32_t pos)
{
char etastr[32];
struct timeval now;
int eta;
- double t, f, g, rate;
+ double percent, t, f, g, rate;
char *unit;
#define ALPHA 0.02
if (rate > 128) { rate /= 1024; unit = "M"; }
if (rate > 128) { rate /= 1024; unit = "G"; }
+ if (src->f&SRCF_ALLPROGRESS) percent = pos*100.0/src->limit;
+ else percent = src->ndone*100.0/src->nsectors;
print_progress("copied %.1f%% (%"PRIu32" of %"PRIu32"; %.1f %sB/s, ETA %s)",
- src->ndone*100.0/src->nsectors, pos, src->limit,
+ percent, pos, src->limit,
rate, unit, etastr);
if (src->file && id_kind(src->file->id) == VOB) {
append_progress(" -- %s %d %3.1f%%",
const struct event *ev;
const char *device = "/dev/dvd", *outfile = 0;
int opt, err, outfd = -1, blksz;
+ unsigned n;
size_t i;
FILE *fp;
struct buf buf = BUF_INIT;
qsort(eventq.v, eventq.n, sizeof(struct event), compare_event);
- f &= ~f_write; start = 0;
+ f &= ~f_write; start = 0; n = 0;
for (i = 0; i < eventq.n; i++) {
ev = &eventq.v[i];
switch (ev->ev) {
if (f&f_write)
bail("overlapping ranges: range from %lu still open at %"PRIu32"",
start, ev->pos);
- f |= f_write; start = ev->pos;
+ n++; f |= f_write; start = ev->pos;
break;
case EV_STOP:
f &= ~f_write;
eventq.n = i;
if (f&f_fixup) {
put_event(EV_WRITE, 0, start);
- f |= f_write;
+ n++; f |= f_write;
}
if (f&f_write) {
src.nsectors += src.limit - start;
put_event(EV_STOP, 0, src.limit);
}
+ if (n == 1 && (f&f_write))
+ src.f |= SRCF_ALLPROGRESS;
f &= ~f_write;
#ifdef DEBUG