module Sound.ALSA.Sequencer.Port
( Port.T
, create
, createSimple
, delete
, deleteSimple
, withSimple
, Port.systemTimer
, Port.systemAnnounce
, Port.unknown
, Port.Cap
, Port.capRead
, Port.capWrite
, Port.capSyncRead
, Port.capSyncWrite
, Port.capDuplex
, Port.capSubsRead
, Port.capSubsWrite
, Port.capNoExport
, Port.caps
, Port.Type
, Port.typeSpecific
, Port.typeMidiGeneric
, Port.typeMidiGM
, Port.typeMidiGS
, Port.typeMidiXG
, Port.typeMidiMT32
, Port.typeMidiGM2
, Port.typeSynth
, Port.typeDirectSample
, Port.typeSample
, Port.typeHardware
, Port.typeSoftware
, Port.typeSynthesizer
, Port.typePort
, Port.typeApplication
, Port.types
) where
import qualified Sound.ALSA.Sequencer.Marshal.Port as Port
import qualified Sound.ALSA.Sequencer.Marshal.Sequencer as Seq
import qualified Sound.ALSA.Exception as Exc
import Sound.ALSA.Sequencer.Area
import Foreign.C.Types (CInt, )
import Foreign.C.String (CString, withCAString, )
import Foreign.Ptr (Ptr, )
import Control.Exception (bracket, )
createSimple :: Seq.T mode -> String -> Port.Cap -> Port.Type -> IO Port.T
createSimple (Seq.Cons h) s c t =
withCAString s $ \a ->
Port.imp `fmap` (Exc.checkResult "create_simple_port" =<< snd_seq_create_simple_port h a c t)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_create_simple_port"
snd_seq_create_simple_port :: Ptr Seq.Core -> CString -> Port.Cap -> Port.Type
-> IO CInt
deleteSimple :: Seq.T mode -> Port.T -> IO ()
deleteSimple (Seq.Cons h) (Port.Cons p) =
Exc.checkResult_ "delete_simple_port" =<< snd_seq_delete_simple_port h (fromIntegral p)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_delete_simple_port"
snd_seq_delete_simple_port :: Ptr Seq.Core -> CInt -> IO CInt
withSimple ::
Seq.T mode -> String -> Port.Cap -> Port.Type ->
(Port.T -> IO a) ->
IO a
withSimple ss s c t =
bracket (createSimple ss s c t) (deleteSimple ss)
create :: Seq.T mode -> PortInfo -> IO ()
create (Seq.Cons h) p =
Exc.checkResult_ "create_port" =<< with_port_info p (snd_seq_create_port h)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_create_port"
snd_seq_create_port :: Ptr Seq.Core -> Ptr PortInfo_ -> IO CInt
delete :: Seq.T mode -> Port.T -> IO ()
delete (Seq.Cons h) (Port.Cons p) =
Exc.checkResult_ "delete_port" =<< snd_seq_delete_port h (fromIntegral p)
foreign import ccall unsafe "alsa/asoundlib.h snd_seq_delete_port"
snd_seq_delete_port :: Ptr Seq.Core -> CInt -> IO CInt