summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkomh <komh@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 03:26:18 +0000
committerkomh <komh@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-28 03:26:18 +0000
commit35fbd55c0fbe9c4beb65963c034ea85082cec6e5 (patch)
tree32a8c5a16ab54134e6ffa2a3c2bc20d39a0b3762
parentba66200023a0fd1d623e80632dc8f33d486a4fbf (diff)
downloadmpv-35fbd55c0fbe9c4beb65963c034ea85082cec6e5.tar.bz2
mpv-35fbd55c0fbe9c4beb65963c034ea85082cec6e5.tar.xz
Add cddb:// support for OS/2
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30788 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--osdep/osdep.h33
-rw-r--r--stream/stream_cddb.c74
2 files changed, 107 insertions, 0 deletions
diff --git a/osdep/osdep.h b/osdep/osdep.h
new file mode 100644
index 0000000000..0a64c31120
--- /dev/null
+++ b/osdep/osdep.h
@@ -0,0 +1,33 @@
+/*
+ * Header in order to include OS-specific headers, macros, types and so on
+ *
+ * Copyright (c) 2010 by KO Myung-Hun (komh@chollian.net)
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_OSDEP_H
+#define MPLAYER_OSDEP_H
+
+#ifdef __OS2__
+#define INCL_DOS
+#define INCL_DOSDEVIOCTL
+#include <os2.h>
+#endif
+
+#endif /* MPLAYER_OSDEP_H */
+
diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c
index 3ecad98183..47a0321e01 100644
--- a/stream/stream_cddb.c
+++ b/stream/stream_cddb.c
@@ -68,6 +68,8 @@
#include "mpbswap.h"
#endif
+#include "osdep/osdep.h"
+
#include "cdd.h"
#include "version.h"
#include "stream.h"
@@ -112,6 +114,78 @@ static int read_toc(const char *dev)
}
CloseHandle(drive);
+#elif defined(__OS2__)
+ UCHAR auchParamDisk[4] = {'C', 'D', '0', '1'};
+
+ struct {
+ BYTE bFirstTrack;
+ BYTE bLastTrack;
+ BYTE bLeadOutF;
+ BYTE bLeadOutS;
+ BYTE bLeadOutM;
+ BYTE bLeadOutReserved;
+ } __attribute__((packed)) sDataDisk;
+
+ struct {
+ UCHAR auchSign[4];
+ BYTE bTrack;
+ } __attribute__((packed)) sParamTrack = {{'C', 'D', '0', '1'},};
+
+ struct {
+ BYTE bStartF;
+ BYTE bStartS;
+ BYTE bStartM;
+ BYTE bStartReserved;
+ BYTE bControlInfo;
+ } __attribute__((packed)) sDataTrack;
+
+ HFILE hcd;
+ ULONG ulAction;
+ ULONG ulParamLen;
+ ULONG ulDataLen;
+ ULONG rc;
+
+ rc = DosOpen(dev, &hcd, &ulAction, 0, FILE_NORMAL,
+ OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
+ OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD,
+ NULL);
+ if (rc) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC);
+ return -1;
+ }
+
+ rc = DosDevIOCtl(hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
+ auchParamDisk, sizeof(auchParamDisk), &ulParamLen,
+ &sDataDisk, sizeof(sDataDisk), &ulDataLen);
+ if (!rc) {
+ first = sDataDisk.bFirstTrack - 1;
+ last = sDataDisk.bLastTrack;
+ for (i = first; i <= last; i++) {
+ if (i == last) {
+ sDataTrack.bStartM = sDataDisk.bLeadOutM;
+ sDataTrack.bStartS = sDataDisk.bLeadOutS;
+ sDataTrack.bStartF = sDataDisk.bLeadOutF;
+ } else {
+ sParamTrack.bTrack = i + 1;
+ rc = DosDevIOCtl(hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
+ &sParamTrack, sizeof(sParamTrack), &ulParamLen,
+ &sDataTrack, sizeof(sDataTrack), &ulDataLen);
+ if (rc)
+ break;
+ }
+
+ cdtoc[i].min = sDataTrack.bStartM;
+ cdtoc[i].sec = sDataTrack.bStartS;
+ cdtoc[i].frame = sDataTrack.bStartF;
+ }
+ }
+
+ DosClose(hcd);
+
+ if (rc) {
+ mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC);
+ return -1;
+ }
#else
int drive;
drive = open(dev, O_RDONLY | O_NONBLOCK);