]> gitweb @ CieloNegro.org - wavpack.git/blobdiff - Codec/Audio/WavPack/Block.hs
slightly changed the type of findNextHeader
[wavpack.git] / Codec / Audio / WavPack / Block.hs
index 0ca454ada59fb2b3f224655d73d3817baabbd698..ac3ef802dd663c6f427e2b4cad6efbcf548533ed 100644 (file)
@@ -120,7 +120,7 @@ data BlockFlags
       -- | maximum magnitude of decoded data (number of bits integers
       --   require minus 1)
       , bfMaxMagnitude   ∷ !Word8
-      -- | sampling rate (0x1111 = unknown/custom) (THINKME)
+      -- | sampling rate ('Nothing' = unknown/custom)
       , bfSamplingRate   ∷ !(Maybe Int)
       -- | 'True' = use IIR for negative hybrid noise shaping
       , bfIIRShaping     ∷ !Bool
@@ -234,19 +234,20 @@ decodeSamplingRate 0x0D = Just  96000
 decodeSamplingRate 0x0E = Just 192000
 decodeSamplingRate    _ =     Nothing
 
-findNextHeader ∷ L.ByteString → (Maybe BlockHeader, L.ByteString)
+-- | Find a WavPack header in a given stream. Returns 'Nothing' if no
+-- headers are found.
+findNextHeader ∷ L.ByteString -- ^ the input
+               → Maybe (BlockHeader, L.ByteString) -- ^ a header and the rest of input
 findNextHeader src
     = case L.uncons src of
         Nothing
-            → (Nothing, L.empty)
-
+            → Nothing
         Just (119, src') -- 'w'
             → let (header, rest) = L.splitAt 32 src
                in
                  case L.length header ≡ 32 of
                    False
-                       → (Nothing, L.empty)
-
+                       → Nothing
                    True
                        → let Just (magicW, header'  ) = L.uncons header
                              Just (magicV, header'' ) = L.uncons header'
@@ -257,9 +258,8 @@ findNextHeader src
                                -- Found the magic 'wvpk'.
                                let bh = runGet get header
                                in
-                                 (Just bh, rest)
+                                 Just (bh, rest)
                            else
                                findNextHeader src'
-
         Just (_, src')
             → findNextHeader src'