summaryrefslogtreecommitdiff
path: root/audio/sound-juicer/files/patch-src::sj-util.c
blob: feea811fcebbb168a45982f6816d691341878a23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--- 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;
@@ -151,20 +154,32 @@
 {
   int fd, status;
   
+#if defined(__linux__)
   fd = open (device, O_RDONLY | O_NONBLOCK | O_EXCL);
   if (fd < 0) {
     return FALSE;
   }
   
   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)
@@ -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;
   }
 
-  close (fd);
-
   return status == CDS_AUDIO;
+#elif defined (__FreeBSD__)
+  return TRUE;
+#else
+  return TRUE;
+#endif
 }
 
 /* Pass NULL to use g_free */