summaryrefslogtreecommitdiff
path: root/rhimport/converter.go
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport/converter.go')
-rw-r--r--rhimport/converter.go43
1 files changed, 21 insertions, 22 deletions
diff --git a/rhimport/converter.go b/rhimport/converter.go
index f7bcb0a..dab3309 100644
--- a/rhimport/converter.go
+++ b/rhimport/converter.go
@@ -40,7 +40,7 @@ type FetchConverter interface {
GetResult() (result string, err error, loudnessCorr float64)
}
-type ConverterResult struct {
+type FetchConverterResult struct {
output string
err error
loudnessCorr float64
@@ -95,7 +95,7 @@ func (c *NullFetchConverter) GetResult() (result string, err error, loudnessCorr
type FFMpegFetchConverter struct {
cmd *exec.Cmd
pipe io.WriteCloser
- result chan ConverterResult
+ result chan FetchConverterResult
}
func NewFFMpegFetchConverter(filename string, metadata map[string]string) (ff *FFMpegFetchConverter, filenameFlac string, err error) {
@@ -114,10 +114,10 @@ func NewFFMpegFetchConverter(filename string, metadata map[string]string) (ff *F
return nil, "", err
}
- ff.result = make(chan ConverterResult, 1)
+ ff.result = make(chan FetchConverterResult, 1)
go func() {
output, err := ff.cmd.CombinedOutput()
- ff.result <- ConverterResult{strings.TrimSpace(string(output)), err, 0.0}
+ ff.result <- FetchConverterResult{strings.TrimSpace(string(output)), err, 0.0}
}()
return
}
@@ -139,8 +139,7 @@ func (ff *FFMpegFetchConverter) GetResult() (result string, err error, loudnessC
}
//
-// FFMpeg/BS1770 Converter: converts all files into flac and calculates loudness correction value
-// using ITU BS1770 (EBU R128)
+// BS1770 Converter: calculates loudness correction value using ITU BS1770 (EBU R128)
//
type BS1770FetchConverter struct {
@@ -148,7 +147,7 @@ type BS1770FetchConverter struct {
file *os.File
pipe io.WriteCloser
multi io.Writer
- result chan ConverterResult
+ result chan FetchConverterResult
}
func NewBS1770FetchConverter(filename string, metadata map[string]string) (bs *BS1770FetchConverter, newFilename string, err error) {
@@ -167,20 +166,20 @@ func NewBS1770FetchConverter(filename string, metadata map[string]string) (bs *B
bs.cmd.Stdout = &bsStdout
bs.cmd.Stderr = &bsStderr
- bs.result = make(chan ConverterResult, 1)
+ bs.result = make(chan FetchConverterResult, 1)
go func() {
if err := bs.cmd.Run(); err != nil {
- bs.result <- ConverterResult{strings.TrimSpace(string(bsStderr.String())), err, 0.0}
+ bs.result <- FetchConverterResult{strings.TrimSpace(string(bsStderr.String())), err, 0.0}
}
res, err := NewBS1770ResultFromXML(&bsStdout)
if err != nil {
- bs.result <- ConverterResult{bsStdout.String(), err, 0.0}
+ bs.result <- FetchConverterResult{bsStdout.String(), err, 0.0}
}
if len(res.Album.Tracks) == 0 {
- bs.result <- ConverterResult{bsStdout.String(), fmt.Errorf("bs1770gain returned no/invalid result"), 0.0}
+ bs.result <- FetchConverterResult{bsStdout.String(), fmt.Errorf("bs1770gain returned no/invalid result"), 0.0}
}
- bs.result <- ConverterResult{"", nil, res.Album.Tracks[0].Integrated.LU}
+ bs.result <- FetchConverterResult{"", nil, res.Album.Tracks[0].Integrated.LU}
}()
return
}
@@ -215,8 +214,8 @@ type FFMpegBS1770FetchConverter struct {
ffmpeg *exec.Cmd
bs1770 *exec.Cmd
pipe io.WriteCloser
- resultFF chan ConverterResult
- resultBS chan ConverterResult
+ resultFF chan FetchConverterResult
+ resultBS chan FetchConverterResult
}
func NewFFMpegBS1770FetchConverter(filename string, metadata map[string]string) (ff *FFMpegBS1770FetchConverter, filenameFlac string, err error) {
@@ -248,26 +247,26 @@ func NewFFMpegBS1770FetchConverter(filename string, metadata map[string]string)
ff.bs1770.Stdout = &bsStdout
ff.bs1770.Stderr = &bsStderr
- ff.resultFF = make(chan ConverterResult, 1)
- ff.resultBS = make(chan ConverterResult, 1)
+ ff.resultFF = make(chan FetchConverterResult, 1)
+ ff.resultBS = make(chan FetchConverterResult, 1)
go func() {
err := ff.ffmpeg.Run()
ffstdout.Close()
- ff.resultFF <- ConverterResult{strings.TrimSpace(string(ffStderr.String())), err, 0.0}
+ ff.resultFF <- FetchConverterResult{strings.TrimSpace(string(ffStderr.String())), err, 0.0}
}()
go func() {
if err := ff.bs1770.Run(); err != nil {
- ff.resultBS <- ConverterResult{strings.TrimSpace(string(bsStderr.String())), err, 0.0}
+ ff.resultBS <- FetchConverterResult{strings.TrimSpace(string(bsStderr.String())), err, 0.0}
}
res, err := NewBS1770ResultFromXML(&bsStdout)
if err != nil {
- ff.resultBS <- ConverterResult{bsStdout.String(), err, 0.0}
+ ff.resultBS <- FetchConverterResult{bsStdout.String(), err, 0.0}
}
if len(res.Album.Tracks) == 0 {
- ff.resultBS <- ConverterResult{bsStdout.String(), fmt.Errorf("bs1770gain returned no/invalid result"), 0.0}
+ ff.resultBS <- FetchConverterResult{bsStdout.String(), fmt.Errorf("bs1770gain returned no/invalid result"), 0.0}
}
- ff.resultBS <- ConverterResult{"", nil, res.Album.Tracks[0].Integrated.LU}
+ ff.resultBS <- FetchConverterResult{"", nil, res.Album.Tracks[0].Integrated.LU}
}()
return
}
@@ -281,7 +280,7 @@ func (ff *FFMpegBS1770FetchConverter) Close() (err error) {
}
func (ff *FFMpegBS1770FetchConverter) GetResult() (result string, err error, loudnessCorr float64) {
- var rff, rbs ConverterResult
+ var rff, rbs FetchConverterResult
if ff.resultFF != nil {
rff = <-ff.resultFF
}