From fe6d90865e38cb96fa33610c1b38d0e8fc86d1e9 Mon Sep 17 00:00:00 2001 From: PHO Date: Wed, 11 May 2011 09:07:36 +0900 Subject: [PATCH] esound-1: Replace use of MonadPeelIO with MonadControlIO Ditz-issue: 5c1f9155776630719beb254e936b4d87d9a4d00f --- EsounD.cabal | 9 +++++---- Sound/EsounD/Controller.hs | 35 +++++++++++------------------------ Sound/EsounD/Filter.hs | 8 ++++---- Sound/EsounD/Monitor.hs | 10 +++++----- Sound/EsounD/Player.hs | 8 ++++---- Sound/EsounD/Recorder.hs | 10 +++++----- 6 files changed, 34 insertions(+), 46 deletions(-) diff --git a/EsounD.cabal b/EsounD.cabal index a9c9368..c24489f 100644 --- a/EsounD.cabal +++ b/EsounD.cabal @@ -2,13 +2,14 @@ Name: EsounD Synopsis: Type-safe bindings to EsounD (ESD; Enlightened Sound Daemon) Description: Type-safe bindings to EsounD: -Version: 0.1 +Version: 0.2 License: PublicDomain License-File: COPYING Author: PHO Maintainer: PHO Stability: experimental Homepage: http://cielonegro.org/EsounD.html +Bug-Reports: http://static.cielonegro.org/ditz/EsounD/ Category: Sound Tested-With: GHC == 7.0.1 Cabal-Version: >= 1.6 @@ -29,10 +30,10 @@ Library base == 4.*, base-unicode-symbols == 0.2.*, bindings-EsounD == 0.1.*, - monad-peel == 0.1.*, + monad-control == 0.2.*, network == 2.3.*, - regions == 0.8.*, - safer-file-handles == 0.9.*, + regions == 0.9.*, + safer-file-handles == 0.10.*, storablevector == 0.2.*, transformers == 0.2.*, unix == 2.4.* diff --git a/Sound/EsounD/Controller.hs b/Sound/EsounD/Controller.hs index c9b0649..c381856 100644 --- a/Sound/EsounD/Controller.hs +++ b/Sound/EsounD/Controller.hs @@ -42,9 +42,9 @@ module Sound.EsounD.Controller ) where import Bindings.EsounD -import Control.Exception.Peel +import Control.Exception.Control import Control.Monad.IO.Class -import Control.Monad.IO.Peel +import Control.Monad.IO.Control import Control.Monad.Trans.Region import Control.Monad.Trans.Region.OnExit import Control.Monad.Unicode @@ -75,13 +75,13 @@ instance Dup Controller where return co { coCloseH = ch' } -- | Open an ESD handle for controlling ESD. -openController ∷ MonadPeelIO pr +openController ∷ MonadControlIO pr ⇒ Maybe HostName -- ^ host to connect to. → RegionT s pr (Controller (RegionT s pr)) openController host - = block $ + = mask_ $ do s ← liftIO openSocket - ch ← onExit $ sanitizeIOError $ closeSocket' s + ch ← onExit $ closeSocket' s return Controller { coSocket = s , coCloseH = ch @@ -115,7 +115,6 @@ lock ∷ ( AncestorRegion pr cr → cr () lock co = liftIO $ - sanitizeIOError $ c'esd_lock (fdToCInt $ coSocket co) ≫= failOnError "esd_lock(fd) returned an error" (≤ 0) ≫ return () @@ -129,7 +128,6 @@ unlock ∷ ( AncestorRegion pr cr → cr () unlock co = liftIO $ - sanitizeIOError $ c'esd_unlock (fdToCInt $ coSocket co) ≫= failOnError "esd_unlock(fd) returned an error" (≤ 0) ≫ return () @@ -143,7 +141,6 @@ standby ∷ ( AncestorRegion pr cr → cr () standby co = liftIO $ - sanitizeIOError $ c'esd_standby (fdToCInt $ coSocket co) ≫= failOnError "esd_standby(fd) returned an error" (≤ 0) ≫ return () @@ -157,7 +154,6 @@ resume ∷ ( AncestorRegion pr cr → cr () resume co = liftIO $ - sanitizeIOError $ c'esd_resume (fdToCInt $ coSocket co) ≫= failOnError "esd_resume(fd) returned an error" (≤ 0) ≫ return () @@ -180,7 +176,7 @@ instance Dup Sample where class (Frame fr, Channels ch) ⇒ SampleSource fr ch dvec where -- | Cache a sample in the server. - cacheSample ∷ (MonadPeelIO pr) + cacheSample ∷ (MonadControlIO pr) ⇒ Controller (RegionT s pr) → Maybe String -- ^ name used to identify this sample to → Int -- ^ sample rate @@ -189,7 +185,7 @@ class (Frame fr, Channels ch) ⇒ SampleSource fr ch dvec where instance Frame fr ⇒ SampleSource fr Mono (L.Vector fr) where cacheSample co name rate v - = block $ + = mask_ $ do sa ← createSample co name @@ -208,7 +204,7 @@ instance Frame fr ⇒ SampleSource fr Mono (L.Vector fr) where instance Frame fr ⇒ SampleSource fr Stereo (L.Vector fr, L.Vector fr) where cacheSample co name rate (l, r) - = block $ + = mask_ $ do sa ← createSample co name @@ -228,7 +224,7 @@ instance Frame fr ⇒ SampleSource fr Stereo (L.Vector fr, L.Vector fr) where createSample ∷ ∀fr ch s pr. ( Frame fr , Channels ch - , MonadPeelIO pr + , MonadControlIO pr ) ⇒ Controller (RegionT s pr) → Maybe String @@ -238,9 +234,9 @@ createSample ∷ ∀fr ch s pr. → Int → RegionT s pr (Sample (RegionT s pr)) createSample co name rate _ _ len - = block $ + = mask_ $ do sid ← liftIO newCache - ch ← onExit $ sanitizeIOError $ deleteCache sid + ch ← onExit $ deleteCache sid return Sample { saID = sid , saCtrl = co @@ -290,7 +286,6 @@ playSample ∷ ( AncestorRegion pr cr → cr () playSample sa = liftIO $ - sanitizeIOError $ c'esd_sample_play (fdToCInt $ coSocket $ saCtrl sa) (saID sa) ≫= failOnError ( printf "esd_sample_play(%s, %s) returned an error" (show $ coSocket $ saCtrl sa) @@ -306,7 +301,6 @@ loopSample ∷ ( AncestorRegion pr cr → cr () loopSample sa = liftIO $ - sanitizeIOError $ c'esd_sample_loop (fdToCInt $ coSocket $ saCtrl sa) (saID sa) ≫= failOnError ( printf "esd_sample_loop(%s, %s) returned an error" (show $ coSocket $ saCtrl sa) @@ -322,7 +316,6 @@ stopSample ∷ ( AncestorRegion pr cr → cr () stopSample sa = liftIO $ - sanitizeIOError $ c'esd_sample_stop (fdToCInt $ coSocket $ saCtrl sa) (saID sa) ≫= failOnError ( printf "esd_sample_stop(%s, %s) returned an error" (show $ coSocket $ saCtrl sa) @@ -338,7 +331,6 @@ killSample ∷ ( AncestorRegion pr cr → cr () killSample sa = liftIO $ - sanitizeIOError $ c'esd_sample_kill (fdToCInt $ coSocket $ saCtrl sa) (saID sa) ≫= failOnError ( printf "esd_sample_kill(%s, %s) returned an error" (show $ coSocket $ saCtrl sa) @@ -398,7 +390,6 @@ getServerInfo ∷ ( AncestorRegion pr cr → cr ServerInfo getServerInfo co = liftIO $ - sanitizeIOError $ bracket retrieve dispose extractServerInfo where retrieve ∷ IO (Ptr C'esd_server_info) @@ -539,7 +530,6 @@ getAllInfo ∷ ( AncestorRegion pr cr → cr AllInfo getAllInfo co = liftIO $ - sanitizeIOError $ bracket retrieve dispose extractAllInfo where retrieve ∷ IO (Ptr C'esd_info) @@ -560,7 +550,6 @@ setStreamPan ∷ ( AncestorRegion pr cr → cr () setStreamPan co sid l r = liftIO $ - sanitizeIOError $ c'esd_set_stream_pan (fdToCInt $ coSocket co) (fromIntegral sid) (floor $ l ⋅ c'ESD_VOLUME_BASE) @@ -584,7 +573,6 @@ setDefaultSamplePan ∷ ( AncestorRegion pr cr → cr () setDefaultSamplePan co sid l r = liftIO $ - sanitizeIOError $ c'esd_set_default_sample_pan (fdToCInt $ coSocket co) (fromIntegral sid) (floor $ l ⋅ c'ESD_VOLUME_BASE) @@ -619,7 +607,6 @@ getServerState ∷ ( AncestorRegion pr cr → cr ServerState getServerState co = liftIO $ - sanitizeIOError $ fmap extractServerState $ c'esd_get_standby_mode (fdToCInt $ coSocket co) ≫= failOnError "esd_get_standby_mode(fd) returned an error" (≡ c'ESM_ERROR) diff --git a/Sound/EsounD/Filter.hs b/Sound/EsounD/Filter.hs index 26b6336..60c6d1d 100644 --- a/Sound/EsounD/Filter.hs +++ b/Sound/EsounD/Filter.hs @@ -13,9 +13,9 @@ module Sound.EsounD.Filter ) where import Bindings.EsounD -import Control.Exception.Peel +import Control.Exception.Control import Control.Monad.IO.Class -import Control.Monad.IO.Peel +import Control.Monad.IO.Control import Control.Monad.Trans.Region import Control.Monad.Trans.Region.OnExit import Control.Monad.Unicode @@ -87,7 +87,7 @@ instance Frame fr ⇒ WritableStream (Filter fr Stereo) (L.Vector fr, L.Vector f openFilter ∷ ∀fr ch s pr. ( Frame fr , Channels ch - , MonadPeelIO pr + , MonadControlIO pr ) ⇒ Int -- ^ sample rate for the stream. → Maybe HostName -- ^ host to connect to. @@ -95,7 +95,7 @@ openFilter ∷ ∀fr ch s pr. -- ESD (if any). → RegionT s pr (Filter fr ch (RegionT s pr)) openFilter rate host name - = block $ + = mask_ $ do h ← liftIO openSocket ch ← onExit $ sanitizeIOError $ closeSocket h return Filter { diff --git a/Sound/EsounD/Monitor.hs b/Sound/EsounD/Monitor.hs index 0fadfd7..20eb2ee 100644 --- a/Sound/EsounD/Monitor.hs +++ b/Sound/EsounD/Monitor.hs @@ -13,9 +13,9 @@ module Sound.EsounD.Monitor ) where import Bindings.EsounD -import Control.Exception.Peel +import Control.Exception.Control import Control.Monad.IO.Class -import Control.Monad.IO.Peel +import Control.Monad.IO.Control import Control.Monad.Trans.Region import Control.Monad.Trans.Region.OnExit import Control.Monad.Unicode @@ -63,7 +63,7 @@ instance Frame fr ⇒ ReadableStream (Monitor fr Stereo) (L.Vector fr, L.Vector openMonitor ∷ ∀fr ch s pr. ( Frame fr , Channels ch - , MonadPeelIO pr + , MonadControlIO pr ) ⇒ Int -- ^ sample rate for the stream. → Maybe HostName -- ^ host to connect to. @@ -71,7 +71,7 @@ openMonitor ∷ ∀fr ch s pr. -- to ESD (if any). → RegionT s pr (Monitor fr ch (RegionT s pr)) openMonitor rate host name - = block $ + = mask_ $ do h ← liftIO openSocket ch ← onExit $ sanitizeIOError $ closeSocket h return Monitor { @@ -83,7 +83,7 @@ openMonitor rate host name fmt ∷ C'esd_format_t fmt = frameFmt ((⊥) ∷ fr) .|. channelFmt ((⊥) ∷ ch) .|. - c'ESD_STREAM .|. + c'ESD_STREAM .|. c'ESD_MONITOR openSocket ∷ IO Handle diff --git a/Sound/EsounD/Player.hs b/Sound/EsounD/Player.hs index 56781da..4d3c719 100644 --- a/Sound/EsounD/Player.hs +++ b/Sound/EsounD/Player.hs @@ -13,9 +13,9 @@ module Sound.EsounD.Player ) where import Bindings.EsounD -import Control.Exception.Peel +import Control.Exception.Control import Control.Monad.IO.Class -import Control.Monad.IO.Peel +import Control.Monad.IO.Control import Control.Monad.Trans.Region import Control.Monad.Trans.Region.OnExit import Control.Monad.Unicode @@ -65,7 +65,7 @@ instance Frame fr ⇒ WritableStream (Player fr Stereo) (L.Vector fr, L.Vector f openPlayer ∷ ∀fr ch s pr. ( Frame fr , Channels ch - , MonadPeelIO pr + , MonadControlIO pr ) ⇒ Int -- ^ sample rate for the stream. → Maybe HostName -- ^ host to connect to. @@ -73,7 +73,7 @@ openPlayer ∷ ∀fr ch s pr. -- ESD (if any). → RegionT s pr (Player fr ch (RegionT s pr)) openPlayer rate host name - = block $ + = mask_ $ do h ← liftIO openSocket ch ← onExit $ sanitizeIOError $ closeSocket h return Player { diff --git a/Sound/EsounD/Recorder.hs b/Sound/EsounD/Recorder.hs index 7a843c3..caeaaa0 100644 --- a/Sound/EsounD/Recorder.hs +++ b/Sound/EsounD/Recorder.hs @@ -13,9 +13,9 @@ module Sound.EsounD.Recorder ) where import Bindings.EsounD -import Control.Exception.Peel +import Control.Exception.Control import Control.Monad.IO.Class -import Control.Monad.IO.Peel +import Control.Monad.IO.Control import Control.Monad.Trans.Region import Control.Monad.Trans.Region.OnExit import Control.Monad.Unicode @@ -63,7 +63,7 @@ instance Frame fr ⇒ ReadableStream (Recorder fr Stereo) (L.Vector fr, L.Vector openRecorder ∷ ∀fr ch s pr. ( Frame fr , Channels ch - , MonadPeelIO pr + , MonadControlIO pr ) ⇒ Int -- ^ sample rate for the stream. → Maybe HostName -- ^ host to connect to. @@ -71,7 +71,7 @@ openRecorder ∷ ∀fr ch s pr. -- to ESD (if any). → RegionT s pr (Recorder fr ch (RegionT s pr)) openRecorder rate host name - = block $ + = mask_ $ do h ← liftIO openSocket ch ← onExit $ sanitizeIOError $ closeSocket h return Recorder { @@ -83,7 +83,7 @@ openRecorder rate host name fmt ∷ C'esd_format_t fmt = frameFmt ((⊥) ∷ fr) .|. channelFmt ((⊥) ∷ ch) .|. - c'ESD_STREAM .|. + c'ESD_STREAM .|. c'ESD_RECORD openSocket ∷ IO Handle -- 2.40.0