changeset 1389:e2754a023ae0

Fixed surprise eject segfault
author Calin Crisan ccrisan@gmail.com
date Sat, 28 Jul 2007 00:08:41 +0300
parents eb6c11de9f33
children 58f74efbe943
files src/cdaudio-ng/cdaudio-ng.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/cdaudio-ng/cdaudio-ng.c	Fri Jul 27 23:03:20 2007 +0300
+++ b/src/cdaudio-ng/cdaudio-ng.c	Sat Jul 28 00:08:41 2007 +0300
@@ -19,7 +19,6 @@
 #include <audacious/i18n.h>
 #include <audacious/configdb.h>
 #include <audacious/plugin.h>
-//#include <audacious/playback.h>	// todo: this should be available soon (by 1.4)
 #include <audacious/util.h>
 #include <audacious/output.h>
 #include "config.h"
@@ -203,7 +202,8 @@
 		if (cdio_get_media_changed(pcdio) && pcdio != NULL) {
 			if (debug)
 				printf("cdaudio-ng: cd changed, rescanning\n");
-			cdaudio_scan_dir(CDDA_DEFAULT);
+			if (cdaudio_scan_dir(CDDA_DEFAULT) == NULL)
+				pcdio = NULL;
 		}
 
 		if (pcdio == NULL) {
@@ -269,7 +269,8 @@
 			cleanup_on_error();
 			return NULL;
 		}
-		cdio_free_device_list(ppcd_drives);
+		if (ppcd_drives != NULL && *ppcd_drives != NULL)
+			cdio_free_device_list(ppcd_drives);
 	}
 
 		/* limit read speed */
@@ -463,6 +464,13 @@
 		cdaudio_scan_dir(CDDA_DEFAULT);
 	}
 
+	if (trackinfo == NULL) {
+		if (debug)
+			printf("cdaudio-ng: no cd information can be retrieved, aborting\n");
+		pinputplayback->playing = FALSE;
+		return;
+	}
+
 	int trackno = find_trackno_from_filename(pinputplayback->filename);
 	if (trackno < firsttrackno || trackno > lasttrackno) {
 		fprintf(stderr, "cdaudio-ng: trackno %d is out of range [%d..%d]\n", trackno, firsttrackno, lasttrackno);
@@ -737,6 +745,9 @@
 
 TitleInput *create_tuple_from_trackinfo(char *filename)
 {
+	if (trackinfo == NULL)
+		return NULL;
+
 	TitleInput *tuple = bmp_title_input_new();
 	int trackno = find_trackno_from_filename(filename);
 
@@ -869,7 +880,6 @@
 {
 	if (playing_track != -1) {
 		playing_track = -1;
-		playback_stop();
 	}
 
 	if (trackinfo != NULL) {