summaryrefslogtreecommitdiff
path: root/plugins/vtx
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/vtx
parentddfbdc8c68cb2c8ebc65d4f4576dbc1eb270c209 (diff)
improved decoder API to be able to interrupt .init at any moment
Diffstat (limited to 'plugins/vtx')
-rw-r--r--plugins/vtx/vtx.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c
index e05870c9..9bb4efa7 100644
--- a/plugins/vtx/vtx.c
+++ b/plugins/vtx/vtx.c
@@ -47,12 +47,17 @@ typedef struct {
} vtx_info_t;
static DB_fileinfo_t *
-vtx_init (DB_playItem_t *it) {
+vtx_open (void) {
+ DB_fileinfo_t *_info = malloc (sizeof (vtx_info_t));
+ memset (_info, 0, sizeof (vtx_info_t));
+ return _info;
+}
+
+static int
+vtx_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
// prepare to decode the track
// return -1 on failure
- DB_fileinfo_t *_info = malloc (sizeof (vtx_info_t));
vtx_info_t *info = (vtx_info_t *)_info;
- memset (info, 0, sizeof (vtx_info_t));
size_t sz = 0;
char *buf = NULL;
@@ -60,36 +65,31 @@ vtx_init (DB_playItem_t *it) {
DB_FILE *fp = deadbeef->fopen (it->fname);
if (!fp) {
trace ("vtx: failed to open file %s\n", it->fname);
- plugin.free (_info);
- return NULL;
+ return -1;
}
sz = deadbeef->fgetlength (fp);
if (sz <= 0) {
trace ("vtx: bad file size\n");
- plugin.free (_info);
- return NULL;
+ return -1;
}
buf = malloc (sz);
if (!buf) {
trace ("vtx: out of memory\n");
- plugin.free (_info);
- return NULL;
+ return -1;
}
if (deadbeef->fread (buf, 1, sz, fp) != sz) {
trace ("vtx: read failed\n");
free (buf);
- plugin.free (_info);
- return NULL;
+ return -1;
}
info->decoder = ayemu_vtx_load (buf, sz);
if (!info->decoder) {
trace ("vtx: ayemu_vtx_load failed\n");
free (buf);
- plugin.free (_info);
- return NULL;
+ return -1;
}
trace ("vtx: data=%p, size=%d\n", info->decoder->regdata, info->decoder->regdata_size);
@@ -112,7 +112,7 @@ vtx_init (DB_playItem_t *it) {
_info->channels = deadbeef->get_output ()->channels ();
_info->samplerate = samplerate;
_info->readpos = 0;
- return _info;
+ return 0;
}
static void
@@ -304,6 +304,7 @@ static DB_decoder_t plugin = {
.plugin.website = "http://deadbeef.sf.net",
.plugin.start = vtx_start,
.plugin.stop = vtx_stop,
+ .open = vtx_open,
.init = vtx_init,
.free = vtx_free,
.read_int16 = vtx_read_int16,