{-# LANGUAGE ForeignFunctionInterface #-}
module Sound.ALSA.Sequencer.Sequencer where
import qualified Sound.ALSA.Sequencer.Marshal.Sequencer as Seq
import qualified Sound.ALSA.Exception as Exc
import qualified Foreign.C.Types as C
import Foreign.C.Types (CSize, )
import Foreign.C.String (CString, withCAString, peekCString, )
import Foreign.Ptr (Ptr, )
import Foreign.Marshal.Alloc (alloca, )
import Foreign.Storable (peek, )
import Data.Word (Word, )
import Control.Exception (bracket, )
open
:: Seq.OpenMode mode
=> String
-> Seq.BlockMode
-> IO (Seq.T mode)
open :: forall mode. OpenMode mode => String -> BlockMode -> IO (T mode)
open String
t BlockMode
bm = forall mode. (mode -> IO (T mode)) -> IO (T mode)
withOpenMode forall a b. (a -> b) -> a -> b
$ \mode
om -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr Core)
p -> forall a. String -> (CString -> IO a) -> IO a
withCAString String
t forall a b. (a -> b) -> a -> b
$ \CString
s ->
do forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"open" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr (Ptr Core) -> CString -> CInt -> CInt -> IO CInt
snd_seq_open Ptr (Ptr Core)
p CString
s (forall mode. OpenMode mode => mode -> CInt
Seq.expOpenMode mode
om) (BlockMode -> CInt
Seq.expBlockMode BlockMode
bm)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall mode. Ptr Core -> T mode
Seq.Cons forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Core)
p
openDefault
:: Seq.OpenMode mode
=> Seq.BlockMode
-> IO (Seq.T mode)
openDefault :: forall mode. OpenMode mode => BlockMode -> IO (T mode)
openDefault = forall mode. OpenMode mode => String -> BlockMode -> IO (T mode)
open String
defaultName
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_open"
snd_seq_open :: Ptr (Ptr Seq.Core) -> CString -> C.CInt -> C.CInt -> IO C.CInt
withOpenMode :: (mode -> IO (Seq.T mode)) -> IO (Seq.T mode)
withOpenMode :: forall mode. (mode -> IO (T mode)) -> IO (T mode)
withOpenMode mode -> IO (T mode)
f = mode -> IO (T mode)
f forall a. HasCallStack => a
undefined
close
:: Seq.T mode
-> IO ()
close :: forall mode. T mode -> IO ()
close (Seq.Cons Ptr Core
h) = forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"close" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> IO CInt
snd_seq_close Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_close"
snd_seq_close :: Ptr Seq.Core -> IO C.CInt
with
:: Seq.OpenMode mode
=> String
-> Seq.BlockMode
-> (Seq.T mode -> IO a)
-> IO a
with :: forall mode a.
OpenMode mode =>
String -> BlockMode -> (T mode -> IO a) -> IO a
with String
t BlockMode
bm =
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall mode. OpenMode mode => String -> BlockMode -> IO (T mode)
open String
t BlockMode
bm) forall mode. T mode -> IO ()
close
withDefault
:: Seq.OpenMode mode
=> Seq.BlockMode
-> (Seq.T mode -> IO a)
-> IO a
withDefault :: forall mode a.
OpenMode mode =>
BlockMode -> (T mode -> IO a) -> IO a
withDefault = forall mode a.
OpenMode mode =>
String -> BlockMode -> (T mode -> IO a) -> IO a
with String
defaultName
defaultName :: String
defaultName :: String
defaultName = String
"default"
getName
:: Seq.T mode
-> IO String
getName :: forall mode. T mode -> IO String
getName (Seq.Cons Ptr Core
h) = CString -> IO String
peekCString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> IO CString
snd_seq_name Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_name"
snd_seq_name :: Ptr Seq.Core -> IO CString
setBlocking
:: Seq.T mode
-> Seq.BlockMode
-> IO ()
setBlocking :: forall mode. T mode -> BlockMode -> IO ()
setBlocking (Seq.Cons Ptr Core
h) BlockMode
m = forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_blocking" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CInt -> IO CInt
snd_seq_nonblock Ptr Core
h(BlockMode -> CInt
Seq.expBlockMode BlockMode
m)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_nonblock"
snd_seq_nonblock :: Ptr Seq.Core -> C.CInt -> IO C.CInt
getOutputBufferSize
:: Seq.T mode
-> IO Word
getOutputBufferSize :: forall mode. T mode -> IO Word
getOutputBufferSize (Seq.Cons Ptr Core
h) =
forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Ptr Core -> IO CSize
snd_seq_get_output_buffer_size Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_get_output_buffer_size"
snd_seq_get_output_buffer_size :: Ptr Seq.Core -> IO CSize
setOutputBufferSize
:: Seq.T mode
-> Word
-> IO ()
setOutputBufferSize :: forall mode. T mode -> Word -> IO ()
setOutputBufferSize (Seq.Cons Ptr Core
h) Word
x =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_output_buffer_size" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CSize -> IO CInt
snd_seq_set_output_buffer_size Ptr Core
h (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_output_buffer_size"
snd_seq_set_output_buffer_size :: Ptr Seq.Core -> CSize -> IO C.CInt
getInputBufferSize
:: Seq.T mode
-> IO Word
getInputBufferSize :: forall mode. T mode -> IO Word
getInputBufferSize (Seq.Cons Ptr Core
h) =
forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Ptr Core -> IO CSize
snd_seq_get_input_buffer_size Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_get_input_buffer_size"
snd_seq_get_input_buffer_size :: Ptr Seq.Core -> IO CSize
setInputBufferSize
:: Seq.T mode
-> Word
-> IO ()
setInputBufferSize :: forall mode. T mode -> Word -> IO ()
setInputBufferSize (Seq.Cons Ptr Core
h) Word
x =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_input_buffer_size" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CSize -> IO CInt
snd_seq_set_input_buffer_size Ptr Core
h (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_input_buffer_size"
snd_seq_set_input_buffer_size :: Ptr Seq.Core -> CSize -> IO C.CInt
setPoolOutput
:: Seq.T mode
-> Word
-> IO ()
setPoolOutput :: forall mode. T mode -> Word -> IO ()
setPoolOutput (Seq.Cons Ptr Core
h) Word
x =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_pool_output" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CSize -> IO CInt
snd_seq_set_client_pool_output Ptr Core
h (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_output"
snd_seq_set_client_pool_output :: Ptr Seq.Core -> CSize -> IO C.CInt
setPoolOutputRoom
:: Seq.T mode
-> Word
-> IO ()
setPoolOutputRoom :: forall mode. T mode -> Word -> IO ()
setPoolOutputRoom (Seq.Cons Ptr Core
h) Word
x =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_pool_output_room" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CSize -> IO CInt
snd_seq_set_client_pool_output_room Ptr Core
h (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_output_room"
snd_seq_set_client_pool_output_room :: Ptr Seq.Core -> CSize -> IO C.CInt
resetPoolOutput
:: Seq.T mode
-> IO ()
resetPoolOutput :: forall mode. T mode -> IO ()
resetPoolOutput (Seq.Cons Ptr Core
h) =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"reset_pool_output" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> IO CInt
snd_seq_reset_pool_output Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_reset_pool_output"
snd_seq_reset_pool_output :: Ptr Seq.Core -> IO C.CInt
setPoolInput
:: Seq.T mode
-> Word
-> IO ()
setPoolInput :: forall mode. T mode -> Word -> IO ()
setPoolInput (Seq.Cons Ptr Core
h) Word
x =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"set_pool_input" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> CSize -> IO CInt
snd_seq_set_client_pool_input Ptr Core
h (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
x)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_set_client_pool_input"
snd_seq_set_client_pool_input :: Ptr Seq.Core -> CSize -> IO C.CInt
resetPoolInput
:: Seq.T mode
-> IO ()
resetPoolInput :: forall mode. T mode -> IO ()
resetPoolInput (Seq.Cons Ptr Core
h) =
forall a. Integral a => String -> a -> IO ()
Exc.checkResult_ String
"reset_pool_input" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr Core -> IO CInt
snd_seq_reset_pool_input Ptr Core
h
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_reset_pool_input"
snd_seq_reset_pool_input :: Ptr Seq.Core -> IO C.CInt