X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=EsounD.git;a=blobdiff_plain;f=Sound%2FEsounD%2FPlayer.hs;fp=Sound%2FEsounD%2FPlayer.hs;h=49740fc4167a57872f74b0c9a784b71f0dbb3c6d;hp=b48dfee9a849f15245ecfb3f702ebdd8ca32e5ec;hb=4570a37d1fc8f21a4ee1221c6ed289d281f1b005;hpb=e8ea338a1b550c6c91726f1d30ad3416d73ec6af diff --git a/Sound/EsounD/Player.hs b/Sound/EsounD/Player.hs index b48dfee..49740fc 100644 --- a/Sound/EsounD/Player.hs +++ b/Sound/EsounD/Player.hs @@ -27,7 +27,7 @@ import Sound.EsounD.Streams import Sound.EsounD.Internals import System.IO import System.IO.SaferFileHandles.Unsafe - +import Text.Printf -- ^ An opaque ESD handle for playing a stream. data Player fr ch (r ∷ ★ → ★) @@ -44,20 +44,23 @@ instance Dup (Player fr ch) where dup pl = do ch' ← dup (plCloseH pl) return pl { plCloseH = ch' } -instance Frame fr ⇒ Writable (Player fr Mono) (L.Vector fr) where - write pl v +instance Stream (Player fr ch) where + streamSampleRate = plRate + +instance Frame fr ⇒ WritableStream (Player fr Mono) (L.Vector fr) where + writeFrames pl v = liftIO $ sanitizeIOError $ L.hPut (plHandle pl) v -instance Frame fr ⇒ Writable (Player fr Stereo) (L.Vector fr, L.Vector fr) where - write pl (l, r) +instance Frame fr ⇒ WritableStream (Player fr Stereo) (L.Vector fr, L.Vector fr) where + writeFrames pl (l, r) = liftIO $ sanitizeIOError $ L.hPut (plHandle pl) (interleave l r) -- | Open an ESD handle for playing a stream. openPlayer ∷ ∀fr ch s pr. - ( Frame fr - , Channels ch - , MonadPeelIO pr - ) + ( Frame fr + , Channels ch + , MonadPeelIO pr + ) ⇒ Int -- ^ sample rate for the stream. → Maybe HostName -- ^ host to connect to. → Maybe String -- ^ name used to identify this stream to @@ -88,13 +91,9 @@ openPlayer rate host name hostPtr namePtr ≫= wrapSocket - ( "esd_play_stream(" - ⧺ show fmt - ⧺ ", " - ⧺ show rate - ⧺ ", " - ⧺ show host - ⧺ ", " - ⧺ show name - ⧺ ") returned an error" + ( printf "esd_play_stream(%s, %s, %s, %s) returned an error" + (show fmt ) + (show rate) + (show host) + (show name) )