summaryrefslogtreecommitdiff
path: root/plugins/wavpack
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-01 15:39:52 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-01 15:39:52 +0200
commit76a27d6a8ffcc8d6ca608e674a78115cdf14b6ec (patch)
tree801dc43105be2d5e36124f02359c48cdc2805abb /plugins/wavpack
parentddfbdc8c68cb2c8ebc65d4f4576dbc1eb270c209 (diff)
improved decoder API to be able to interrupt .init at any moment
Diffstat (limited to 'plugins/wavpack')
-rw-r--r--plugins/wavpack/wavpack.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c
index f54f0603..9e3abd68 100644
--- a/plugins/wavpack/wavpack.c
+++ b/plugins/wavpack/wavpack.c
@@ -92,20 +92,22 @@ static WavpackStreamReader wsr = {
};
static DB_fileinfo_t *
-wv_init (DB_playItem_t *it) {
+wv_open (void) {
DB_fileinfo_t *_info = malloc (sizeof (wvctx_t));
- wvctx_t *info = (wvctx_t *)_info;
- memset (info, 0, sizeof (wvctx_t));
+ memset (_info, 0, sizeof (wvctx_t));
+ return _info;
+}
+static int
+wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
+ wvctx_t *info = (wvctx_t *)_info;
info->file = deadbeef->fopen (it->fname);
if (!info->file) {
- plugin.free (_info);
- return NULL;
+ return -1;
}
info->ctx = WavpackOpenFileInputEx (&wsr, info->file, NULL, NULL, OPEN_2CH_MAX/*|OPEN_WVC*/, 0);
if (!info->ctx) {
- plugin.free (_info);
- return NULL;
+ return -1;
}
_info->plugin = &plugin;
_info->bps = WavpackGetBitsPerSample (info->ctx);
@@ -116,15 +118,14 @@ wv_init (DB_playItem_t *it) {
info->startsample = it->startsample;
info->endsample = it->endsample;
if (plugin.seek_sample (_info, 0) < 0) {
- plugin.free (_info);
- return NULL;
+ return -1;
}
}
else {
info->startsample = 0;
info->endsample = WavpackGetNumSamples (info->ctx)-1;
}
- return _info;
+ return 0;
}
static void
@@ -372,6 +373,7 @@ static DB_decoder_t plugin = {
.plugin.author = "Alexey Yakovenko",
.plugin.email = "waker@users.sourceforge.net",
.plugin.website = "http://deadbeef.sf.net",
+ .open = wv_open,
.init = wv_init,
.free = wv_free,
.read_int16 = wv_read_int16,