X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=EsounD.git;a=blobdiff_plain;f=Sound%2FEsounD%2FInternals.hs;h=997899a6291e0ae05a100110a5300564e45d0b58;hp=735ce6324762dd14672a688df383b65515e6e727;hb=dddadcc3746636546f4010e37aafef211d75cb0d;hpb=a3232311af5c412a47542ff5af7ea94af0c44422 diff --git a/Sound/EsounD/Internals.hs b/Sound/EsounD/Internals.hs index 735ce63..997899a 100644 --- a/Sound/EsounD/Internals.hs +++ b/Sound/EsounD/Internals.hs @@ -33,28 +33,34 @@ import System.Posix.IO import System.Posix.Types class Storable fr ⇒ Frame fr where - frameFmt ∷ fr → C'esd_format_t + frameFmt ∷ fr → C'esd_format_t + frameSize ∷ fr → Int instance Frame Int8 where - frameFmt _ = c'ESD_BITS8 + frameFmt _ = c'ESD_BITS8 + frameSize _ = 1 instance Frame Int16 where - frameFmt _ = c'ESD_BITS16 + frameFmt _ = c'ESD_BITS16 + frameSize _ = 2 class Channels ch where - channelFmt ∷ ch → C'esd_format_t + channelFmt ∷ ch → C'esd_format_t + numChannels ∷ ch → Int -- Mono data Mono instance Channels Mono where - channelFmt _ = c'ESD_MONO + channelFmt _ = c'ESD_MONO + numChannels _ = 1 -- Stereo data Stereo instance Channels Stereo where - channelFmt _ = c'ESD_STEREO + channelFmt _ = c'ESD_STEREO + numChannels _ = 2 {-# INLINE interleave #-} interleave ∷ Storable α ⇒ L.Vector α → L.Vector α → L.Vector α @@ -98,7 +104,7 @@ withCStrOrNull ∷ Maybe String → (CString → IO a) → IO a withCStrOrNull Nothing f = f nullPtr withCStrOrNull (Just s) f = withCString s f -failOnError ∷ Monad m ⇒ String → (CInt → Bool) → CInt → m CInt +failOnError ∷ Monad m ⇒ String → (α → Bool) → α → m α failOnError msg isErr rv | isErr rv = fail msg | otherwise = return rv