From 6f1cdc5b4f5eda4b0bbf5047551f59feb2ddd809 Mon Sep 17 00:00:00 2001 From: Unlock Music Dev Date: Sat, 19 Nov 2022 07:25:45 +0800 Subject: [PATCH] fix: raw don't access registry --- algo/common/raw.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/algo/common/raw.go b/algo/common/raw.go index 5f4e9e6..65d8c11 100644 --- a/algo/common/raw.go +++ b/algo/common/raw.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "strings" ) type RawDecoder struct { @@ -26,13 +25,12 @@ func (d *RawDecoder) Validate() error { return fmt.Errorf("seek file failed: %v", err) } - for ext, sniffer := range snifferRegistry { - if sniffer(header) { - d.audioExt = strings.ToLower(ext) - return nil - } + var ok bool + d.audioExt, ok = SniffAll(header) + if !ok { + return errors.New("raw: sniff audio type failed") } - return errors.New("audio doesn't recognized") + return nil } func (d *RawDecoder) Read(p []byte) (n int, err error) {