]> gitweb @ CieloNegro.org - EsounD.git/blobdiff - Sound/EsounD/Player.hs
Monitor
[EsounD.git] / Sound / EsounD / Player.hs
index b48dfee9a849f15245ecfb3f702ebdd8ca32e5ec..49740fc4167a57872f74b0c9a784b71f0dbb3c6d 100644 (file)
@@ -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)
                                )