4 struct wavefile_source
{
10 static err_t
get_output_format(struct graphnode
*node
, struct graphpin
*pin
,
13 struct wavefile_source
*ws
= node
->extra
;
14 af
->media
= MT_AUDIO_16I
;
15 af
->srate
= ws
->wf
.format
.srate
;
16 af
->channels
= ws
->wf
.format
.channels
;
20 static err_t
set_buffer(struct graphnode
*node
, struct graphpin
*pin
, struct buffer
*buf
)
22 struct wavefile_source
*ws
= node
->extra
;
27 static err_t
run(struct graphnode
*node
)
29 struct wavefile_source
*ws
= node
->extra
;
32 err
= buffer_alloc(ws
->buf
, 4410);
37 err
= wavefile_read_at(&ws
->wf
, ws
->pos
, ws
->buf
->data
, 4410);
47 static const struct graphnode_functab functab
= {
48 NULL
, // is_acceptable_input_format
49 NULL
, // get_ideal_input_format
55 err_t
wavesource_create(struct graphnode
**node_out
, const char *filename
)
57 struct graphnode
*node
;
59 struct wavefile_source
*ws
;
62 err
= graphnode_create(&node
, &functab
, sizeof *ws
);
67 err
= graphnode_add_pin(node
, &pin
);
75 err
= wavefile_open(&ws
->wf
, filename
);