summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-19 14:00:40 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-19 14:00:40 +0100
commit25f13980b6f30093f80174c8055cc42a47772d0d (patch)
tree03b5870b440d069ed5368a76125ee8c9ea6af26c
parentdf8785f82444ba9d84b2db7d4fcf4c2442f7cacf (diff)
updated decoder_template
-rw-r--r--decoder_template.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/decoder_template.c b/decoder_template.c
index 1ddcc3c8..bfa2af8b 100644
--- a/decoder_template.c
+++ b/decoder_template.c
@@ -32,6 +32,13 @@ static int
example_init (DB_playItem_t *it) {
// prepare to decode the track
// return -1 on failure
+
+ // fill in mandatory plugin fields
+ plugin.info.bps = deadbeef->get_output ()->bitspersample ();
+ plugin.info.channels = deadbeef->get_output ()->channels ();
+ plugin.info.samplerate = decoder->samplerate;
+ plugin.info.readpos = 0;
+
return 0;
}
@@ -45,7 +52,9 @@ example_read_int16 (char *bytes, int size) {
// try decode `size' bytes
// return number of decoded bytes
// return 0 on EOF
- return 0;
+
+ plugin.info.readpos = (float)currentsample / plugin.info.samplerate;
+ return size;
}
static int
@@ -53,6 +62,10 @@ example_seek_sample (int sample) {
// seek to specified sample (frame)
// return 0 on success
// return -1 on failure
+
+ // update readpos
+ plugin.info.readpos = (float)sample / plugin.info.samplerate;
+ return 0;
}
static int
@@ -60,7 +73,7 @@ example_seek (float time) {
// seek to specified time in seconds
// return 0 on success
// return -1 on failure
- // e.g. return example_seek_sample (time * samplerate);
+ return example_seek_sample (time * plugin.info.samplerate);
return 0;
}