summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-14 21:41:35 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-14 21:41:35 (GMT)
commit09d298877fdf473ebe5a997b20a42b4e69355c67 (patch)
treea82d64859151bccf032a86f79d26b537f8323728 /rhimport
parent1a409362450ea903019005bc48145be1da14848d (diff)
simplified call to converter GetResult
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/converter.go30
-rw-r--r--rhimport/fetcher.go11
2 files changed, 20 insertions, 21 deletions
diff --git a/rhimport/converter.go b/rhimport/converter.go
index f842ef3..0546b97 100644
--- a/rhimport/converter.go
+++ b/rhimport/converter.go
@@ -38,7 +38,7 @@ import (
type FetchConverter interface {
io.WriteCloser
- GetResult() (result string, err error, loudnessCorr float64)
+ GetResult(ctx *Context, res *Result) (result string, err error)
}
type FetchConverterResult struct {
@@ -85,8 +85,8 @@ func (c *NullFetchConverter) Close() (err error) {
return c.file.Close()
}
-func (c *NullFetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
- return "", nil, 0.0
+func (c *NullFetchConverter) GetResult(ctx *Context, res *Result) (result string, err error) {
+ return "", nil
}
//
@@ -131,12 +131,13 @@ func (ff *FFMpegFetchConverter) Close() (err error) {
return ff.pipe.Close()
}
-func (ff *FFMpegFetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
+func (ff *FFMpegFetchConverter) GetResult(ctx *Context, res *Result) (result string, err error) {
if ff.result != nil {
r := <-ff.result
- return r.output, r.err, r.loudnessCorr
+ ctx.LoudnessCorr = r.loudnessCorr
+ return r.output, r.err
}
- return "", nil, 0.0
+ return "", nil
}
//
@@ -198,12 +199,13 @@ func (bs *BS1770FetchConverter) Close() (err error) {
return errPipe
}
-func (bs *BS1770FetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
+func (bs *BS1770FetchConverter) GetResult(ctx *Context, res *Result) (result string, err error) {
if bs.result != nil {
r := <-bs.result
- return r.output, r.err, r.loudnessCorr
+ ctx.LoudnessCorr = r.loudnessCorr
+ return r.output, r.err
}
- return "", nil, 0.0
+ return "", nil
}
//
@@ -281,7 +283,7 @@ func (ff *FFMpegBS1770FetchConverter) Close() (err error) {
return ff.pipe.Close()
}
-func (ff *FFMpegBS1770FetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
+func (ff *FFMpegBS1770FetchConverter) GetResult(ctx *Context, res *Result) (result string, err error) {
var rff, rbs FetchConverterResult
if ff.resultFF != nil {
rff = <-ff.resultFF
@@ -290,11 +292,11 @@ func (ff *FFMpegBS1770FetchConverter) GetResult() (result string, err error, lou
rbs = <-ff.resultBS
}
if rff.err != nil {
- return rff.output, fmt.Errorf("ffmpeg: %v", rff.err), 0.0
+ return rff.output, fmt.Errorf("ffmpeg: %v", rff.err)
}
if rbs.err != nil {
- return rbs.output, fmt.Errorf("bs1770gain: %v", rbs.err), 0.0
+ return rbs.output, fmt.Errorf("bs1770gain: %v", rbs.err)
}
-
- return "", nil, rbs.loudnessCorr
+ ctx.LoudnessCorr = rbs.loudnessCorr
+ return "", nil
}
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index 3933105..4d942fa 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -238,7 +238,7 @@ func fetchFileCurl(ctx *Context, res *Result, uri *url.URL) (err error) {
if cbdata.conv != nil {
cbdata.conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr, ctx.LoudnessCorr = cbdata.conv.GetResult()
+ convOut, convErr = cbdata.conv.GetResult(ctx, res)
}
if err != nil || cbdata.writeError != nil || convErr != nil {
if cbdata.conv != nil {
@@ -369,7 +369,7 @@ func fetchFileArchiv(ctx *Context, res *Result, uri *url.URL) (err error) {
if cbdata.conv != nil {
cbdata.conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr, ctx.LoudnessCorr = cbdata.conv.GetResult()
+ convOut, convErr = cbdata.conv.GetResult(ctx, res)
}
if err != nil || cbdata.writeError != nil || convErr != nil {
if cbdata.conv != nil {
@@ -456,9 +456,7 @@ func fetchFileDirConvert(ctx *Context, res *Result, origSrc *os.File, sizeTotal
conv.Close()
rhl.Printf("waiting for converter to finish...")
- var convOut string
- var convErr error
- if convOut, convErr, ctx.LoudnessCorr = conv.GetResult(); convErr != nil {
+ if convOut, convErr := conv.GetResult(ctx, res); convErr != nil {
if convOut != "" {
rhl.Printf("converter error: %v; converter output: %s", convErr, convOut)
}
@@ -674,7 +672,7 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error {
err = writeAttachmentFile(ctx, res, sizeTotal, conv)
conv.Close()
rhl.Printf("waiting for converter to finish...")
- convOut, convErr, loudnessCorr := conv.GetResult()
+ convOut, convErr := conv.GetResult(ctx, res)
if err != nil {
return err
}
@@ -684,7 +682,6 @@ func fetchFileAttachment(ctx *Context, res *Result, uri *url.URL) error {
}
return fmt.Errorf("converter error: %v; converter output: %s", convErr, convOut)
}
- ctx.LoudnessCorr = loudnessCorr
rhdl.Printf("converter: loudness correction = %.2f dB", ctx.LoudnessCorr)
if ctx.SourceFilePolicy == Auto {