2013-05-20 19:07:24 -05:00
|
|
|
extern mod extra;
|
2013-01-03 16:55:46 -06:00
|
|
|
|
2013-05-20 19:07:24 -05:00
|
|
|
use std::comm::Chan;
|
2013-01-03 16:55:46 -06:00
|
|
|
|
|
|
|
type RingBuffer = ~[float];
|
2013-03-01 17:55:31 -06:00
|
|
|
type SamplesFn = ~fn(samples: &RingBuffer);
|
2013-01-03 16:55:46 -06:00
|
|
|
|
|
|
|
enum Msg
|
|
|
|
{
|
|
|
|
GetSamples(~str, SamplesFn), // sample set name, callback which receives samples
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(name: ~str, samples_chan: Chan<Msg>) {
|
|
|
|
do task::spawn
|
|
|
|
{
|
|
|
|
let callback: SamplesFn =
|
|
|
|
|buffer|
|
|
|
|
{
|
|
|
|
for uint::range(0, buffer.len())
|
|
|
|
|i| {error!("%?: %f", i, buffer[i])}
|
|
|
|
};
|
2013-03-15 17:27:15 -05:00
|
|
|
samples_chan.send(GetSamples(name.clone(), callback));
|
2013-01-03 16:55:46 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {}
|