X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=wavpack.git;a=blobdiff_plain;f=Codec%2FAudio%2FWavPack%2FBlock.hs;h=4ecdb7d8d40e5530f6e8e8846d8ef776320a104a;hp=aff1da3249c0904256f0565e4ad49326816620b9;hb=98a1dd78c7bb73c5d66f4773b63bbc5b94e7e618;hpb=fda0a74785ab6da03f98be513de5cd3bada1359d diff --git a/Codec/Audio/WavPack/Block.hs b/Codec/Audio/WavPack/Block.hs index aff1da3..4ecdb7d 100644 --- a/Codec/Audio/WavPack/Block.hs +++ b/Codec/Audio/WavPack/Block.hs @@ -9,7 +9,7 @@ module Codec.Audio.WavPack.Block , BlockHeader(..) , BlockFlags(..) - , findNextBlock + , readBlocks ) where import Codec.Audio.WavPack.Metadata @@ -286,10 +286,17 @@ decodeSamplingRate 0x0D = S.Just 96000 decodeSamplingRate 0x0E = S.Just 192000 decodeSamplingRate _ = S.Nothing --- | Find a WavPack block in a given stream. Returns 'S.Nothing' if no --- blocks are found. -findNextBlock ∷ L.ByteString -- ^ the input - → (# S.Maybe Block, L.ByteString #) -- ^ the rest of input +-- | Read WavPack blocks in a given stream lazily. +readBlocks ∷ L.ByteString → [Block] +readBlocks src + = case findNextBlock src of + (# S.Just block, src' #) + → block : readBlocks src' + (# S.Nothing, _ #) + → [] + +findNextBlock ∷ L.ByteString + → (# S.Maybe Block, L.ByteString #) findNextBlock src = case L.uncons src of Nothing