diff --git a/doc.go b/doc.go index 81a5829..b03a5be 100644 --- a/doc.go +++ b/doc.go @@ -1,4 +1,4 @@ -// Copyright 2018 The ZikiChomgo Authors. All rights reserved. Use of this source +// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source // code is governed by a license that can be found in the License file. // Package ext houses zc collaboration with external imports. diff --git a/flac/decoder.go b/flac/decoder.go index 03dfb1b..642c3ad 100644 --- a/flac/decoder.go +++ b/flac/decoder.go @@ -1,4 +1,4 @@ -// Copyright 2018 The ZikiChomgo Authors. All rights reserved. Use of this source +// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source // code is governed by a license that can be found in the License file. // TODO: add seek support; only enabled in the dev branch of mewkiz/flac. diff --git a/flac/decoder_test.go b/flac/decoder_test.go index 36660fb..81aedbc 100644 --- a/flac/decoder_test.go +++ b/flac/decoder_test.go @@ -1,9 +1,33 @@ -// Copyright 2018 The ZikiChomgo Authors. All rights reserved. Use of this source +// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source // code is governed by a license that can be found in the License file. package flac -import "zikichombo.org/sound" +import ( + "os" + "testing" + + "zikichombo.org/codec" + "zikichombo.org/sio" + "zikichombo.org/sound" +) // Assert that flac.Decoder implements the sound.Source interface. var _ sound.Source = (*Decoder)(nil) + +func TestRegister(t *testing.T) { + co, err := codec.CodecFor(".flac", nil) + if err != nil { + t.Fatal(err) + } + f, err := os.Open("0.flac") + if err != nil { + t.Fatal(err) + } + dec, _, err := co.Decoder(f) + if err != nil { + t.Fatal(err) + } + defer dec.Close() + sio.Play(dec) +} diff --git a/flac/doc.go b/flac/doc.go index e1b26f7..7ff4748 100644 --- a/flac/doc.go +++ b/flac/doc.go @@ -1,4 +1,4 @@ -// Copyright 2018 The ZikiChomgo Authors. All rights reserved. Use of this source +// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source // code is governed by a license that can be found in the License file. // Package flac provides decoding of FLAC audio streams. diff --git a/flac/register.go b/flac/register.go new file mode 100644 index 0000000..2fa0035 --- /dev/null +++ b/flac/register.go @@ -0,0 +1,29 @@ +// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source +// code is governed by a license that can be found in the License file. + +package flac + +import ( + "io" + + "zikichombo.org/codec" + "zikichombo.org/sound" + "zikichombo.org/sound/sample" +) + +type flacCodec struct { + codec.NullCodec +} + +func (f *flacCodec) Extensions() []string { + return []string{".flc", ".flac"} +} + +func (f *flacCodec) Decoder(rc io.ReadCloser) (sound.Source, sample.Codec, error) { + dec, err := NewDecoder(rc) + return dec, codec.AnySampleCodec, err +} + +func init() { + codec.RegisterCodec(&flacCodec{}) +}