summaryrefslogtreecommitdiff
path: root/plugins/cdda
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/cdda
parentddfbdc8c68cb2c8ebc65d4f4576dbc1eb270c209 (diff)
improved decoder API to be able to interrupt .init at any moment
Diffstat (limited to 'plugins/cdda')
-rw-r--r--plugins/cdda/cdda.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c
index 998fd277..089041a1 100644
--- a/plugins/cdda/cdda.c
+++ b/plugins/cdda/cdda.c
@@ -69,10 +69,15 @@ min (int a, int b) {
}
static DB_fileinfo_t *
-cda_init (DB_playItem_t *it) {
+cda_open (void) {
DB_fileinfo_t *_info = malloc (sizeof (cdda_info_t));
+ memset (_info, 0, sizeof (cdda_info_t));
+ return _info;
+}
+
+static int
+cda_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
cdda_info_t *info = (cdda_info_t *)_info;
- memset (info, 0, sizeof (cdda_info_t));
trace ("cdda: init %s\n", it->fname);
@@ -86,8 +91,7 @@ cda_init (DB_playItem_t *it) {
}
else {
trace ("cdda: bad name: %s\n", it->fname);
- plugin.free (_info);
- return NULL;
+ return -1;
}
int track_nr = atoi (nr);
char *fname = (*location) ? location : NULL; //NULL if empty string; means pysical CD drive
@@ -96,15 +100,13 @@ cda_init (DB_playItem_t *it) {
if (!info->cdio)
{
trace ("cdda: Could not open CD\n");
- plugin.free (_info);
- return NULL;
+ return -1;
}
if (TRACK_FORMAT_AUDIO != cdio_get_track_format (info->cdio, track_nr))
{
trace ("cdda: Not an audio track (%d)\n", track_nr);
- plugin.free (_info);
- return NULL;
+ return -1;
}
_info->plugin = &plugin;
@@ -118,7 +120,7 @@ cda_init (DB_playItem_t *it) {
info->current_sector = info->first_sector;
info->tail_len = 0;
info->current_sample = 0;
- return _info;
+ return 0;
}
int
@@ -468,6 +470,7 @@ static DB_decoder_t plugin = {
.plugin.start = cda_start,
.plugin.stop = cda_stop,
.plugin.configdialog = settings_dlg,
+ .open = cda_open,
.init = cda_init,
.free = cda_free,
.read_int16 = cda_read_int16,