-! (c)2010 Chris Double, Joe Groff bsd license
+! (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 kernel libc make
-math math.order math.parser ogg ogg.vorbis sequences ;
+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

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

CONSTANT: stream-buffer-size 4096


        } cleave
    ] with-destructors ;

: read-vorbis-stream ( filename -- vorbis-stream )
    binary <file-reader> <vorbis-stream> ; inline

M: vorbis-stream dispose*
    {
        [ temp-state>>   [ free ] when* ]
        [ comment>>      [ [ vorbis_comment_clear ] [ free ] bi ] when* ]
        [ block>>        [ free ] when* ]
        [ dsp-state>>    [ free ] when* ]
        [ info>>         [ [ vorbis_info_clear ] [ free ] bi ] when* ]
        [ stream-state>> [ free ] when* ]
        [ page>>         [ free ] when* ]
        [ sync-state>>   [ free ] when* ]
