1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

Support cddb on darwin.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25421 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
ulion 2007-12-16 11:31:52 +00:00
parent 1abce87cbe
commit 6277b4387f
2 changed files with 52 additions and 2 deletions

2
configure vendored
View File

@ -5503,7 +5503,7 @@ fi
echores "$_libcdio"
if test "$_cdda" = yes ; then
test $_cddb = auto && test $_network = yes && ! darwin && _cddb=yes
test $_cddb = auto && test $_network = yes && _cddb=yes
_def_cdparanoia='#define HAVE_CDDA'
_inputmodules="cdda $_inputmodules"
else

View File

@ -47,6 +47,10 @@
#include <ddk/ntddcdrm.h>
#elif (__bsdi__)
#include <dvd.h>
#elif defined(__APPLE__) || defined(__DARWIN__)
#include <IOKit/storage/IOCDTypes.h>
#include <IOKit/storage/IOCDMediaBSDClient.h>
#include "mpbswap.h"
#endif
#include "cdd.h"
@ -64,7 +68,7 @@ static int cdtoc_last_track;
int
read_toc(const char *dev) {
int first, last;
int first = 0, last = -1;
int i;
#ifdef WIN32
HANDLE drive;
@ -143,6 +147,52 @@ read_toc(const char *dev) {
cdtoc[i].sec = toc_buffer.addr.msf.second;
cdtoc[i].frame = toc_buffer.addr.msf.frame;
}
#elif defined(__APPLE__) || defined(__DARWIN__)
{
dk_cd_read_toc_t tochdr;
uint8_t buf[4];
uint8_t buf2[100 * sizeof(CDTOCDescriptor) + sizeof(CDTOC)];
memset(&tochdr, 0, sizeof(tochdr));
tochdr.bufferLength = sizeof(buf);
tochdr.buffer = &buf;
if (!ioctl(drive, DKIOCCDREADTOC, &tochdr)
&& tochdr.bufferLength == sizeof(buf)) {
first = buf[2] - 1;
last = buf[3];
}
if (last >= 0) {
memset(&tochdr, 0, sizeof(tochdr));
tochdr.bufferLength = sizeof(buf2);
tochdr.buffer = &buf2;
tochdr.format = kCDTOCFormatTOC;
if (ioctl(drive, DKIOCCDREADTOC, &tochdr)
|| tochdr.bufferLength < sizeof(CDTOC))
last = -1;
}
if (last >= 0) {
CDTOC *cdToc = (CDTOC *)buf2;
CDTrackInfo lastTrack;
dk_cd_read_track_info_t trackInfoParams;
for (i = first; i < last; ++i) {
CDMSF msf = CDConvertTrackNumberToMSF(i + 1, cdToc);
cdtoc[i].min = msf.minute;
cdtoc[i].sec = msf.second;
cdtoc[i].frame = msf.frame;
}
memset(&trackInfoParams, 0, sizeof(trackInfoParams));
trackInfoParams.addressType = kCDTrackInfoAddressTypeTrackNumber;
trackInfoParams.bufferLength = sizeof(lastTrack);
trackInfoParams.address = last;
trackInfoParams.buffer = &lastTrack;
if (!ioctl(drive, DKIOCCDREADTRACKINFO, &trackInfoParams)) {
CDMSF msf = CDConvertLBAToMSF(be2me_32(lastTrack.trackStartAddress)
+ be2me_32(lastTrack.trackSize));
cdtoc[last].min = msf.minute;
cdtoc[last].sec = msf.second;
cdtoc[last].frame = msf.frame;
}
}
}
#endif
close(drive);
#endif