changeset 281:b432db0b2529

Synchronise audio read
author Chris Cannam
date Fri, 24 May 2013 12:41:41 +0100
parents df0836b48494
children e330ac62703b
files yetilab/stream/audiofile.yeti
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/audiofile.yeti	Thu May 23 21:36:20 2013 +0100
+++ b/yetilab/stream/audiofile.yeti	Fri May 24 12:41:41 2013 +0100
@@ -97,14 +97,15 @@
     aistream = AudioSystem#getAudioInputStream(f);
     format = aistream#getFormat();
     len = available' { format, aistream }; // at start of stream
+    syncd = synchronized aistream;
     {
-        get position () = len - available' { aistream, format },
+        get position () = syncd \(len - available' { aistream, format }),
         get channels () = if ch == 0 then format#getChannels() else ch fi,
         get sampleRate () = format#getSampleRate(),
-        get available () = Known (available' { aistream, format }),
-        get finished? () = not (aistream#available() > 0),
-        read = reader { aistream, format },
-        close () = close' { aistream },
+        get available () = syncd \(Known (available' { aistream, format })),
+        get finished? () = syncd \(not (aistream#available() > 0)),
+        read = syncd \(reader { aistream, format }),
+        close () = syncd \(close' { aistream }),
     });
 
 open = openWithReader read' 0;