From 76a27d6a8ffcc8d6ca608e674a78115cdf14b6ec Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sat, 1 May 2010 15:39:52 +0200 Subject: improved decoder API to be able to interrupt .init at any moment --- plugins/adplug/adplug-db.cpp | 18 +++++++++++------- plugins/adplug/plugin.c | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'plugins/adplug') 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, -- cgit v1.2.3