freebsd-ports/audio/sound-juicer/files/patch-src::sj-util.c

72 lines
1.3 KiB
C
Raw Normal View History

2004-06-16 04:16:58 +02:00
--- src/sj-util.c.orig Tue Jun 15 19:14:09 2004
+++ src/sj-util.c Tue Jun 15 19:29:16 2004
@@ -122,6 +122,9 @@
gtk_widget_destroy (dialog);
goto done;
}
+#ifdef __FreeBSD__
+ ioctl (fd, CDIOCALLOW);
+#endif
result = ioctl (fd, CDROMEJECT);
if (result == -1) {
GtkWidget *dialog;
2004-06-16 04:16:58 +02:00
@@ -151,20 +154,32 @@
{
int fd, status;
2004-06-16 04:16:58 +02:00
+#if defined(__linux__)
fd = open (device, O_RDONLY | O_NONBLOCK | O_EXCL);
if (fd < 0) {
return FALSE;
}
2004-06-16 04:16:58 +02:00
status = ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
+ close (fd);
if (status < 0) {
- close (fd);
return FALSE;
}
- close (fd);
-
return status == CDS_TRAY_OPEN;
+#elif defined(__FreeBSD__)
+ struct ioc_toc_header h;
+
+ fd = open (device, O_RDONLY | O_NONBLOCK | O_EXCL);
+ if (fd < 0) {
+ return FALSE;
+ }
+
+ status = ioctl (fd, CDIOREADTOCHEADER, &h);
+ close (fd);
+
+ return status < 0;
+#endif
}
gboolean is_audio_cd (const char *device)
2004-06-16 04:16:58 +02:00
@@ -191,15 +210,19 @@
return FALSE;
}
+#if defined(__linux__)
status = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT);
+ close (fd);
if (status < 0) {
- close (fd);
return FALSE;
}
2004-06-16 04:16:58 +02:00
- close (fd);
-
return status == CDS_AUDIO;
+#elif defined (__FreeBSD__)
+ return TRUE;
+#else
+ return TRUE;
+#endif
}
/* Pass NULL to use g_free */