         } cleave
     ] with-destructors ;
 
+: read-vorbis-stream ( filename -- vorbis-stream )
+    binary <file-reader> <vorbis-stream> ; inline
+
 M: vorbis-stream dispose*
     {
         [ temp-state>>   [ free ] when* ]
-        [ comment>>      [ free ] when* ]
+        [ comment>>      [ [ vorbis_comment_clear ] [ free ] bi ] when* ]
         [ block>>        [ free ] when* ]
         [ dsp-state>>    [ free ] when* ]
-        [ info>>         [ free ] when* ]
+        [ info>>         [ [ vorbis_info_clear ] [ free ] bi ] when* ]
         [ stream-state>> [ free ] when* ]
         [ page>>         [ free ] when* ]
         [ sync-state>>   [ free ] when* ]

M: vorbis-stream generator-audio-format
    [ info>> channels>> ] [ drop 16 ] [ info>> rate>> ] tri ;
M: vorbis-stream generate-audio
    drop f f ;

! (c)2007, 2010 Chris Double, Joe Groff bsd license
USING: accessors alien.c-types audio.engine byte-arrays classes.struct
combinators destructors fry gpu.buffers io io.files io.encodings.binary
kernel libc locals make math math.order math.parser ogg ogg.vorbis
sequences specialized-arrays specialized-vectors ;
FROM: alien.c-types => float short void* ;
SPECIALIZED-ARRAYS: float void* ;
SPECIALIZED-VECTOR: short
IN: audio.vorbis

TUPLE: vorbis-stream < disposable
