hunk ./alsa-seq-glib-gtk.cabal 18 +Extra-Source-Files: + src/Sound/ALSA/Sequencer/GlibGtk.hs + hunk ./alsa-seq-glib-gtk.cabal 31 - poll >= 0.0 && <0.1, - enumset >= 0.0.2 && <0.1, + poll >=0.0 && <0.1, + enumset >=0.0.3 && <0.1, hunk ./alsa-seq-glib-gtk.cabal 34 - base >= 3 && <5 + base >=3 && <5 hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 13 -import qualified Data.FlagSet as FlagSet +import qualified Data.EnumSet as EnumSet hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 21 -add :: Poll.Events -> Seq.T mode -> G.Priority -> IO Bool -> IO [G.HandlerId] -add el sh pri fun = mapM add1 =<< Poll.descriptors sh el where - add1 (Poll.Fd fd e _) = G.inputAdd (fromIntegral fd) (map pio $ FlagSet.decompose e) pri fun - pio Poll.In = G.IOIn - pio Poll.Out = G.IOOut - pio Poll.Pri = G.IOPri - pio Poll.Err = G.IOErr - pio Poll.Hup = G.IOHup - pio Poll.NVal = G.IOInvalid +add :: Seq.T mode -> Poll.Events -> G.Priority -> IO Bool -> IO [G.HandlerId] +add sh el pri fun = + let add1 (Poll.Fd fd e _) = + G.inputAdd (fromIntegral fd) (map pio $ EnumSet.toEnums e) pri fun + in mapM add1 =<< Poll.descriptors sh el + +pio :: Poll.Event -> G.IOCondition +pio Poll.In = G.IOIn +pio Poll.Out = G.IOOut +pio Poll.Pri = G.IOPri +pio Poll.Err = G.IOErr +pio Poll.Hup = G.IOHup +pio Poll.NVal = G.IOInvalid +pio (Poll.Other n) = + error $ "unknown Poll flag at bit position " ++ show n hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 48 -inputAdd sh pri fun = add (FlagSet.fromMaskedValue Poll.inp) sh pri handler where +inputAdd sh pri fun = add sh Poll.inp pri handler where hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 60 -drainOutput sh pri = add (FlagSet.fromMaskedValue Poll.out) sh pri handler where +drainOutput sh pri = add sh Poll.out pri handler where hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 67 - hunk ./alsa-seq-glib-gtk.cabal 18 -Extra-Source-Files: - src/Sound/ALSA/Sequencer/GlibGtk.hs - hunk ./alsa-seq-glib-gtk.cabal 39 + Other-Modules: + Sound.ALSA.Sequencer.GlibGtk + Sound.ALSA.Sequencer.GlibGtkClass hunk ./src/Sound/ALSA/Sequencer/Glib.hs 1 -{-# LANGUAGE CPP #-} hunk ./src/Sound/ALSA/Sequencer/Glib.hs 7 +import qualified Sound.ALSA.Sequencer.GlibGtkClass as GC +import qualified Sound.ALSA.Sequencer.GlibGtk as GG + hunk ./src/Sound/ALSA/Sequencer/Glib.hs 12 -#include "GlibGtk.hs" +import qualified Sound.ALSA.Sequencer.Event as Event +import qualified Sound.ALSA.Sequencer as Seq + +import qualified System.Posix.Poll as Poll + + +methods :: GC.T G.Priority G.HandlerId G.IOCondition +methods = + GC.Cons G.inputAdd G.inputRemove pio + +pio :: Poll.Event -> G.IOCondition +pio Poll.In = G.IOIn +pio Poll.Out = G.IOOut +pio Poll.Pri = G.IOPri +pio Poll.Err = G.IOErr +pio Poll.Hup = G.IOHup +pio Poll.NVal = G.IOInvalid +pio (Poll.Other n) = + error $ "unknown Poll flag at bit position " ++ show n + + +type HandlerId = [G.HandlerId] + +inputAdd :: Seq.AllowInput mode => Seq.T mode -> G.Priority -> (Event.T -> IO Bool) -> IO HandlerId +inputAdd = GG.inputAdd methods + +drainOutput :: Seq.AllowOutput mode => Seq.T mode -> G.Priority -> IO HandlerId +drainOutput = GG.drainOutput methods + +inputRemove :: HandlerId -> IO () +inputRemove = GG.inputRemove methods hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 6 --} +-} +module Sound.ALSA.Sequencer.GlibGtk where hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 9 -import qualified Sound.ALSA.Sequencer.Poll as Poll +import qualified Sound.ALSA.Sequencer.GlibGtkClass as GC + +import qualified Sound.ALSA.Sequencer.Poll as APoll hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 24 -add :: Seq.T mode -> Poll.Events -> G.Priority -> IO Bool -> IO [G.HandlerId] -add sh el pri fun = +add :: + GC.T pri handler cond -> + Seq.T mode -> Poll.Events -> pri -> IO Bool -> IO [handler] +add methods sh el pri fun = hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 29 - G.inputAdd (fromIntegral fd) (map pio $ EnumSet.toEnums e) pri fun - in mapM add1 =<< Poll.descriptors sh el - -pio :: Poll.Event -> G.IOCondition -pio Poll.In = G.IOIn -pio Poll.Out = G.IOOut -pio Poll.Pri = G.IOPri -pio Poll.Err = G.IOErr -pio Poll.Hup = G.IOHup -pio Poll.NVal = G.IOInvalid -pio (Poll.Other n) = - error $ "unknown Poll flag at bit position " ++ show n + GC.inputAdd methods + (fromIntegral fd) (map (GC.pio methods) $ EnumSet.toEnums e) pri fun + in mapM add1 =<< APoll.descriptors sh el hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 39 -type HandlerId = [G.HandlerId] hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 42 -inputAdd :: Seq.AllowInput mode => Seq.T mode -> G.Priority -> (Event.T -> IO Bool) -> IO HandlerId -inputAdd sh pri fun = add sh Poll.inp pri handler where +inputAdd :: + Seq.AllowInput mode => + GC.T pri handler cond -> + Seq.T mode -> pri -> (Event.T -> IO Bool) -> IO [handler] +inputAdd methods sh pri fun = add methods sh Poll.inp pri handler where hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 57 -drainOutput :: Seq.AllowOutput mode => Seq.T mode -> G.Priority -> IO HandlerId -drainOutput sh pri = add sh Poll.out pri handler where +drainOutput :: + Seq.AllowOutput mode => + GC.T pri handler cond -> + Seq.T mode -> pri -> IO [handler] +drainOutput methods sh pri = add methods sh Poll.out pri handler where hunk ./src/Sound/ALSA/Sequencer/GlibGtk.hs 65 -inputRemove :: HandlerId -> IO () -inputRemove = mapM_ G.inputRemove +inputRemove :: + GC.T pri handler cond -> [handler] -> IO () +inputRemove methods = mapM_ (GC.inputRemove methods) addfile ./src/Sound/ALSA/Sequencer/GlibGtkClass.hs hunk ./src/Sound/ALSA/Sequencer/GlibGtkClass.hs 1 +module Sound.ALSA.Sequencer.GlibGtkClass where + +import qualified System.Posix.Poll as Poll +-- import qualified System.Posix.Types as Posix + + +data T pri handler cond = Cons { + inputAdd :: {- Posix.Fd -} Int -> [cond] -> pri -> IO Bool -> IO handler, + inputRemove :: handler -> IO (), + pio :: Poll.Event -> cond + } hunk ./src/Sound/ALSA/Sequencer/Gtk.hs 1 -{-# LANGUAGE CPP #-} hunk ./src/Sound/ALSA/Sequencer/Gtk.hs 7 +import qualified Sound.ALSA.Sequencer.GlibGtkClass as GC +import qualified Sound.ALSA.Sequencer.GlibGtk as GG + hunk ./src/Sound/ALSA/Sequencer/Gtk.hs 12 -#include "GlibGtk.hs" +import qualified Sound.ALSA.Sequencer.Event as Event +import qualified Sound.ALSA.Sequencer as Seq + +import qualified System.Posix.Poll as Poll + + +methods :: GC.T G.Priority G.HandlerId G.IOCondition +methods = + GC.Cons G.inputAdd G.inputRemove pio + +pio :: Poll.Event -> G.IOCondition +pio Poll.In = G.IOIn +pio Poll.Out = G.IOOut +pio Poll.Pri = G.IOPri +pio Poll.Err = G.IOErr +pio Poll.Hup = G.IOHup +pio Poll.NVal = G.IOInvalid +pio (Poll.Other n) = + error $ "unknown Poll flag at bit position " ++ show n + + +type HandlerId = [G.HandlerId] + +inputAdd :: Seq.AllowInput mode => Seq.T mode -> G.Priority -> (Event.T -> IO Bool) -> IO HandlerId +inputAdd = GG.inputAdd methods + +drainOutput :: Seq.AllowOutput mode => Seq.T mode -> G.Priority -> IO HandlerId +drainOutput = GG.drainOutput methods hunk ./src/Sound/ALSA/Sequencer/Gtk.hs 41 +inputRemove :: HandlerId -> IO () +inputRemove = GG.inputRemove methods