1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-11 04:01:31 +00:00

make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia

patch by Erik Lunchpail <erik_27can at yahoo.com>
base on patch by Rocky Bernstein <rocky at panix.com>
minor modification by myself


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16936 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
faust3 2005-11-06 17:42:20 +00:00
parent f57a65dd86
commit 0538ed8780
5 changed files with 179 additions and 5 deletions

View File

@ -26,6 +26,10 @@ ifeq ($(VIDIX),yes)
SUBDIRS += libdha vidix SUBDIRS += libdha vidix
DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
endif endif
ifeq ($(HAVE_LIBCDIO),yes)
CFLAGS += $(LIBCDIO_INC)
COMMON_LIBS += $(LIBCDIO_LIB)
endif
SRCS_COMMON = asxparser.c \ SRCS_COMMON = asxparser.c \
codec-cfg.c \ codec-cfg.c \

52
configure vendored
View File

@ -226,6 +226,7 @@ Codecs:
--enable-gif enable gif support [autodetect] --enable-gif enable gif support [autodetect]
--enable-png enable png input/output support [autodetect] --enable-png enable png input/output support [autodetect]
--enable-jpeg enable jpeg input/output support [autodetect] --enable-jpeg enable jpeg input/output support [autodetect]
--enable-libcdio enable external libcdio support [autodetect]
--enable-liblzo enable external liblzo support [autodetect] --enable-liblzo enable external liblzo support [autodetect]
--disable-win32 disable Win32 DLL support [autodetect] --disable-win32 disable Win32 DLL support [autodetect]
--disable-dshow disable Win32/DirectShow support [autodetect] --disable-dshow disable Win32/DirectShow support [autodetect]
@ -1480,6 +1481,7 @@ _arts=auto
_esd=auto _esd=auto
_polyp=auto _polyp=auto
_jack=auto _jack=auto
_libcdio=auto
_liblzo=auto _liblzo=auto
_mad=auto _mad=auto
_toolame=auto _toolame=auto
@ -1677,6 +1679,8 @@ for ac_option do
--disable-mad) _mad=no ;; --disable-mad) _mad=no ;;
--disable-toolame) _toolame=no ;; --disable-toolame) _toolame=no ;;
--disable-twolame) _twolame=no ;; --disable-twolame) _twolame=no ;;
--enable-libcdio) _libcdio=yes ;;
--disable-libcio) _libcdio=no ;;
--enable-liblzo) _liblzo=yes ;; --enable-liblzo) _liblzo=yes ;;
--disable-liblzo) _liblzo=no ;; --disable-liblzo) _liblzo=no ;;
--enable-vorbis) _vorbis=yes ;; --enable-vorbis) _vorbis=yes ;;
@ -5076,6 +5080,49 @@ fi
echores "$_cdparanoia" echores "$_cdparanoia"
echocheck "libcdio"
if test "$_libcdio" = auto && test "$_cdparanoia" = no ; then
if ( pkg-config --modversion libcdio) > /dev/null 2>&1 ; then
cat > $TMPC << EOF
#include <stdio.h>
#include <cdio/version.h>
#include <cdio/cdda.h>
#include <cdio/paranoia.h>
int main()
{
printf("%s\n", CDIO_VERSION);
return 0;
}
EOF
_libcdio=no
for _inc_tmp in "$_inc_libcdio" "-I/usr/include/cdio" "-I/usr/local/include/cdio" ; do
cc_check `pkg-config --cflags --libs libcdio` $_inc_tmp $_ld_libcdio -lcdio_cdda -lcdio_paranoia $_ld_lm && _inc_libcdio="$_inc_tmp" && ( $TMPO >> "$TMPLOG" ) && _libcdio=yes && break
done
else
_libcdio=no
fi
fi
if test "$_libcdio" = yes && test "$_cdparanoia" = no ; then
_def_libcdio='#define HAVE_LIBCDIO'
_def_cdparanoia='#define HAVE_CDDA'
_def_havelibcdio='yes'
_inputmodules="cdda $_inputmodules"
_inc_libcdio=`pkg-config --cflags libcdio`
_ld_libcdio=`pkg-config --libs libcdio`
_ld_cdparanoia="$_ld_cdparanoia -lcdio_cdda -lcdio_paranoia -lcdio"
else
if test "$_cdparanoia" = yes ; then
_libcdio="no (using cdparanoia)"
else
_libcdio=no
fi
_def_libcdio='#undef HAVE_LIBCDIO'
_def_havelibcdio='no'
fi
echores "$_libcdio"
echocheck "freetype >= 2.0.9" echocheck "freetype >= 2.0.9"
# freetype depends on iconv # freetype depends on iconv
@ -7116,6 +7163,8 @@ FONTCONFIG_INC = $_inc_fontconfig
FONTCONFIG_LIB = $_ld_fontconfig FONTCONFIG_LIB = $_ld_fontconfig
FRIBIDI_INC = $_inc_fribidi FRIBIDI_INC = $_inc_fribidi
FRIBIDI_LIB = $_ld_fribidi FRIBIDI_LIB = $_ld_fribidi
LIBCDIO_INC = $_inc_libcdio
LIBCDIO_LIB = $_ld_libcdio
LIBLZO_LIB= $_ld_liblzo LIBLZO_LIB= $_ld_liblzo
MAD_LIB = $_ld_mad MAD_LIB = $_ld_mad
VORBIS_LIB = $_ld_vorbis $_ld_libdv VORBIS_LIB = $_ld_vorbis $_ld_libdv
@ -7223,6 +7272,9 @@ $_def_debug
/* Toggles colorized output */ /* Toggles colorized output */
//#define MSG_USE_COLORS 1 //#define MSG_USE_COLORS 1
/* Indicates that libcdio is available for VCD and CD-DA playback */
$_def_libcdio
/* Indicates that Ogle's libdvdread is available for DVD playback */ /* Indicates that Ogle's libdvdread is available for DVD playback */
$_def_dvdread $_def_dvdread

View File

@ -1,8 +1,14 @@
#ifndef __CDD_H__ #ifndef __CDD_H__
#define __CDD_H__ #define __CDD_H__
#include "config.h"
#ifndef HAVE_LIBCDIO
#include <cdda_interface.h> #include <cdda_interface.h>
#include <cdda_paranoia.h> #include <cdda_paranoia.h>
#else
#include <cdio/cdda.h>
#include <cdio/paranoia.h>
#endif
typedef struct { typedef struct {
char cddb_hello[1024]; char cddb_hello[1024];
@ -48,8 +54,13 @@ typedef struct {
} cd_info_t; } cd_info_t;
typedef struct { typedef struct {
#ifndef HAVE_LIBCDIO
cdrom_drive* cd; cdrom_drive* cd;
cdrom_paranoia* cdp; cdrom_paranoia* cdp;
#else
cdrom_drive_t* cd;
cdrom_paranoia_t* cdp;
#endif
int sector; int sector;
int start_sector; int start_sector;
int end_sector; int end_sector;

View File

@ -87,13 +87,17 @@ extern cd_info_t* cddb_parse_xmcd(char *xmcd_file);
static int seek(stream_t* s,off_t pos); static int seek(stream_t* s,off_t pos);
static int fill_buffer(stream_t* s, char* buffer, int max_len); static int fill_buffer(stream_t* s, char* buffer, int max_len);
static void close(stream_t* s); static void close_cdda(stream_t* s);
static int open_cdda(stream_t *st,int m, void* opts, int* file_format) { static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
struct cdda_params* p = (struct cdda_params*)opts; struct cdda_params* p = (struct cdda_params*)opts;
int mode = p->paranoia_mode; int mode = p->paranoia_mode;
int offset = p->toc_offset; int offset = p->toc_offset;
#ifndef HAVE_LIBCDIO
cdrom_drive* cdd = NULL; cdrom_drive* cdd = NULL;
#else
cdrom_drive_t* cdd = NULL;
#endif
cdda_priv* priv; cdda_priv* priv;
cd_info_t *cd_info,*cddb_info = NULL; cd_info_t *cd_info,*cddb_info = NULL;
unsigned int audiolen=0; unsigned int audiolen=0;
@ -125,9 +129,11 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
} }
#endif #endif
#ifndef HAVE_LIBCDIO
if(p->generic_dev) if(p->generic_dev)
cdd = cdda_identify_scsi(p->generic_dev,p->device,0,NULL); cdd = cdda_identify_scsi(p->generic_dev,p->device,0,NULL);
else else
#endif
#if defined(__NetBSD__) #if defined(__NetBSD__)
cdd = cdda_identify_scsi(p->device,p->device,0,NULL); cdd = cdda_identify_scsi(p->device,p->device,0,NULL);
#else #else
@ -144,7 +150,9 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
if(p->sector_size) { if(p->sector_size) {
cdd->nsectors = p->sector_size; cdd->nsectors = p->sector_size;
#ifndef HAVE_LIBCDIO
cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW; cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW;
#endif
} }
if(cdda_open(cdd) != 0) { if(cdda_open(cdd) != 0) {
@ -218,10 +226,17 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
if(p->no_skip) if(p->no_skip)
mode |= PARANOIA_MODE_NEVERSKIP; mode |= PARANOIA_MODE_NEVERSKIP;
#ifndef HAVE_LIBCDIO
paranoia_modeset(cdd, mode); paranoia_modeset(cdd, mode);
if(p->search_overlap >= 0) if(p->search_overlap >= 0)
paranoia_overlapset(cdd,p->search_overlap); paranoia_overlapset(cdd,p->search_overlap);
#else
paranoia_modeset(priv->cdp, mode);
if(p->search_overlap >= 0)
paranoia_overlapset(priv->cdp,p->search_overlap);
#endif
paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET); paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET);
priv->sector = priv->start_sector; priv->sector = priv->start_sector;
@ -235,14 +250,21 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
#endif #endif
st->priv = priv; st->priv = priv;
#ifndef HAVE_LIBCDIO
st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW; st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW;
st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW; st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW;
st->type = STREAMTYPE_CDDA; st->type = STREAMTYPE_CDDA;
st->sector_size = CD_FRAMESIZE_RAW; st->sector_size = CD_FRAMESIZE_RAW;
#else
st->start_pos = priv->start_sector*CDIO_CD_FRAMESIZE_RAW;
st->end_pos = priv->end_sector*CDIO_CD_FRAMESIZE_RAW;
st->type = STREAMTYPE_CDDA;
st->sector_size = CDIO_CD_FRAMESIZE_RAW;
#endif
st->fill_buffer = fill_buffer; st->fill_buffer = fill_buffer;
st->seek = seek; st->seek = seek;
st->close = close; st->close = close_cdda;
*file_format = DEMUXER_TYPE_RAWAUDIO; *file_format = DEMUXER_TYPE_RAWAUDIO;
@ -251,7 +273,11 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
return STREAM_OK; return STREAM_OK;
} }
#ifndef HAVE_LIBCDIO
static void cdparanoia_callback(long inpos, int function) { static void cdparanoia_callback(long inpos, int function) {
#else
static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) {
#endif
} }
static int fill_buffer(stream_t* s, char* buffer, int max_len) { static int fill_buffer(stream_t* s, char* buffer, int max_len) {
@ -263,13 +289,22 @@ static int fill_buffer(stream_t* s, char* buffer, int max_len) {
buf = paranoia_read(p->cdp,cdparanoia_callback); buf = paranoia_read(p->cdp,cdparanoia_callback);
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
#ifndef HAVE_LIBCDIO
for(i=0;i<CD_FRAMESIZE_RAW/2;i++) for(i=0;i<CD_FRAMESIZE_RAW/2;i++)
#else
for(i=0;i<CDIO_CD_FRAMESIZE_RAW/2;i++)
#endif
buf[i]=le2me_16(buf[i]); buf[i]=le2me_16(buf[i]);
#endif #endif
p->sector++; p->sector++;
#ifndef HAVE_LIBCDIO
s->pos = p->sector*CD_FRAMESIZE_RAW; s->pos = p->sector*CD_FRAMESIZE_RAW;
memcpy(buffer,buf,CD_FRAMESIZE_RAW); memcpy(buffer,buf,CD_FRAMESIZE_RAW);
#else
s->pos = p->sector*CDIO_CD_FRAMESIZE_RAW;
memcpy(buffer,buf,CDIO_CD_FRAMESIZE_RAW);
#endif
if((p->sector < p->start_sector) || (p->sector >= p->end_sector)) { if((p->sector < p->start_sector) || (p->sector >= p->end_sector)) {
s->eof = 1; s->eof = 1;
@ -290,7 +325,11 @@ static int fill_buffer(stream_t* s, char* buffer, int max_len) {
} }
#ifndef HAVE_LIBCDIO
return CD_FRAMESIZE_RAW; return CD_FRAMESIZE_RAW;
#else
return CDIO_CD_FRAMESIZE_RAW;
#endif
} }
static int seek(stream_t* s,off_t newpos) { static int seek(stream_t* s,off_t newpos) {
@ -306,8 +345,13 @@ static int seek(stream_t* s,off_t newpos) {
return 0; return 0;
} }
#ifndef HAVE_LIBCDIO
sec = s->pos/CD_FRAMESIZE_RAW; sec = s->pos/CD_FRAMESIZE_RAW;
//printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW); //printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW);
#else
sec = s->pos/CDIO_CD_FRAMESIZE_RAW;
//printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CDIO_CD_FRAMESIZE_RAW);
#endif
//printf("sector: %d new: %d\n", p->sector, sec ); //printf("sector: %d new: %d\n", p->sector, sec );
for(i=0;i<p->cd->tracks;i++){ for(i=0;i<p->cd->tracks;i++){
@ -338,14 +382,18 @@ static int seek(stream_t* s,off_t newpos) {
#endif #endif
p->sector = sec; p->sector = sec;
#ifndef HAVE_LIBCDIO
// s->pos = sec*CD_FRAMESIZE_RAW; // s->pos = sec*CD_FRAMESIZE_RAW;
#else
// s->pos = sec*CDIO_CD_FRAMESIZE_RAW;
#endif
//printf("seek: %d, sec: %d\n", (int)s->pos, sec); //printf("seek: %d, sec: %d\n", (int)s->pos, sec);
paranoia_seek(p->cdp,sec,SEEK_SET); paranoia_seek(p->cdp,sec,SEEK_SET);
return 1; return 1;
} }
static void close(stream_t* s) { static void close_cdda(stream_t* s) {
cdda_priv* p = (cdda_priv*)s->priv; cdda_priv* p = (cdda_priv*)s->priv;
paranoia_free(p->cdp); paranoia_free(p->cdp);
cdda_close(p->cd); cdda_close(p->cd);

View File

@ -21,10 +21,18 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
#include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#ifdef WIN32
#ifdef __MINGW32__
#define mkdir(a,b) mkdir(a)
#endif
#include <windows.h>
#include <winsock2.h>
#else
#include <netdb.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -32,6 +40,8 @@
#include <linux/cdrom.h> #include <linux/cdrom.h>
#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/cdio.h> #include <sys/cdio.h>
#elif defined(WIN32)
#include <ddk/ntddcdrm.h>
#endif #endif
#include "cdd.h" #include "cdd.h"
@ -83,6 +93,41 @@ read_toc(const char *dev) {
return tochdr.cdth_trk1; return tochdr.cdth_trk1;
} }
#elif defined(WIN32)
int
read_toc(const char *dev) {
HANDLE drive;
DWORD r;
CDROM_TOC toc;
char device[10];
int i;
sprintf(device, "\\\\.\\%s", dev);
drive = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if(!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) {
mp_msg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n");
return 0;
}
for (i = toc.FirstTrack; i <= toc.LastTrack; i++) {
toc.FirstTrack = i;
cdtoc[i-1].min = toc.TrackData[i - 1].Address[1];
cdtoc[i-1].sec = toc.TrackData[i - 1].Address[2];
cdtoc[i-1].frame = toc.TrackData[i - 1].Address[3];
cdtoc[i-1].frame += cdtoc[i-1].min*60*75;
cdtoc[i-1].frame += cdtoc[i-1].sec*75;
}
toc.FirstTrack = 0xAA;
cdtoc[toc.LastTrack].min = toc.TrackData[toc.LastTrack].Address[1];
cdtoc[toc.LastTrack].sec = toc.TrackData[toc.LastTrack].Address[2];
cdtoc[toc.LastTrack].frame = toc.TrackData[toc.LastTrack].Address[3];
cdtoc[toc.LastTrack].frame += cdtoc[toc.LastTrack].min*60*75;
cdtoc[toc.LastTrack].frame += cdtoc[toc.LastTrack].sec*75;
CloseHandle(drive);
return toc.LastTrack;
}
#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
int int
read_toc(const char *dev) { read_toc(const char *dev) {
@ -281,7 +326,11 @@ cddb_read_cache(cddb_data_t *cddb_data) {
sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id);
file_fd = open(file_name, O_RDONLY); file_fd = open(file_name, O_RDONLY
#ifdef WIN32
| O_BINARY
#endif
);
if( file_fd<0 ) { if( file_fd<0 ) {
printf("No cache found\n"); printf("No cache found\n");
return -1; return -1;
@ -328,7 +377,11 @@ cddb_write_cache(cddb_data_t *cddb_data) {
if( ret<0 ) { if( ret<0 ) {
// Directory not present, create it. // Directory not present, create it.
ret = mkdir( cddb_data->cache_dir, 0755 ); ret = mkdir( cddb_data->cache_dir, 0755 );
#ifdef __MINGW32__
if( ret<0 && errno != EEXIST ) {
#else
if( ret<0 ) { if( ret<0 ) {
#endif
perror("mkdir"); perror("mkdir");
printf("Failed to create directory %s\n", cddb_data->cache_dir ); printf("Failed to create directory %s\n", cddb_data->cache_dir );
return -1; return -1;
@ -674,6 +727,12 @@ cddb_resolve(const char *dev, char **xmcd_file) {
} }
home_dir = getenv("HOME"); home_dir = getenv("HOME");
#ifdef __MINGW32__
if( home_dir==NULL ) home_dir = getenv("USERPROFILE");
if( home_dir==NULL ) home_dir = getenv("HOMEPATH");
// Last resort, store the cddb cache in the mplayer directory
if( home_dir==NULL ) home_dir = (char *)get_path("");
#endif
if( home_dir==NULL ) { if( home_dir==NULL ) {
cddb_data.cache_dir = NULL; cddb_data.cache_dir = NULL;
} else { } else {