Finalized Bindings [Addendum]

After fiddling with some other code, i realized that I could condense my real code a bit. My finalizers where basically (lambda (value) (finalizer-function value)) where I should just actually pass in finalizer-function

    (define/public (play file-index callback)
      (let ((file (schemep3-database-index->filename file-index)))
        (if (not (file-exists? file))
            (values #f #f)
            (with-finalized-binding
             (lambda () (call-vlc libvlc_media_new (get-vlc-instance) (path->mrl file)))
             (lambda (media)
               (with-finalized-binding
                (lambda () (call-vlc libvlc_media_player_new_from_media media))
                (lambda (media-player)
                  (call-vlc libvlc_media_player_play media-player)
                  (internal-playback-loop media-player callback))
                libvlc_media_player_release))
             libvlc_media_release))))

Leave a Reply

Your email address will not be published. Required fields are marked *