mirror of https://bitbucket.org/ausocean/av.git
av/stream/flac: moved readAll to after loop
This commit is contained in:
parent
6fda0b3c3f
commit
155134eeed
|
@ -25,8 +25,6 @@ func Decode(buf []byte) ([]byte, error) {
|
||||||
enc := wav.NewEncoder(ws, int(stream.Info.SampleRate), int(stream.Info.BitsPerSample), int(stream.Info.NChannels), wavAudioFormat)
|
enc := wav.NewEncoder(ws, int(stream.Info.SampleRate), int(stream.Info.BitsPerSample), int(stream.Info.NChannels), wavAudioFormat)
|
||||||
defer enc.Close()
|
defer enc.Close()
|
||||||
var data []int
|
var data []int
|
||||||
var out []byte
|
|
||||||
var d []byte
|
|
||||||
for {
|
for {
|
||||||
// Decode FLAC audio samples.
|
// Decode FLAC audio samples.
|
||||||
frame, err := stream.ParseNext()
|
frame, err := stream.ParseNext()
|
||||||
|
@ -55,12 +53,10 @@ func Decode(buf []byte) ([]byte, error) {
|
||||||
if err := enc.Write(buf); err != nil {
|
if err := enc.Write(buf); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
d, err = ioutil.ReadAll(ws.Reader())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
out = append(out, d...)
|
|
||||||
}
|
}
|
||||||
|
d, err := ioutil.ReadAll(ws.Reader())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue