libdiscid: fix recipe, add src/disc_haiku.c (#2128)

This commit is contained in:
Xiang Fan
2018-01-17 21:00:20 +08:00
committed by fbrosson
parent 4f13e07a04
commit ebe8226692
2 changed files with 202 additions and 6 deletions

View File

@@ -4,19 +4,23 @@ disc IDs from audio CDs. It reads a CD's table of contents (TOC) and \
generates an identifier which can be used to lookup the CD at MusicBrainz. \
Additionally, it provides a submission URL for adding the disc ID to the \
database and gathers ISRCs and the MCN (=UPC/EAN) from disc."
HOMEPAGE="http://musicbrainz.org/doc/libdiscid"
COPYRIGHT="2012 Andrew Hawkins"
HOMEPAGE="https://musicbrainz.org/doc/libdiscid"
COPYRIGHT="2006-2017 MetaBrainz Foundation"
LICENSE="GNU LGPL v2.1"
REVISION="2"
REVISION="3"
SOURCE_URI="http://ftp.musicbrainz.org/pub/musicbrainz/libdiscid/libdiscid-$portVersion.tar.gz"
CHECKSUM_SHA256="f9e443ac4c0dd4819c2841fcc82169a46fb9a626352cdb9c7f65dd3624cd31b9"
PATCHES="libdiscid-$portVersion.patchset"
ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86"
libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
PROVIDES="
libdiscid$secondaryArchSuffix = $portVersion
lib:libdiscid$secondaryArchSuffix = 0.6.2 compat >= 0
lib:libdiscid$secondaryArchSuffix = $libVersionCompat
"
REQUIRES="
haiku$secondaryArchSuffix
@@ -25,7 +29,7 @@ REQUIRES="
PROVIDES_devel="
libdiscid${secondaryArchSuffix}_devel = $portVersion
devel:libdiscid$secondaryArchSuffix = 0.6.2 compat >= 0
devel:libdiscid$secondaryArchSuffix = $libVersionCompat
"
REQUIRES_devel="
libdiscid$secondaryArchSuffix == $portVersion base
@@ -36,13 +40,23 @@ BUILD_REQUIRES="
devel:libmusicbrainz5$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:aclocal
cmd:automake
cmd:autoreconf
cmd:awk
cmd:cmp
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:libtoolize$secondaryArchSuffix
cmd:make
"
defineDebugInfoPackage libdiscid$secondaryArchSuffix \
$libDir/libdiscid.so.$libVersion
BUILD()
{
autoreconf -fi
runConfigure ./configure
make $jobArgs
}
@@ -50,6 +64,8 @@ BUILD()
INSTALL()
{
make install
install -d $docDir
install -t $docDir AUTHORS README
rm $libDir/libdiscid.la
@@ -64,4 +80,3 @@ TEST()
{
make check
}

View File

@@ -0,0 +1,181 @@
From 7d3edd19c385a5f6869acd8bc285ff7abe1a51d3 Mon Sep 17 00:00:00 2001
From: sfanxiang <sfanxiang@gmail.com>
Date: Mon, 15 Jan 2018 02:01:29 +0000
Subject: port to Haiku
diff --git a/Makefile.am b/Makefile.am
index 31dce4c..dfabcd5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -77,9 +77,10 @@ libdiscid_la_SOURCES = src/base64.c src/sha1.c src/disc.c
libdiscid_la_LDFLAGS = -version-number @libdiscid_VERSION_LT@ -no-undefined
libdiscid_la_LIBADD =
-#if OS_BEOS
-#libdiscid_la_LIBADD += -lbe -lroot
-#endif
+if OS_HAIKU
+libdiscid_la_LIBADD += -lbe -lroot
+libdiscid_la_SOURCES += src/toc.c src/unix.c src/disc_haiku.c
+endif
if OS_DARWIN
libdiscid_la_LDFLAGS += -framework CoreFoundation -framework IOKit
libdiscid_la_SOURCES += src/toc.c src/unix.c src/disc_darwin.c
diff --git a/configure.ac b/configure.ac
index 0d21232..accef71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,7 @@ AC_DEFINE(libdiscid_EXPORTS, [], "the header is used to create the library")
case "${host_cpu}-${host_os}" in
- #*-beos*) os=beos;;
+ *-haiku*) os=haiku;;
*-mingw*) os=win32;;
*-cygwin*) os=win32;;
*-freebsd*) os=freebsd ;;
@@ -63,7 +63,7 @@ case "${host_cpu}-${host_os}" in
esac
AC_MSG_NOTICE([Using disc read implementation for: $os])
-#AM_CONDITIONAL([OS_BEOS], [test x$os = xbeos])
+AM_CONDITIONAL([OS_HAIKU], [test x$os = xhaiku])
AM_CONDITIONAL([OS_DARWIN], [test x$os = xdarwin])
AM_CONDITIONAL([OS_FREEBSD], [test x$os = xfreebsd])
AM_CONDITIONAL([OS_GENERIC], [test x$os = xgeneric])
diff --git a/src/disc_haiku.c b/src/disc_haiku.c
new file mode 100644
index 0000000..0680884
--- /dev/null
+++ b/src/disc_haiku.c
@@ -0,0 +1,126 @@
+/* --------------------------------------------------------------------------
+
+ MusicBrainz -- The Internet music metadatabase
+
+ Copyright (C) 2009 Shunsuke Kuroda
+ Copyright (C) 2006 Matthias Friedrich
+ Copyright (C) 2000 Robert Kaye
+ Copyright (C) 1999 Marc E E van Woerkom
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA
+
+--------------------------------------------------------------------------- */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <unistd.h>
+#include <scsi.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+
+
+#include "discid/discid.h"
+#include "discid/discid_private.h"
+#include "unix.h"
+
+#define NUM_CANDIDATES 4
+
+static char *device_candidates[NUM_CANDIDATES] = {
+ "/dev/disk/atapi/0/master/raw",
+ "/dev/disk/atapi/0/slave/raw",
+ "/dev/disk/atapi/1/master/raw",
+ "/dev/disk/atapi/1/slave/raw"
+};
+
+int mb_disc_unix_read_toc_header(int fd, mb_disc_toc *disk_toc) {
+ scsi_toc toc;
+ int ret = ioctl(fd, B_SCSI_GET_TOC, &toc);
+
+ if (ret == -1)
+ return 0; /* error */
+
+ disk_toc->first_track_num = toc.toc_data[2];
+ disk_toc->last_track_num = toc.toc_data[3];
+
+ return 1;
+}
+
+
+int mb_disc_unix_read_toc_entry(int fd, int track_num, mb_disc_toc_track *track) {
+ scsi_toc toc;
+ int ret, base, address;
+
+ ret = ioctl(fd, B_SCSI_GET_TOC, &toc);
+
+ if (ret == -1)
+ return 0; /* error */
+
+ /* leadout - track number 170 (0xaa) */
+ if (track_num == 0xaa)
+ track_num = toc.toc_data[3] + 1;
+
+ base = ((track_num - toc.toc_data[2]) * 8) + 4;
+
+ /* out of bound */
+ if (base >= sizeof(toc.toc_data) / sizeof(toc.toc_data[0]) ||
+ base + 7 >= sizeof(toc.toc_data) / sizeof(toc.toc_data[0]) ||
+ base < 0)
+ return 0;
+
+ /* LBA = (minutes * 60 + seconds) * 75 + frames - 150 */
+ address = toc.toc_data[base + 5];
+ address *= 60;
+ address += toc.toc_data[base + 6];
+ address *= 75;
+ address += toc.toc_data[base + 7];
+ address -= 150;
+ track->address = address;
+
+ track->control = toc.toc_data[base + 1];
+
+ return 1;
+}
+
+void mb_disc_unix_read_mcn(int fd, mb_disc_private *disc) {
+ return;
+}
+
+void mb_disc_unix_read_isrc(int fd, mb_disc_private *disc, int track_num) {
+ return;
+}
+
+char *mb_disc_get_default_device_unportable(void) {
+ return mb_disc_unix_find_device(device_candidates, NUM_CANDIDATES);
+}
+
+int mb_disc_has_feature_unportable(enum discid_feature feature) {
+ switch(feature) {
+ case DISCID_FEATURE_READ:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int mb_disc_read_unportable(mb_disc_private *disc, const char *device,
+ unsigned int features) {
+ return mb_disc_unix_read(disc, device, features);
+}
+
+/* EOF */
--
2.15.0