]> gitweb @ CieloNegro.org - EsounD.git/blobdiff - Sound/EsounD/Internals.hs
Controller (partway)
[EsounD.git] / Sound / EsounD / Internals.hs
index 60cf4b922b39d02aea0e26ab24e6b7047691ee75..f4b067f0903cf30fc9a23b62ccb13dee41c5e4fe 100644 (file)
@@ -14,10 +14,10 @@ module Sound.EsounD.Internals
     , deinterleave
 
     , toLSV
-
     , wrapSocket
     , closeSocket
     , withCStrOrNull
+    , failOnError
     )
     where
 import Bindings.EsounD
@@ -28,6 +28,7 @@ import Foreign.C.String
 import Foreign.C.Types
 import Foreign.Ptr
 import Foreign.Storable
+import Prelude.Unicode
 import System.IO
 import System.Posix.IO
 import System.Posix.Types
@@ -97,3 +98,8 @@ closeSocket h = do (Fd fd) ← handleToFd h
 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 → m ()
+failOnError msg rv
+    | rv ≤ 0   = fail msg
+    | otherwise = return ()