X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=EsounD.git;a=blobdiff_plain;f=Sound%2FEsounD%2FInternals.hs;h=4f57a3b07e694772fc507bd2590041311411e73b;hp=f75f99a0dc1770777e9aa196505058a1854539f3;hb=2c9350d4762d69bbfcdc58212e27506c3d4f7494;hpb=332de27c05d195598689979c035bd136a47f4394 diff --git a/Sound/EsounD/Internals.hs b/Sound/EsounD/Internals.hs index f75f99a..4f57a3b 100644 --- a/Sound/EsounD/Internals.hs +++ b/Sound/EsounD/Internals.hs @@ -1,3 +1,7 @@ +{-# LANGUAGE + EmptyDataDecls + , UnicodeSyntax + #-} module Sound.EsounD.Internals ( Frame(..) @@ -10,17 +14,17 @@ module Sound.EsounD.Internals , withCStrOrNull ) where - import Bindings.EsounD import Data.Int import Foreign.C.String import Foreign.C.Types import Foreign.Ptr +import Foreign.Storable import System.IO import System.Posix.IO import System.Posix.Types -class Frame fr where +class Storable fr ⇒ Frame fr where frameFmt ∷ fr → C'esd_format_t instance Frame Int8 where @@ -40,16 +44,15 @@ data Stereo instance Channels Stereo where channelFmt _ = c'ESD_STEREO - -wrapSocket :: String -> CInt → IO Handle +wrapSocket ∷ String → CInt → IO Handle wrapSocket e (-1) = fail e wrapSocket _ fd = fdToHandle (Fd fd) -closeSocket :: Handle → IO () +closeSocket ∷ Handle → IO () closeSocket h = do (Fd fd) ← handleToFd h _ ← c'esd_close (fromIntegral fd) return () -withCStrOrNull :: Maybe String → (CString → IO a) → IO a +withCStrOrNull ∷ Maybe String → (CString → IO a) → IO a withCStrOrNull Nothing f = f nullPtr withCStrOrNull (Just s) f = withCString s f