summaryrefslogtreecommitdiff
path: root/plugins/adplug
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/adplug
parentddfbdc8c68cb2c8ebc65d4f4576dbc1eb270c209 (diff)
improved decoder API to be able to interrupt .init at any moment
Diffstat (limited to 'plugins/adplug')
-rw-r--r--plugins/adplug/adplug-db.cpp18
-rw-r--r--plugins/adplug/plugin.c5
2 files changed, 15 insertions, 8 deletions
diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp
index 4fa90b4d..9aa5efb2 100644
--- a/plugins/adplug/adplug-db.cpp
+++ b/plugins/adplug/adplug-db.cpp
@@ -53,13 +53,18 @@ typedef struct {
} adplug_info_t;
DB_fileinfo_t *
-adplug_init (DB_playItem_t *it) {
- // prepare to decode the track
- // return -1 on failure
-
+adplug_open (void) {
adplug_info_t *info = (adplug_info_t *)malloc (sizeof (adplug_info_t));
DB_fileinfo_t *_info = (DB_fileinfo_t *)info;
memset (info, 0, sizeof (adplug_info_t));
+ return _info;
+}
+
+int
+adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
+ // prepare to decode the track
+ // return -1 on failure
+ adplug_info_t *info = (adplug_info_t *)_info;
int samplerate = deadbeef->conf_get_int ("synth.samplerate", 48000);
int bps = deadbeef->get_output ()->bitspersample ();
@@ -69,8 +74,7 @@ adplug_init (DB_playItem_t *it) {
info->decoder = CAdPlug::factory (it->fname, info->opl, CAdPlug::players);
if (!info->decoder) {
trace ("adplug: failed to open %s\n", it->fname);
- adplug_plugin.free (_info);
- return NULL;
+ return -1;
}
info->subsong = it->tracknum;
@@ -88,7 +92,7 @@ adplug_init (DB_playItem_t *it) {
trace ("adplug_init ok (duration=%f, totalsamples=%d)\n", deadbeef->pl_get_item_duration (it), totalsamples);
- return _info;
+ return 0;
}
void
diff --git a/plugins/adplug/plugin.c b/plugins/adplug/plugin.c
index 6b2a6ca5..c4e8e04c 100644
--- a/plugins/adplug/plugin.c
+++ b/plugins/adplug/plugin.c
@@ -26,7 +26,9 @@ extern const char *adplug_exts[];
extern const char *adplug_filetypes[];
DB_fileinfo_t *
-adplug_init (DB_playItem_t *it);
+adplug_open (void);
+int
+adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it);
void
adplug_free (DB_fileinfo_t *);
int
@@ -56,6 +58,7 @@ DB_decoder_t adplug_plugin = {
.plugin.website = "http://deadbeef.sf.net",
.plugin.start = adplug_start,
.plugin.stop = adplug_stop,
+ .open = adplug_open,
.init = adplug_init,
.free = adplug_free,
.read_int16 = adplug_read_int16,