Skip to content

Commit

Permalink
make it optionally possible to compile MPlayer with libcdio instead o…
Browse files Browse the repository at this point in the history
…f 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
  • Loading branch information
faust3 committed Nov 6, 2005
1 parent f57a65d commit 0538ed8
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -26,6 +26,10 @@ ifeq ($(VIDIX),yes)
SUBDIRS += libdha vidix
DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
endif
ifeq ($(HAVE_LIBCDIO),yes)
CFLAGS += $(LIBCDIO_INC)
COMMON_LIBS += $(LIBCDIO_LIB)
endif

SRCS_COMMON = asxparser.c \
codec-cfg.c \
Expand Down
52 changes: 52 additions & 0 deletions configure
Expand Up @@ -226,6 +226,7 @@ Codecs:
--enable-gif enable gif support [autodetect]
--enable-png enable png 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]
--disable-win32 disable Win32 DLL support [autodetect]
--disable-dshow disable Win32/DirectShow support [autodetect]
Expand Down Expand Up @@ -1480,6 +1481,7 @@ _arts=auto
_esd=auto
_polyp=auto
_jack=auto
_libcdio=auto
_liblzo=auto
_mad=auto
_toolame=auto
Expand Down Expand Up @@ -1677,6 +1679,8 @@ for ac_option do
--disable-mad) _mad=no ;;
--disable-toolame) _toolame=no ;;
--disable-twolame) _twolame=no ;;
--enable-libcdio) _libcdio=yes ;;
--disable-libcio) _libcdio=no ;;
--enable-liblzo) _liblzo=yes ;;
--disable-liblzo) _liblzo=no ;;
--enable-vorbis) _vorbis=yes ;;
Expand Down Expand Up @@ -5076,6 +5080,49 @@ fi
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"

# freetype depends on iconv
Expand Down Expand Up @@ -7116,6 +7163,8 @@ FONTCONFIG_INC = $_inc_fontconfig
FONTCONFIG_LIB = $_ld_fontconfig
FRIBIDI_INC = $_inc_fribidi
FRIBIDI_LIB = $_ld_fribidi
LIBCDIO_INC = $_inc_libcdio
LIBCDIO_LIB = $_ld_libcdio
LIBLZO_LIB= $_ld_liblzo
MAD_LIB = $_ld_mad
VORBIS_LIB = $_ld_vorbis $_ld_libdv
Expand Down Expand Up @@ -7223,6 +7272,9 @@ $_def_debug
/* Toggles colorized output */
//#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 */
$_def_dvdread
Expand Down
11 changes: 11 additions & 0 deletions libmpdemux/cdd.h
@@ -1,8 +1,14 @@
#ifndef __CDD_H__
#define __CDD_H__

#include "config.h"
#ifndef HAVE_LIBCDIO
#include <cdda_interface.h>
#include <cdda_paranoia.h>
#else
#include <cdio/cdda.h>
#include <cdio/paranoia.h>
#endif

typedef struct {
char cddb_hello[1024];
Expand Down Expand Up @@ -48,8 +54,13 @@ typedef struct {
} cd_info_t;

typedef struct {
#ifndef HAVE_LIBCDIO
cdrom_drive* cd;
cdrom_paranoia* cdp;
#else
cdrom_drive_t* cd;
cdrom_paranoia_t* cdp;
#endif
int sector;
int start_sector;
int end_sector;
Expand Down
54 changes: 51 additions & 3 deletions libmpdemux/cdda.c
Expand Up @@ -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 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) {
struct cdda_params* p = (struct cdda_params*)opts;
int mode = p->paranoia_mode;
int offset = p->toc_offset;
#ifndef HAVE_LIBCDIO
cdrom_drive* cdd = NULL;
#else
cdrom_drive_t* cdd = NULL;
#endif
cdda_priv* priv;
cd_info_t *cd_info,*cddb_info = NULL;
unsigned int audiolen=0;
Expand Down Expand Up @@ -125,9 +129,11 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
}
#endif

#ifndef HAVE_LIBCDIO
if(p->generic_dev)
cdd = cdda_identify_scsi(p->generic_dev,p->device,0,NULL);
else
#endif
#if defined(__NetBSD__)
cdd = cdda_identify_scsi(p->device,p->device,0,NULL);
#else
Expand All @@ -144,7 +150,9 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {

if(p->sector_size) {
cdd->nsectors = p->sector_size;
#ifndef HAVE_LIBCDIO
cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW;
#endif
}

if(cdda_open(cdd) != 0) {
Expand Down Expand Up @@ -218,10 +226,17 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {

if(p->no_skip)
mode |= PARANOIA_MODE_NEVERSKIP;
#ifndef HAVE_LIBCDIO
paranoia_modeset(cdd, mode);

if(p->search_overlap >= 0)
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);
priv->sector = priv->start_sector;
Expand All @@ -235,14 +250,21 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
#endif

st->priv = priv;
#ifndef HAVE_LIBCDIO
st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW;
st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW;
st->type = STREAMTYPE_CDDA;
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->seek = seek;
st->close = close;
st->close = close_cdda;

*file_format = DEMUXER_TYPE_RAWAUDIO;

Expand All @@ -251,7 +273,11 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
return STREAM_OK;
}

#ifndef HAVE_LIBCDIO
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) {
Expand All @@ -263,13 +289,22 @@ static int fill_buffer(stream_t* s, char* buffer, int max_len) {
buf = paranoia_read(p->cdp,cdparanoia_callback);

#ifdef WORDS_BIGENDIAN
#ifndef HAVE_LIBCDIO
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]);
#endif

p->sector++;
#ifndef HAVE_LIBCDIO
s->pos = p->sector*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)) {
s->eof = 1;
Expand All @@ -290,7 +325,11 @@ static int fill_buffer(stream_t* s, char* buffer, int max_len) {
}


#ifndef HAVE_LIBCDIO
return CD_FRAMESIZE_RAW;
#else
return CDIO_CD_FRAMESIZE_RAW;
#endif
}

static int seek(stream_t* s,off_t newpos) {
Expand All @@ -306,8 +345,13 @@ static int seek(stream_t* s,off_t newpos) {
return 0;
}

#ifndef HAVE_LIBCDIO
sec = s->pos/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 );

for(i=0;i<p->cd->tracks;i++){
Expand Down Expand Up @@ -338,14 +382,18 @@ static int seek(stream_t* s,off_t newpos) {
#endif

p->sector = sec;
#ifndef HAVE_LIBCDIO
// 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);
paranoia_seek(p->cdp,sec,SEEK_SET);
return 1;
}

static void close(stream_t* s) {
static void close_cdda(stream_t* s) {
cdda_priv* p = (cdda_priv*)s->priv;
paranoia_free(p->cdp);
cdda_close(p->cd);
Expand Down

0 comments on commit 0538ed8

Please sign in to comment.