         } 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* ]

    { block vorbis-block }
    { comment vorbis-comment }
    { temp-state ogg-stream-state }
    { #vorbis-headers integer initial: 0 } ;

CONSTANT: stream-buffer-size 4096



: retrieve-page ( vorbis-stream -- ? )
    [ sync-state>> ] [ page>> ] bi ogg_sync_pageout 0 > ; inline

: sync-pages ( vorbis-stream -- )
    dup retrieve-page [ [ queue-page ] [ sync-pages ] bi ] [ drop ] if ;

: standard-initial-header? ( vorbis-stream -- bool )
    page>> ogg_page_bos zero? not ; inline
