refactor: code cleaning

This commit is contained in:
Unlock Music Dev
2022-11-20 02:47:28 +08:00
parent 8e068b9c8d
commit f6748d644d
7 changed files with 41 additions and 30 deletions

View File

@@ -22,13 +22,11 @@ var (
)
type Decoder struct {
rd io.ReadSeeker
rd io.ReadSeeker // rd is the original file reader
offset int
cipher common.StreamDecoder
outputExt string
mask byte
audio []byte
}
func (d *Decoder) GetAudioExt() string {
@@ -43,6 +41,8 @@ func NewDecoder(rd io.ReadSeeker) common.Decoder {
return &Decoder{rd: rd}
}
// Validate checks if the file is a valid xiami .xm file.
// rd will set to the beginning of the encrypted audio data.
func (d *Decoder) Validate() error {
header := make([]byte, 16) // xm header is fixed to 16 bytes