summaryrefslogtreecommitdiff
path: root/src/input/input_cdda.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/input_cdda.c')
-rw-r--r--src/input/input_cdda.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index 824b97fbb..08229874c 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -210,7 +210,7 @@ typedef struct {
int mrls_allocated_entries;
xine_mrl_t **mrls;
- char *autoplaylist[MAX_TRACKS];
+ char **autoplaylist;
} cdda_input_class_t;
@@ -2436,6 +2436,21 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) {
return 1;
}
+static void free_autoplay_list(cdda_input_class_t *this)
+{
+ /* free old playlist */
+ if (this->autoplaylist) {
+ unsigned int i;
+ for( i = 0; this->autoplaylist[i]; i++ ) {
+ free( this->autoplaylist[i] );
+ this->autoplaylist[i] = NULL;
+ }
+
+ free(this->autoplaylist);
+ this->autoplaylist = NULL;
+ }
+}
+
static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
int *num_files) {
@@ -2447,11 +2462,7 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
lprintf("cdda_class_get_autoplay_list for >%s<\n", this->cdda_device);
- /* free old playlist */
- for( i = 0; this->autoplaylist[i]; i++ ) {
- free( this->autoplaylist[i] );
- this->autoplaylist[i] = NULL;
- }
+ free_autoplay_list(this);
/* get the CD TOC */
toc = init_cdrom_toc();
@@ -2509,6 +2520,8 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
num_tracks--;
if (num_tracks >= MAX_TRACKS-1)
num_tracks = MAX_TRACKS - 2;
+
+ this->autoplaylist = calloc(num_tracks + 2, sizeof(char *));
for ( i = 0; i <= num_tracks; i++ )
this->autoplaylist[i] = _x_asprintf("cdda:/%d",i+toc->first_track);
@@ -2624,7 +2637,14 @@ static void cdda_class_dispose (input_class_t *this_gen) {
config->unregister_callback(config, "media.audio_cd.drive_slowdown");
#endif
+ free_autoplay_list(this);
+
+ while (this->mrls_allocated_entries) {
+ MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]);
+ free(this->mrls[this->mrls_allocated_entries--]);
+ }
free (this->mrls);
+
free (this);
}