summaryrefslogtreecommitdiff
path: root/audio/libdiscid/patches/patch-ab
blob: 0edad29f1bbe6061a8b4c4a2ceea4243fd344107 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
$NetBSD: patch-ab,v 1.1 2009/07/07 17:44:51 drochner Exp $

--- src/disc_freebsd.c.orig	2008-01-12 12:41:51.000000000 +0100
+++ src/disc_freebsd.c
@@ -45,6 +45,9 @@
 
 #define XA_INTERVAL			((60 + 90 + 2) * CD_FRAMES)
 
+#ifdef __NetBSD__
+#define CDIOREADTOCENTRY CDIOREADTOCENTRIES
+#endif
 
 /* TODO: make sure it's available */
 int snprintf(char *str, size_t size, const char *format, ...);
@@ -52,7 +55,12 @@ int snprintf(char *str, size_t size, con
 
 static int read_toc_header(int fd, int *first, int *last) {
 	struct ioc_toc_header th;
+#ifdef __NetBSD__
+	struct cd_toc_entry td;
+	struct ioc_read_toc_entry te;
+#else
 	struct ioc_read_toc_single_entry te;
+#endif
 
 	int ret = ioctl(fd, CDIOREADTOCHEADER, &th);
 
@@ -68,10 +76,20 @@ static int read_toc_header(int fd, int *
 	 * session are handled correctly.
 	 */
 	te.address_format = CD_LBA_FORMAT;
+#ifdef __NetBSD__
+	te.starting_track = th.ending_track;
+	te.data_len = sizeof(td);
+	te.data = &td;
+#else
 	te.track = th.ending_track;
+#endif
 	ret = ioctl(fd, CDIOREADTOCENTRY, &te);
 
+#ifdef __NetBSD__
+	if (( td.control & CD_DATA_TRACK) != 0 )
+#else
 	if (( te.entry.control & CD_DATA_TRACK) != 0 )
+#endif
 		(*last)--;
 
 	return ret;
@@ -79,17 +97,32 @@ static int read_toc_header(int fd, int *
 
 
 static int read_toc_entry(int fd, int track_num, unsigned long *lba) {
+#ifdef __NetBSD__
+	struct cd_toc_entry td;
+	struct ioc_read_toc_entry te;
+#else
 	struct ioc_read_toc_single_entry te;
+#endif
 	int ret;
 
+#ifdef __NetBSD__
+	te.starting_track = track_num;
+	te.data_len = sizeof(td);
+	te.data = &td;
+#else
 	te.track = track_num;
+#endif
 	te.address_format = CD_LBA_FORMAT;
 
 	ret = ioctl(fd, CDIOREADTOCENTRY, &te);
 	assert( te.address_format == CD_LBA_FORMAT );
 
 	if ( ret == 0 )
+#ifdef __NetBSD__
+		*lba = td.addr.lba;
+#else
 		*lba = ntohl(te.entry.addr.lba);
+#endif
 
 	return ret;
 }
@@ -97,16 +130,32 @@ static int read_toc_entry(int fd, int tr
 
 static int read_leadout(int fd, unsigned long *lba) {
 	struct ioc_toc_header th;
+#ifdef __NetBSD__
+	struct cd_toc_entry td;
+	struct ioc_read_toc_entry te;
+#else
 	struct ioc_read_toc_single_entry te;
+#endif
 	int ret;
    
 	ret = ioctl(fd, CDIOREADTOCHEADER, &th);
+#ifdef __NetBSD__
+	te.starting_track = th.ending_track;
+	te.data_len = sizeof(td);
+	te.data = &td;
+#else
 	te.track = th.ending_track;
+#endif
 	te.address_format = CD_LBA_FORMAT;
 	ret = ioctl(fd, CDIOREADTOCENTRY, &te);
 
+#ifdef __NetBSD__
+	if (( td.control & CD_DATA_TRACK) != 0 ) {
+		*lba = td.addr.lba - 11400;
+#else
 	if (( te.entry.control & CD_DATA_TRACK) != 0 ) {
 		*lba = ntohl(te.entry.addr.lba) - 11400;
+#endif
 		return ret;
 	}