From 82a53d6d2801a7b6c0dc0ea06172a26e9de9f39e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 15 Jul 2016 00:33:17 +0200 Subject: include cart/cut in progress if available diff --git a/rhimport/core.go b/rhimport/core.go index 289857c..cc4671c 100644 --- a/rhimport/core.go +++ b/rhimport/core.go @@ -60,7 +60,7 @@ func init() { fetcherInit() } -type ProgressCB func(step int, stepName string, current, total float64, userdata interface{}) bool +type ProgressCB func(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool type DoneCB func(result Result, userdata interface{}) bool type Result struct { diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index 1a957c3..c9bfc2f 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -105,7 +105,7 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool { } if data.ctx.ProgressCallBack != nil { - if keep := data.ctx.ProgressCallBack(1, "downloading", float64(data.written), data.totalSize, data.ctx.ProgressCallBackData); !keep { + if keep := data.ctx.ProgressCallBack(1, "downloading", float64(data.written), data.totalSize, 0, 0, data.ctx.ProgressCallBackData); !keep { data.ctx.ProgressCallBack = nil } } @@ -448,7 +448,7 @@ func fetchFileDirConvert(ctx *Context, res *Result, origSrc *os.File, sizeTotal written += uint64(w) if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "fetching", float64(written), float64(sizeTotal), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "fetching", float64(written), float64(sizeTotal), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -534,7 +534,7 @@ func fetchFileDir(ctx *Context, res *Result, uri *url.URL, dir string, convert b } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "fetching", 0.0, float64(size), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "fetching", 0.0, float64(size), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -551,7 +551,7 @@ func fetchFileDir(ctx *Context, res *Result, uri *url.URL, dir string, convert b } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "fetching", float64(size), float64(size), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "fetching", float64(size), float64(size), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -576,14 +576,14 @@ func fetchFileFake(ctx *Context, res *Result, uri *url.URL) error { return nil } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "faking", float64(i), float64(duration), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "faking", float64(i), float64(duration), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } time.Sleep(100 * time.Millisecond) } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "faking", float64(duration), float64(duration), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "faking", float64(duration), float64(duration), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -627,7 +627,7 @@ func writeAttachmentFile(ctx *Context, res *Result, sizeTotal uint64, conv Fetch written += uint64(w) if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "receiving", float64(written), float64(sizeTotal), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "receiving", float64(written), float64(sizeTotal), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -673,7 +673,7 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error { } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(1, "receiving", 0.0, float64(sizeTotal), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(1, "receiving", 0.0, float64(sizeTotal), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } diff --git a/rhimport/importer.go b/rhimport/importer.go index 5f2f40d..bcaf84f 100644 --- a/rhimport/importer.go +++ b/rhimport/importer.go @@ -312,7 +312,7 @@ func importAudio(ctx *Context, res *Result) (err error) { } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(3, "importing", ulnow, ultotal, ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(3, "importing", ulnow, ultotal, ctx.Cart, ctx.Cut, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } diff --git a/rhimport/normalizer.go b/rhimport/normalizer.go index d99984c..3f56151 100644 --- a/rhimport/normalizer.go +++ b/rhimport/normalizer.go @@ -72,7 +72,7 @@ func runNormalizer(ctx *Context, src *os.File, size int64) (err error) { } written += w if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(2, "normalizing", float64(written), float64(size), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(2, "normalizing", float64(written), float64(size), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -92,7 +92,7 @@ func NormalizeFile(ctx *Context) (err error) { if ctx.LoudnessCorr == 0.0 { rhl.Println("NormalizeFile: skipping normalization since the gain = 0.0dB") if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(2, "normalizing", 1.0, 1.0, ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(2, "normalizing", 1.0, 1.0, 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -115,7 +115,7 @@ func NormalizeFile(ctx *Context) (err error) { } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(2, "normalizing", 0.0, float64(size), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(2, "normalizing", 0.0, float64(size), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } @@ -132,7 +132,7 @@ func NormalizeFile(ctx *Context) (err error) { } if ctx.ProgressCallBack != nil { - if keep := ctx.ProgressCallBack(2, "normalizing", float64(size), float64(size), ctx.ProgressCallBackData); !keep { + if keep := ctx.ProgressCallBack(2, "normalizing", float64(size), float64(size), 0, 0, ctx.ProgressCallBackData); !keep { ctx.ProgressCallBack = nil } } diff --git a/rhimport/session.go b/rhimport/session.go index f260aaa..2059525 100644 --- a/rhimport/session.go +++ b/rhimport/session.go @@ -72,6 +72,8 @@ type ProgressData struct { StepName string Current float64 Total float64 + Cart uint + Cut uint } type sessionAddProgressHandlerResponse struct { @@ -94,9 +96,9 @@ type sessionAddDoneHandlerRequest struct { response chan<- sessionAddDoneHandlerResponse } -func sessionProgressCallback(step int, stepName string, current, total float64, userdata interface{}) bool { +func sessionProgressCallback(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool { out := userdata.(chan<- ProgressData) - out <- ProgressData{step, stepName, current, total} + out <- ProgressData{step, stepName, current, total, cart, cut} return true } @@ -173,7 +175,7 @@ func (self *Session) addDoneHandler(userdata interface{}, cb DoneCB) (resp sessi func (self *Session) callProgressHandler(p *ProgressData) { for _, cb := range self.progressCBs { if cb.cb != nil { - if keep := cb.cb(p.Step, p.StepName, p.Current, p.Total, cb.userdata); !keep { + if keep := cb.cb(p.Step, p.StepName, p.Current, p.Total, p.Cart, p.Cut, cb.userdata); !keep { cb.cb = nil } } -- cgit v0.10.2