module Sound.ALSA.Sequencer.Client.Info.EventFilter where

import qualified Sound.ALSA.Sequencer.Area as Area
import qualified Sound.ALSA.Sequencer.Marshal.Event as Event

import Foreign.C.Types(CInt, )
import Foreign.Ptr(Ptr, )


type T  = Area.ClientInfo
type T_ = Area.ClientInfo_


clear :: T -> IO ()
add :: Event.Type e => T -> e -> IO ()
delete :: Event.Type e => T -> e -> IO ()
check :: Event.Type e => T -> e -> IO Bool


clear i =
  Area.with_client_info i snd_seq_client_info_event_filter_clear

foreign import ccall unsafe "alsa/asoundlib.h snd_seq_client_info_event_filter_clear"
  snd_seq_client_info_event_filter_clear :: Ptr T_ -> IO ()

add i e =
  Area.with_client_info i (`snd_seq_client_info_event_filter_add` fromIntegral (Event.expEv e))

foreign import ccall unsafe "alsa/asoundlib.h snd_seq_client_info_event_filter_add"
  snd_seq_client_info_event_filter_add :: Ptr T_ -> CInt -> IO ()

delete i e =
  Area.with_client_info i (`snd_seq_client_info_event_filter_del` fromIntegral (Event.expEv e))

foreign import ccall unsafe "alsa/asoundlib.h snd_seq_client_info_event_filter_del"
  snd_seq_client_info_event_filter_del :: Ptr T_ -> CInt -> IO ()

check i e =
  fmap (/= 0) $ Area.with_client_info i (`snd_seq_client_info_event_filter_check` fromIntegral (Event.expEv e))

foreign import ccall unsafe "alsa/asoundlib.h snd_seq_client_info_event_filter_check"
  snd_seq_client_info_event_filter_check :: Ptr T_ -> CInt -> IO CInt