mirror of
https://github.com/wader/fq.git
synced 2024-12-25 22:34:14 +03:00
e9d9f8aef9
Rename s/interface{}/any/g Preparation for using generics in decode API and native jq funcations etc Remove some unused linter ignores as linter has been fixed
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package flac
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/format/registry"
|
|
"github.com/wader/fq/pkg/decode"
|
|
)
|
|
|
|
var flacMetadatablockFormat decode.Group
|
|
|
|
func init() {
|
|
registry.MustRegister(decode.Format{
|
|
Name: format.FLAC_METADATABLOCKS,
|
|
Description: "FLAC metadatablocks",
|
|
DecodeFn: metadatablocksDecode,
|
|
RootArray: true,
|
|
RootName: "metadatablocks",
|
|
Dependencies: []decode.Dependency{
|
|
{Names: []string{format.FLAC_METADATABLOCK}, Group: &flacMetadatablockFormat},
|
|
},
|
|
})
|
|
}
|
|
|
|
func metadatablocksDecode(d *decode.D, in any) any {
|
|
flacMetadatablocksOut := format.FlacMetadatablocksOut{}
|
|
|
|
isLastBlock := false
|
|
for !isLastBlock {
|
|
dv, v := d.FieldFormat("metadatablock", flacMetadatablockFormat, nil)
|
|
flacMetadatablockOut, ok := v.(format.FlacMetadatablockOut)
|
|
if dv != nil && !ok {
|
|
panic(fmt.Sprintf("expected FlacMetadatablocksOut, got %#+v", flacMetadatablockOut))
|
|
}
|
|
isLastBlock = flacMetadatablockOut.IsLastBlock
|
|
if flacMetadatablockOut.HasStreamInfo {
|
|
flacMetadatablocksOut.HasStreamInfo = true
|
|
flacMetadatablocksOut.StreamInfo = flacMetadatablockOut.StreamInfo
|
|
}
|
|
}
|
|
|
|
return flacMetadatablocksOut
|
|
}
|