The other day I needed a non-short circuiting or. I thought there might be a SRFI for it, but I looked and couldn’t find one. So I made my own.
This is what I came up with:
(define-syntax complete-or
(syntax-rules ()
((_) #f)
((_ e) e)
[...]
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)))
[...]
In VLC backend for schemep3, I have to use what is a fairly common pattern in procedural languages, that doesn’t translate as well into a functional language. It looks something like this:
Var Bar = NULL;
Variable Foo = LibrarySprocketNew();
if ( Foo )
{
Bar = LibrarySprocketBeFancy( Foo );
LibrarySprocketRelease( Foo [...]
As promised in last post, here is an example of playing back an mp3 file using the vlc-ffi code. You may have to change the plugin-path parameter depending on your configuration…
#lang scheme
(require "vlc-ffi.ss")
(define (play-to-end media-player e)
(let loop ()
(let ([state (libvlc_media_player_get_state media-player e)]
[...]
I realized the other day that most of the functionality of VLC lies within a library called libVLC that has a C API. PLT Scheme has a great Foreign Function Interface that makes it fairly easy to interface with such a library.
So, I ditched the mplayer playback backend for schemep3 and converted to libvlc. [...]
Recent Comments