taem / cd-discid Goto Github PK
View Code? Open in Web Editor NEWcd-discid is a backend utility to get CDDB discid information from a CD-ROM disc
Home Page: http://linukz.org/cd-discid.shtml
License: GNU General Public License v2.0
cd-discid is a backend utility to get CDDB discid information from a CD-ROM disc
Home Page: http://linukz.org/cd-discid.shtml
License: GNU General Public License v2.0
The patch below adds support for IRIX to cd-discid:
diff -ur ./cd-discid.c ../../cd-discid-1.4//cd-discid.c
--- ./cd-discid.c Tue May 14 11:02:00 CEST 2013
+++ ../../cd-discid-1.4//cd-discid.c Sun May 22 18:39:33 CEST 2016
@@ -95,6 +95,19 @@
#define cdte_track_address trackStartAddress
#define DEVICE_NAME "/dev/disk1"
+#elif defined(__sgi)
+#include <dmedia/cdaudio.h>
+#define CD_FRAMES 75 /* per second */
+#define CD_MSF_OFFSET 150 /* MSF offset of first frame */
+#define cdrom_tochdr CDSTATUS
+#define cdth_trk0 first
+#define cdth_trk1 last
+#define close CDclose
+struct cdrom_tocentry
+{
+ int cdte_track_address ;
+};
+#define DEVICE_NAME "/dev/scsi/sc0d4l0"
#else
#error "Your OS isn't supported yet."
#endif /* os selection */
@@ -127,13 +140,20 @@
int main(int argc, char *argv[])
{
int len;
- int drive, i, totaltime;
+ int i, totaltime;
long int cksum = 0;
int musicbrainz = 0;
unsigned char first = 1, last = 1;
char *devicename = DEVICE_NAME;
- struct cdrom_tochdr hdr;
struct cdrom_tocentry *TocEntry;
+#ifndef __sgi
+ int drive;
+ struct cdrom_tochdr hdr;
+#else
+ CDPLAYER *drive;
+ CDTRACKINFO info;
+ cdrom_tochdr hdr;
+#endif
char *command = argv[0];
#if defined(__OpenBSD__) || defined(__NetBSD__)
@@ -162,8 +182,13 @@
exit(EXIT_FAILURE);
}
+#if defined(__sgi)
+ drive = CDopen(devicename, "r");
+ if (drive == 0) {
+#else
drive = open(devicename, O_RDONLY | O_NONBLOCK);
if (drive < 0) {
+#endif
fprintf(stderr, "%s: %s: ", command, devicename);
perror("open");
exit(EXIT_FAILURE);
@@ -179,6 +204,11 @@
perror("DKIOCCDREADDISCINFO");
exit(EXIT_FAILURE);
}
+#elif defined(__sgi)
+ if (0 == CDgetstatus(drive, &hdr)) {
+ perror("CDROMREADTOCHDR");
+ exit(EXIT_FAILURE);
+ }
#else
if (ioctl(drive, CDROMREADTOCHDR, &hdr) < 0) {
fprintf(stderr, "%s: %s: ", command, devicename);
@@ -238,6 +268,14 @@
*/
TocEntry[last].cdte_track_address = TocEntry[last - 1].trackSize +
TocEntry[last - 1].trackStartAddress;
+#elif defined(__sgi)
+ for (i = 0; i < last; i++) {
+ if (0 == CDgettrackinfo(drive, i + 1, &info)) {
+ fprintf(stderr, "CDgettrackinfo failed on track %i: %s\n", i + 1, devicename);
+ }
+ TocEntry[i].cdte_track_address = info.start_min*60*CD_FRAMES + info.start_sec*CD_FRAMES + info.start_frame;
+ }
+ TocEntry[last].cdte_track_address = TocEntry[last - 1].cdte_track_address + info.total_min*60*CD_FRAMES + info.total_sec*CD_FRAMES + info.total_frame;
#else /* FreeBSD, Linux, Solaris */
for (i = 0; i < last; i++) {
/* tracks start with 1, but I must start with 0 on OpenBSD */
Trying to use it together with cddb_query
(from libcddb) gives an error:
freso@kotake> cd-discid --version
cd-discid 1.4.
freso@kotake> cd-discid
60100919 25 150 13455 23860 35583 43712 52994 66828 77283 86154 105083 120642 130551 143796 158474 170604 182849 198225 210288 221351 231534 242998 261047 27
3360 284556 295670 4107
freso@kotake> cddb_query calc $(cd-discid)
error: track count is 25, but 26 frame offset(s) specified
I.e. I get this correct FreeDB-ID:
38098c05
If I do: cd-discid --musicbrainz /dev/sr1 , I get:
5 183 51735 90810 126230 165433 183465
This TOC couldn't be found here, if you give in (FreeDB-ID:) 38098c05 (you will find 6 CDs)
https://musicbrainz.org/search
My own code in a windows program finds it normally at FreeDB this way (and via Telnet):
cddb query 38098c05 5 183 51735 90810 126230 165433 2445
Would it be possible to cut a new release to pick up the change to raw devices on OS X? (a691a92) Seems like it's needed to get correct output there; see Homebrew/legacy-homebrew#46267.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.