module Sound.Alsa.Sequencer.Client
( Client
, client_unknown
, client_system
, client_subscribers
, client_broadcast
, get_client_id
, set_client_name
, ClientInfo
, ClientType(..)
, get_client_info
, get_any_client_info
, query_first_client
, query_next_client
, set_client_info
, client_info_copy
, client_info_clone
, client_info_get_client
, client_info_get_type
, client_info_get_name
, client_info_get_broadcast_filter
, client_info_get_error_bounce
, client_info_get_num_ports
, client_info_get_event_lost
, client_info_set_client
, client_info_set_name
, client_info_set_broadcast_filter
, client_info_set_error_bounce
) where
import Foreign.C.Types(CInt)
import Foreign.Ptr(Ptr)
import Control.Monad(guard)
import Sound.Alsa.Sequencer.Marshal
import Sound.Alsa.Sequencer.Area
import Sound.Alsa.Sequencer.Errors
get_client_id :: SndSeq -> IO Client
get_client_id h = client_info_get_client =<< get_client_info h
set_client_name :: SndSeq -> String -> IO ()
set_client_name h s =
do i <- get_client_info h
client_info_set_name i s
set_client_info h i
get_client_info :: SndSeq -> IO ClientInfo
get_client_info (SndSeq h) =
do info <- client_info_malloc
check_error =<< with_client_info info (snd_seq_get_client_info h)
return info
foreign import ccall "alsa/asoundlib.h snd_seq_get_client_info"
snd_seq_get_client_info :: Ptr SndSeq_ -> Ptr ClientInfo_ -> IO CInt
get_any_client_info :: SndSeq -> Client -> IO ClientInfo
get_any_client_info (SndSeq h) c =
do info <- client_info_malloc
check_error =<< with_client_info info
(snd_seq_get_any_client_info h (exp_Client c))
return info
foreign import ccall "alsa/asoundlib.h snd_seq_get_any_client_info"
snd_seq_get_any_client_info
:: Ptr SndSeq_ -> CInt -> Ptr ClientInfo_ -> IO CInt
query_first_client :: SndSeq -> IO ClientInfo
query_first_client h =
do x <- client_info_malloc
with_client_info x (`snd_seq_client_info_set_client` (1))
b <- query_next_client h x
return x
query_next_client :: SndSeq -> ClientInfo
-> IO Bool
query_next_client (SndSeq h) info =
check_error' (const True)
(\x -> guard (x == 2) >> return False)
=<< with_client_info info (snd_seq_query_next_client h)
foreign import ccall "alsa/asoundlib.h snd_seq_query_next_client"
snd_seq_query_next_client :: Ptr SndSeq_ -> Ptr ClientInfo_ -> IO CInt
set_client_info :: SndSeq -> ClientInfo -> IO ()
set_client_info (SndSeq h) info =
check_error_ =<< with_client_info info (snd_seq_set_client_info h)
foreign import ccall "alsa/asoundlib.h snd_seq_set_client_info"
snd_seq_set_client_info :: Ptr SndSeq_ -> Ptr ClientInfo_ -> IO CInt