[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[52] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2009-12-21 18:42:26
|
Revision: 52 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=52&view=rev Author: nickols_k Date: 2009-12-21 18:42:18 +0000 (Mon, 21 Dec 2009) Log Message: ----------- simplify cdio access and disable os depended stuff Modified Paths: -------------- mplayerxp/configure mplayerxp/libmpdemux/Makefile mplayerxp/libmpdemux/cdd.h mplayerxp/libmpdemux/cdda.c mplayerxp/libmpdemux/s_cdd.c mplayerxp/libmpdemux/s_vcd.c mplayerxp/libmpdemux/stream.c Removed Paths: ------------- mplayerxp/libmpdemux/vcd_read.h mplayerxp/libmpdemux/vcd_read_fbsd.h mplayerxp/libmpdemux/vcd_read_nbsd.h Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/configure 2009-12-21 18:42:18 UTC (rev 52) @@ -80,7 +80,6 @@ --disable-libcss Disable libcss support [autodetect] --disable-libdvdread Disable libdvdread support [autodetect] --disable-libdvdnav Disable libdvdnav support [autodetect] - --disable-vcd Disable VCD support [autodetect] Video: --enable-dga build with DGA1 or DGA2 support [autodetect] --enable-vesa build with VESA support [autodetect] @@ -185,7 +184,6 @@ sdl sdl_image libvcd - vcd tv_v4l x11 xdpms @@ -699,10 +697,15 @@ enabled sdl && aomodules="sdl $aomodules" || noaomodules="sdl $noaomodules" enabled sdl && vomodules="sdl $vomodules" || novomodules="sdl $novomodules" -enabled libcdio && require2 libcdio "cdio/paranoia.h" cdio_paranoia_read -lcdio_paranoia +enabled libcdio && require2 libcdio "cdio/cdio.h" cdio_read_mode2_sectors -lcdio print_config HAVE_ mp_config.h mp_config.mak libcdio -enabled libcdio && inputmodules="cdda $inputmodules" || noinputmodules="cdda $noinputmodules" +enabled libcdio && inputmodules="vcd $inputmodules" || noinputmodules="vcd $noinputmodules" + +enabled libcdio && require2 libcdio_cdda "cdio/cdda.h" cdio_cddap_read -lcdio_cdda +print_config HAVE_ mp_config.h mp_config.mak libcdio_cdda +enabled libcdio_cdda && inputmodules="cdda $inputmodules" || noinputmodules="cdda $noinputmodules" + ######### # AUDIO # ######### @@ -771,10 +774,6 @@ enabled fastmemcpy && x86 || disable fastmemcpy print_config USE_ mp_config.h mp_config.mak fastmemcpy -test linux -o bsdos -o freebsd -o sunos && enable vcd || disable vcd -print_config HAVE_ mp_config.h mp_config.mak vcd -enabled vcd && inputmodules="vcd $inputmodules" || noinputmodules="vcd $noinputmodules" - enabled tv && print_config USE_ mp_config.h mp_config.mak tv enabled tv && inputmodules="tv $inputmodules" || noinputmodules="tv $noinputmodules" Modified: mplayerxp/libmpdemux/Makefile =================================================================== --- mplayerxp/libmpdemux/Makefile 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/Makefile 2009-12-21 18:42:18 UTC (rev 52) @@ -7,7 +7,7 @@ DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done SRCS = s_file.c s_ffmpeg.c -ifeq ($(HAVE_LIBCDIO),yes) +ifeq ($(HAVE_LIBCDIO_CDDA),yes) SRCS += s_cdd.c cdda.c ifeq ($(HAVE_STREAMING),yes) SRCS += cddb.c @@ -26,7 +26,7 @@ ifeq ($(USE_LIBVCD),yes) SRCS += s_vcdnav.c endif -ifeq ($(HAVE_VCD),yes) +ifeq ($(HAVE_LIBCDIO),yes) SRCS += s_vcd.c endif SRCS += cache2.c dvdauth.c stream.c tvi_dummy.c tvi_v4l.c Modified: mplayerxp/libmpdemux/cdd.h =================================================================== --- mplayerxp/libmpdemux/cdd.h 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/cdd.h 2009-12-21 18:42:18 UTC (rev 52) @@ -2,7 +2,6 @@ #define __CDD_H__ #include <cdio/cdda.h> -#include <cdio/paranoia.h> typedef struct { char cddb_hello[1024]; @@ -49,20 +48,19 @@ typedef struct my_track_s { int play; - unsigned long start_sector; - unsigned long end_sector; + lsn_t start_sector; + lsn_t end_sector; }my_track_t; typedef struct { cdrom_drive_t* cd; - cdrom_paranoia_t* cdp; my_track_t tracks[256]; /* hope that's enough */ unsigned min; unsigned sec; unsigned msec; - unsigned long sector; - unsigned long start_sector; - unsigned long end_sector; + lsn_t sector; + lsn_t start_sector; + lsn_t end_sector; } cdda_priv; cd_info_t* __FASTCALL__ cd_info_new(); Modified: mplayerxp/libmpdemux/cdda.c =================================================================== --- mplayerxp/libmpdemux/cdda.c 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/cdda.c 2009-12-21 18:42:18 UTC (rev 52) @@ -11,13 +11,11 @@ #include "cdd.h" #include "demux_msg.h" static int speed = -1; -static int paranoia_mode = 1; static int search_overlap = -1; static int no_skip = 0; static const config_t cdda_opts[] = { { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, NULL }, - { "paranoia", ¶noia_mode, CONF_TYPE_INT,CONF_RANGE, 0, 2, NULL }, { "overlap", &search_overlap, CONF_TYPE_INT, CONF_RANGE,0,75, NULL }, { "noskip", &no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL }, { "skip", &no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL }, @@ -72,8 +70,6 @@ } int __FASTCALL__ open_cdda(stream_t *st,const char* dev,const char* arg) { - lsn_t lsn; - int mode = paranoia_mode; unsigned cd_tracks; cdda_priv* priv; unsigned int audiolen=0; @@ -128,47 +124,20 @@ if(speed) cdio_cddap_speed_set(priv->cd,speed); - priv->cdp = cdio_paranoia_init(priv->cd); - if(priv->cdp == NULL) { - cdio_cddap_close(priv->cd); - free(priv); - return 0; - } - - mode = PARANOIA_MODE_FULL; - if(mode == 0) - mode = PARANOIA_MODE_DISABLE; - else if(mode == 1) - mode = PARANOIA_MODE_OVERLAP; - - if(no_skip) - mode |= PARANOIA_MODE_NEVERSKIP; - - cdio_paranoia_modeset(priv->cdp,mode); - if(search_overlap >= 0) - cdio_paranoia_overlapset(priv->cdp,search_overlap); - - lsn=cdio_paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET); - MSG_DBG2("[CDDA] %ld=cdio_paranoia_seek(%p,%ld,SEEK_SET)\n",lsn,priv->cdp,priv->start_sector); priv->sector = priv->start_sector; st->type = STREAMTYPE_SEEKABLE|STREAMTYPE_RAWAUDIO; st->priv = priv; - st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW; - st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW; + st->start_pos = priv->start_sector*CDIO_CD_FRAMESIZE_RAW; + st->end_pos = priv->end_sector*CDIO_CD_FRAMESIZE_RAW; return 1; } -static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) { - UNUSED(inpos); - UNUSED(function); -} - -static unsigned long map_sector(cdda_priv*p,unsigned long sector,track_t *tr) +static lsn_t map_sector(cdda_priv*p,lsn_t sector,track_t *tr) { unsigned i,j; - unsigned long cd_track=sector; + lsn_t cd_track=sector; for(i=0;i<256;i++){ if(p->tracks[i].play && p->tracks[i].end_sector==sector-1) { cd_track=0; @@ -184,8 +153,8 @@ /* return physical sector address */ static unsigned long psa(cdda_priv*p,unsigned long sector) { - unsigned i,j; - unsigned long got_sectors=0,track_len; + unsigned i; + unsigned long got_sectors=p->start_sector,track_len; for(i=0;i<256;i++){ if(p->tracks[i].play) { track_len=p->tracks[i].end_sector-p->tracks[i].start_sector; @@ -198,35 +167,30 @@ int __FASTCALL__ read_cdda(stream_t* s,char *buf,track_t *tr) { cdda_priv* p = (cdda_priv*)s->priv; - unsigned long cd_track; - int16_t * _buf; track_t i=255; *tr=255; - _buf = cdio_paranoia_read(p->cdp,cdparanoia_callback); - + if(cdio_cddap_read(p->cd, buf, p->sector, 1)==0) { + MSG_ERR("[CD-DA]: read error occured\n"); + return -1; /* EOF */ + } p->sector++; - memcpy(buf,_buf,CD_FRAMESIZE_RAW); + if(p->sector == p->end_sector) return -1; /* EOF */ - if(p->sector == p->end_sector) return -1; - - cd_track=map_sector(p,p->sector,&i); - if(!cd_track) return -1; + p->sector=map_sector(p,p->sector,&i); + if(!p->sector) return -1; *tr=i+1; - MSG_V("Track %d, sector=%d\n", *tr, cd_track); - if(cd_track!=p->sector) { cdio_paranoia_seek(p->cdp,cd_track,SEEK_SET); p->sector=cd_track; } - return CD_FRAMESIZE_RAW; + MSG_V("Track %d, sector=%d\n", *tr, p->sector); + return CDIO_CD_FRAMESIZE_RAW; } void __FASTCALL__ seek_cdda(stream_t* s,off_t pos,track_t *tr) { cdda_priv* p = (cdda_priv*)s->priv; long sec; - long current_track=0, seeked_track=0; - unsigned i; - lsn_t lsn; + long seeked_track=0; track_t j=255; - sec = pos/CD_FRAMESIZE_RAW; + sec = pos/CDIO_CD_FRAMESIZE_RAW; MSG_DBG2("[CDDA] prepare seek to %ld\n",sec); seeked_track=sec; *tr=255; @@ -234,20 +198,16 @@ seeked_track = map_sector(p,seeked_track,&j); if(seeked_track) *tr=j+1; } - - lsn=cdio_paranoia_seek(p->cdp,seeked_track,SEEK_SET); - MSG_DBG2("[CDDA] %ld=cdio_paranoia_seek(%p,%ld,SEEK_SET)\n",lsn,p->cdp,seeked_track); p->sector=seeked_track; } off_t __FASTCALL__ tell_cdda(stream_t* s) { cdda_priv* p = (cdda_priv*)s->priv; - return p->sector*CD_FRAMESIZE_RAW; + return p->sector*CDIO_CD_FRAMESIZE_RAW; } void __FASTCALL__ close_cdda(stream_t* s) { cdda_priv* p = (cdda_priv*)s->priv; - cdio_paranoia_free(p->cdp); cdio_cddap_close(p->cd); free(p); } Modified: mplayerxp/libmpdemux/s_cdd.c =================================================================== --- mplayerxp/libmpdemux/s_cdd.c 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/s_cdd.c 2009-12-21 18:42:18 UTC (rev 52) @@ -107,7 +107,7 @@ const stream_driver_t cdda_stream= { "cdda://", - "reads multimedia stream directly from Compact Disc Digital Audio system, or CD-DA", + "reads multimedia stream directly from Digital Audio Compact Disc [CD-DA]", _cdda_open, cdd_read, cdd_seek, @@ -119,7 +119,7 @@ const stream_driver_t cddb_stream= { "cddb://", - "reads multimedia stream from Compact Disc Database or CD-DB", + "reads multimedia stream from CD-DA but tracks names from CDDB servers", _cddb_open, cdd_read, cdd_seek, Modified: mplayerxp/libmpdemux/s_vcd.c =================================================================== --- mplayerxp/libmpdemux/s_vcd.c 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/s_vcd.c 2009-12-21 18:42:18 UTC (rev 52) @@ -2,48 +2,32 @@ s_vcd - VCD's stream interface */ #include "../mp_config.h" -#ifdef HAVE_VCD +#ifdef HAVE_LIBCDIO +#include <unistd.h> +#include <fcntl.h> #include <stdlib.h> #include <string.h> #include <stdio.h> -#include "stream.h" +#include <cdio/cdio.h> - -#ifdef __FreeBSD__ -#include <sys/cdrio.h> -#endif -#include <sys/ioctl.h> - -#include <fcntl.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef __FreeBSD__ -#include "vcd_read_fbsd.h" -#elif defined(__NetBSD__) -#include "vcd_read_nbsd.h" -#else -#include "vcd_read.h" -#endif +#include "stream.h" #include "help_mp.h" #include "mrl.h" #include "demux_msg.h" typedef struct vcd_priv_s { + CdIo_t *cd; off_t spos; unsigned ssect,esect; }vcd_priv_t; static int __FASTCALL__ _vcd_open(stream_t *stream,const char *filename,unsigned flags) { - int ret,ret2; int vcd_track; vcd_priv_t *priv; const char *param; - char *device; -#ifdef __FreeBSD__ - int bsize=VCD_SECTOR_SIZE; -#endif + char *dev,*device=NULL; UNUSED(flags); /* originally was vcd:// but playtree parser replaced it */ if(strcmp(filename,"help") == 0) @@ -53,46 +37,38 @@ } param=mrl_parse_line(filename,NULL,NULL,&device,NULL); vcd_track=atoi(param); - if(!device) device=DEFAULT_CDROM_DEVICE; - stream->fd=open(device,O_RDONLY); + if(!device) dev=DEFAULT_CDROM_DEVICE; + else dev=device; + priv=stream->priv=malloc(sizeof(vcd_priv_t)); + cdio_init(); + priv->cd=cdio_open(dev,DRIVER_UNKNOWN); if(device) free(device); - if(stream->fd<0) + if(!priv->cd) { MSG_ERR(MSGTR_CdDevNotfound,device); return 0; } - vcd_read_toc(stream->fd); - ret2=vcd_get_track_end(stream->fd,vcd_track); - if(ret2<0){ MSG_ERR(MSGTR_ErrTrackSelect " (get)\n");return 0;} - ret=vcd_seek_to_track(stream->fd,vcd_track); - if(ret<0){ MSG_ERR(MSGTR_ErrTrackSelect " (seek)\n");return 0;} - priv=stream->priv=malloc(sizeof(vcd_priv_t)); - vcd_read(stream->fd,NULL); - vcd_dec_msf(); - priv->ssect=vcd_get_msf(); - priv->esect=ret2/VCD_SECTOR_DATA; - ret=VCD_SECTOR_DATA*priv->ssect; - MSG_V("VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); -#ifdef __FreeBSD__ - if (ioctl (stream->f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { - MSG_ERR ("Error in CDRIOCSETBLOCKSIZE"); - } -#endif + vcd_track=cdio_get_num_tracks(priv->cd); + MSG_V("CD contains: %d tracks\n",vcd_track); + priv->ssect=cdio_get_track_pregap_lsn(priv->cd,2); + priv->esect=cdio_get_track_pregap_lsn(priv->cd,vcd_track)+cdio_get_track_sec_count(priv->cd,vcd_track); + stream->type = STREAMTYPE_SEEKABLE|STREAMTYPE_PROGRAM; stream->sector_size=VCD_SECTOR_SIZE; - stream->start_pos=ret; - stream->end_pos=ret2; - ((vcd_priv_t *)stream->priv)->spos=ret; + stream->start_pos=priv->ssect*VCD_SECTOR_DATA; + stream->end_pos=priv->esect*VCD_SECTOR_DATA; + ((vcd_priv_t *)stream->priv)->spos=stream->start_pos; return 1; } static int __FASTCALL__ _vcd_read(stream_t *stream,stream_packet_t*sp) { vcd_priv_t *p=stream->priv; + ssize_t len; sp->type=0; - sp->len = vcd_read(stream->fd,sp->buf); - p->spos += sp->len; - return sp->len; + len=cdio_read(p->cd,sp->buf,sp->len); + p->spos += len; + return len; } static off_t __FASTCALL__ _vcd_seek(stream_t *stream,off_t pos) @@ -104,7 +80,7 @@ newpos=pos/VCD_SECTOR_DATA; if(newpos<p->ssect) newpos=p->ssect; if(newpos>p->esect) newpos=p->esect; - vcd_set_msf(newpos); + newpos=cdio_lseek(p->cd,newpos*VCD_SECTOR_DATA,SEEK_SET); p->spos=newpos*VCD_SECTOR_DATA; return p->spos; } @@ -117,8 +93,9 @@ static void __FASTCALL__ _vcd_close(stream_t*stream) { + vcd_priv_t *p=stream->priv; + cdio_destroy(p->cd); free(stream->priv); - close(stream->fd); } static int __FASTCALL__ _vcd_ctrl(stream_t *s,unsigned cmd,void *args) { UNUSED(s); Modified: mplayerxp/libmpdemux/stream.c =================================================================== --- mplayerxp/libmpdemux/stream.c 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/stream.c 2009-12-21 18:42:18 UTC (rev 52) @@ -22,7 +22,7 @@ #define min(a,b) ((a)<(b)?(a):(b)) #endif -#ifdef HAVE_LIBCDIO +#ifdef HAVE_LIBCDIO_CDDA extern const stream_driver_t cdda_stream; extern const stream_driver_t cddb_stream; #endif @@ -42,7 +42,7 @@ #ifdef USE_OSS_AUDIO extern const stream_driver_t oss_stream; #endif -#ifdef HAVE_VCD +#ifdef HAVE_LIBCDIO extern const stream_driver_t vcd_stream; #endif #ifdef USE_LIBVCD @@ -54,7 +54,7 @@ static const stream_driver_t *sdrivers[] = { -#ifdef HAVE_LIBCDIO +#ifdef HAVE_LIBCDIO_CDDA &cdda_stream, #ifdef HAVE_STREAMING &cddb_stream, @@ -69,7 +69,7 @@ #ifdef USE_TV &tv_stream, #endif -#ifdef HAVE_VCD +#ifdef HAVE_LIBCDIO &vcd_stream, #endif #ifdef USE_LIBVCD Deleted: mplayerxp/libmpdemux/vcd_read.h =================================================================== --- mplayerxp/libmpdemux/vcd_read.h 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/vcd_read.h 2009-12-21 18:42:18 UTC (rev 52) @@ -1,255 +0,0 @@ -//=================== VideoCD ========================== -#if defined(linux) || defined(sun) || defined(__bsdi__) - -#if defined(linux) -#include <linux/cdrom.h> -#elif defined(sun) -#include <sys/cdio.h> -static int sun_vcd_read(int, int*); -#elif defined(__bsdi__) -#include <dvd.h> -#endif - - -static struct cdrom_tocentry vcd_entry; - -static inline void vcd_set_msf(unsigned int sect){ - vcd_entry.cdte_addr.msf.frame=sect%75; - sect=sect/75; - vcd_entry.cdte_addr.msf.second=sect%60; - sect=sect/60; - vcd_entry.cdte_addr.msf.minute=sect; -} - -static inline unsigned int vcd_get_msf(){ - return vcd_entry.cdte_addr.msf.frame + - (vcd_entry.cdte_addr.msf.second+ - vcd_entry.cdte_addr.msf.minute*60)*75; -} - -static int vcd_seek_to_track(int fd,int track){ - vcd_entry.cdte_format = CDROM_MSF; - vcd_entry.cdte_track = track; - if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) { - perror("ioctl dif1"); - return -1; - } - return VCD_SECTOR_DATA*vcd_get_msf(); -} - -static int vcd_get_track_end(int fd,int track){ - struct cdrom_tochdr tochdr; - if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) - { perror("read CDROM toc header: "); return -1; } - vcd_entry.cdte_format = CDROM_MSF; - vcd_entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT; - if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) { - perror("ioctl dif2"); - return -1; - } - return VCD_SECTOR_DATA*vcd_get_msf(); -} - -static void vcd_read_toc(int fd){ - struct cdrom_tochdr tochdr; - int i; - if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) - { perror("read CDROM toc header: "); return; } - for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 ; i++){ - struct cdrom_tocentry tocentry; - - tocentry.cdte_track = i; - tocentry.cdte_format = CDROM_MSF; - - if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) - { perror("read CDROM toc entry: "); return; } - - MSG_V("track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n", - (int)tocentry.cdte_track, - (int)tocentry.cdte_adr, - (int)tocentry.cdte_ctrl, - (int)tocentry.cdte_format, - (int)tocentry.cdte_addr.msf.minute, - (int)tocentry.cdte_addr.msf.second, - (int)tocentry.cdte_addr.msf.frame, - (int)tocentry.cdte_datamode - ); - } -} - -static unsigned char vcd_buf[VCD_SECTOR_SIZE]; - -static void vcd_inc_msf(void) -{ - vcd_entry.cdte_addr.msf.frame++; - if (vcd_entry.cdte_addr.msf.frame==75){ - vcd_entry.cdte_addr.msf.frame=0; - vcd_entry.cdte_addr.msf.second++; - if (vcd_entry.cdte_addr.msf.second==60){ - vcd_entry.cdte_addr.msf.second=0; - vcd_entry.cdte_addr.msf.minute++; - } - } -} - -static void vcd_dec_msf(void) -{ - vcd_set_msf(vcd_get_msf()-1); -} - -static int vcd_read(int fd,char *mem){ -#if defined(linux) || defined(__bsdi__) - do { - memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf)); - if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF? - /* Check header ID for a padding sector and simply discard - these. It is alleged that VCD's put these in to keep the - bitrate constant. - */ - MSG_DBG3("MSF=%i SUBHEADER: (0) %02X %02X %02X %02X %02X %02X %02X %02X (8) %02X %02X %02X %02X %02X %02X %02X %02X (16) %02X %02X %02X %02X %02X %02X %02X %02X\n" - ,vcd_entry.cdte_addr.msf - ,vcd_buf[0] - ,vcd_buf[1] - ,vcd_buf[2] - ,vcd_buf[3] - ,vcd_buf[4] - ,vcd_buf[5] - ,vcd_buf[6] - ,vcd_buf[7] - ,vcd_buf[8] - ,vcd_buf[9] - ,vcd_buf[10] - ,vcd_buf[11] - ,vcd_buf[12] - ,vcd_buf[13] - ,vcd_buf[14] - ,vcd_buf[15] - ,vcd_buf[16] - ,vcd_buf[17] - ,vcd_buf[18] - ,vcd_buf[19] - ,vcd_buf[20] - ,vcd_buf[21] - ,vcd_buf[22] - ,vcd_buf[23]); - MSG_DBG3("DATA: %02X %02X %02X %02X %02X %02X %02X %02X\n" - ,vcd_buf[VCD_SECTOR_OFFS+0] - ,vcd_buf[VCD_SECTOR_OFFS+1] - ,vcd_buf[VCD_SECTOR_OFFS+2] - ,vcd_buf[VCD_SECTOR_OFFS+3] - ,vcd_buf[VCD_SECTOR_OFFS+4] - ,vcd_buf[VCD_SECTOR_OFFS+5] - ,vcd_buf[VCD_SECTOR_OFFS+6] - ,vcd_buf[VCD_SECTOR_OFFS+7]); - vcd_inc_msf(); - }while((vcd_buf[18]&~0x01)==0x60); - if(mem) memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); -#elif defined(sun) - { - int offset; - if (sun_vcd_read(fd, &offset) <= 0) return 0; - if(mem) memcpy(mem,&vcd_buf[offset],VCD_SECTOR_DATA); - } - vcd_inc_msf(); -#endif - return VCD_SECTOR_DATA; -} - - -#ifdef sun -#include <sys/scsi/generic/commands.h> -#include <sys/scsi/impl/uscsi.h> - -#define SUN_XAREAD 1 /*fails on atapi drives*/ -#define SUN_MODE2READ 2 /*fails on atapi drives*/ -#define SUN_SCSIREAD 3 -#define SUN_VCDREAD SUN_SCSIREAD - -static int sun_vcd_read(int fd, int *offset) -{ -#if SUN_VCDREAD == SUN_XAREAD - struct cdrom_cdxa cdxa; - cdxa.cdxa_addr = vcd_get_msf(); - cdxa.cdxa_length = 1; - cdxa.cdxa_data = vcd_buf; - cdxa.cdxa_format = CDROM_XA_SECTOR_DATA; - - if(ioctl(fd,CDROMCDXA,&cdxa)==-1) { - perror("CDROMCDXA"); - return 0; - } - *offset = 0; -#elif SUN_VCDREAD == SUN_MODE2READ - struct cdrom_read cdread; - cdread.cdread_lba = 4*vcd_get_msf(); - cdread.cdread_bufaddr = vcd_buf; - cdread.cdread_buflen = 2336; - - if(ioctl(fd,CDROMREADMODE2,&cdread)==-1) { - perror("CDROMREADMODE2"); - return 0; - } - *offset = 8; -#elif SUN_VCDREAD == SUN_SCSIREAD - struct uscsi_cmd sc; - union scsi_cdb cdb; - int lba = vcd_get_msf(); - int blocks = 1; - int sector_type; - int sync, header_code, user_data, edc_ecc, error_field; - int sub_channel; - - /* sector_type = 3; *//* mode2 */ - sector_type = 5; /* mode2/form2 */ - sync = 0; - header_code = 0; - user_data = 1; - edc_ecc = 0; - error_field = 0; - sub_channel = 0; - - memset(&cdb, 0, sizeof(cdb)); - memset(&sc, 0, sizeof(sc)); - cdb.scc_cmd = 0xBE; - cdb.cdb_opaque[1] = (sector_type) << 2; - cdb.cdb_opaque[2] = (lba >> 24) & 0xff; - cdb.cdb_opaque[3] = (lba >> 16) & 0xff; - cdb.cdb_opaque[4] = (lba >> 8) & 0xff; - cdb.cdb_opaque[5] = lba & 0xff; - cdb.cdb_opaque[6] = (blocks >> 16) & 0xff; - cdb.cdb_opaque[7] = (blocks >> 8) & 0xff; - cdb.cdb_opaque[8] = blocks & 0xff; - cdb.cdb_opaque[9] = (sync << 7) | - (header_code << 5) | - (user_data << 4) | - (edc_ecc << 3) | - (error_field << 1); - cdb.cdb_opaque[10] = sub_channel; - - sc.uscsi_cdb = (caddr_t)&cdb; - sc.uscsi_cdblen = 12; - sc.uscsi_bufaddr = vcd_buf; - sc.uscsi_buflen = 2336; - sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ; - sc.uscsi_timeout = 20; - if (ioctl(fd, USCSICMD, &sc)) { - MSG_ERR("USCSICMD: READ CD"); - return -1; - } - if (sc.uscsi_status) { - MSG_ERR( "scsi command failed with status %d\n", sc.uscsi_status); - return -1; - } - *offset = 0; - return 1; -#else -#error SUN_VCDREAD -#endif -} -#endif /*sun*/ - -#else /* linux || sun || __bsdi__ */ - -#error vcd is not yet supported on this arch... - -#endif Deleted: mplayerxp/libmpdemux/vcd_read_fbsd.h =================================================================== --- mplayerxp/libmpdemux/vcd_read_fbsd.h 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/vcd_read_fbsd.h 2009-12-21 18:42:18 UTC (rev 52) @@ -1,97 +0,0 @@ -#include <sys/cdio.h> -#include <sys/cdrio.h> - -//=================== VideoCD ========================== -#define CDROM_LEADOUT 0xAA - -typedef struct { - uint8_t sync [12]; - uint8_t header [4]; - uint8_t subheader [8]; - uint8_t data [2324]; - uint8_t spare [4]; -} cdsector_t; - -static cdsector_t vcd_buf; -static struct ioc_read_toc_single_entry vcd_entry; - -static inline void vcd_set_msf(unsigned int sect){ - vcd_entry.entry.addr.msf.frame=sect%75; - sect=sect/75; - vcd_entry.entry.addr.msf.second=sect%60; - sect=sect/60; - vcd_entry.entry.addr.msf.minute=sect; -} - -static inline unsigned int vcd_get_msf(){ - return vcd_entry.entry.addr.msf.frame + - (vcd_entry.entry.addr.msf.second+ - vcd_entry.entry.addr.msf.minute*60)*75; -} - -int vcd_seek_to_track(int fd,int track){ - vcd_entry.address_format = CD_MSF_FORMAT; - vcd_entry.track = track; - if (ioctl(fd, CDIOREADTOCENTRY, &vcd_entry)) { - perror("ioctl dif1"); - return -1; - } - return VCD_SECTOR_DATA*vcd_get_msf(); -} - -int vcd_get_track_end(int fd,int track){ - struct ioc_toc_header tochdr; - if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1) - { perror("read CDROM toc header: "); return -1; } - vcd_entry.address_format = CD_MSF_FORMAT; - vcd_entry.track = track<tochdr.ending_track?(track+1):CDROM_LEADOUT; - if (ioctl(fd, CDIOREADTOCENTRY, &vcd_entry)) { - perror("ioctl dif2"); - return -1; - } - return VCD_SECTOR_DATA*vcd_get_msf(); -} - -void vcd_read_toc(int fd){ - struct ioc_toc_header tochdr; - int i; - if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1) - { perror("read CDROM toc header: "); return; } - for (i=tochdr.starting_track ; i<=tochdr.ending_track ; i++){ - struct ioc_read_toc_single_entry tocentry; - - tocentry.track = i; - tocentry.address_format = CD_MSF_FORMAT; - - if (ioctl(fd,CDIOREADTOCENTRY,&tocentry)==-1) - { MSG_ERR("read CDROM toc entry: "); return; } - - MSG_V("track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", - (int)tocentry.track, - (int)tocentry.entry.addr_type, - (int)tocentry.entry.control, - (int)tocentry.address_format, - (int)tocentry.entry.addr.msf.minute, - (int)tocentry.entry.addr.msf.second, - (int)tocentry.entry.addr.msf.frame - ); - } -} - -static int vcd_read(int fd,char *mem){ - - if (pread(fd,&vcd_buf,VCD_SECTOR_SIZE,vcd_get_msf()*VCD_SECTOR_SIZE) - != VCD_SECTOR_SIZE) return 0; // EOF? - - vcd_entry.entry.addr.msf.frame++; - if (vcd_entry.entry.addr.msf.frame==75){ - vcd_entry.entry.addr.msf.frame=0; - vcd_entry.entry.addr.msf.second++; - if (vcd_entry.entry.addr.msf.second==60){ - vcd_entry.entry.addr.msf.second=0; - vcd_entry.entry.addr.msf.minute++; - } - } - memcpy(mem,vcd_buf.data,VCD_SECTOR_DATA); - return VCD_SECTOR_DATA; -} Deleted: mplayerxp/libmpdemux/vcd_read_nbsd.h =================================================================== --- mplayerxp/libmpdemux/vcd_read_nbsd.h 2009-12-19 19:15:24 UTC (rev 51) +++ mplayerxp/libmpdemux/vcd_read_nbsd.h 2009-12-21 18:42:18 UTC (rev 52) @@ -1,164 +0,0 @@ - -#include <sys/types.h> -#include <sys/inttypes.h> -#include <sys/cdio.h> -#include <sys/scsiio.h> - -#define CDROM_LEADOUT 0xAA - -static struct ioc_read_toc_entry vcd_entry; -static struct cd_toc_entry vcd_entry_data; -static char vcd_buf[VCD_SECTOR_SIZE]; - -static inline void -vcd_set_msf(unsigned int sect) -{ - unsigned int s = sect; - vcd_entry_data.addr.msf.frame = sect % 75; - sect = sect / 75; - vcd_entry_data.addr.msf.second = sect % 60; - sect = sect / 60; - vcd_entry_data.addr.msf.minute = sect; -} - -static inline void -vcd_inc_msf(void) -{ - vcd_entry_data.addr.msf.frame++; - if (vcd_entry_data.addr.msf.frame==75){ - vcd_entry_data.addr.msf.frame=0; - vcd_entry_data.addr.msf.second++; - if (vcd_entry_data.addr.msf.second==60){ - vcd_entry_data.addr.msf.second=0; - vcd_entry_data.addr.msf.minute++; - } - } -} - -static inline unsigned int -vcd_get_msf() -{ - return vcd_entry_data.addr.msf.frame + - (vcd_entry_data.addr.msf.second + - vcd_entry_data.addr.msf.minute * 60) * 75; -} - -int -vcd_seek_to_track(int fd, int track) -{ - vcd_entry.address_format = CD_MSF_FORMAT; - vcd_entry.starting_track = track; - vcd_entry.data_len = sizeof(struct cd_toc_entry); - vcd_entry.data = &vcd_entry_data; - if (ioctl(fd, CDIOREADTOCENTRIES, &vcd_entry)) { - perror("ioctl dif1"); - return -1; - } - return VCD_SECTOR_DATA * vcd_get_msf(); -} - -int -vcd_get_track_end(int fd, int track) -{ - struct ioc_toc_header tochdr; - if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) { - perror("read CDROM toc header: "); - return -1; - } - vcd_entry.address_format = CD_MSF_FORMAT; - vcd_entry.starting_track = track < tochdr.ending_track ? (track + 1) : CDROM_LEADOUT; - vcd_entry.data_len = sizeof(struct cd_toc_entry); - vcd_entry.data = &vcd_entry_data; - if (ioctl(fd, CDIOREADTOCENTRYS, &vcd_entry)) { - perror("ioctl dif2"); - return -1; - } - return VCD_SECTOR_DATA * vcd_get_msf(); -} - -void -vcd_read_toc(int fd) -{ - struct ioc_toc_header tochdr; - int i; - if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) { - perror("read CDROM toc header: "); - return; - } - for (i = tochdr.starting_track; i <= tochdr.ending_track; i++) { - struct ioc_read_toc_entry tocentry; - struct cd_toc_entry tocentry_data; - - tocentry.starting_track = i; - tocentry.address_format = CD_MSF_FORMAT; - tocentry.data_len = sizeof(struct cd_toc_entry); - tocentry.data = &tocentry_data; - - if (ioctl(fd, CDIOREADTOCENTRYS, &tocentry) == -1) { - MSG_ERR("read CDROM toc entry: "); - return; - } - MSG_V("track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n", - (int) tocentry.starting_track, - (int) tocentry.data->addr_type, - (int) tocentry.data->control, - (int) tocentry.address_format, - (int) tocentry.data->addr.msf.minute, - (int) tocentry.data->addr.msf.second, - (int) tocentry.data->addr.msf.frame - ); - } -} - -static int -vcd_read(int fd, char *mem) -{ - struct scsireq sc; - int lba = vcd_get_msf(); - int blocks; - int sector_type; - int sync, header_code, user_data, edc_ecc, error_field; - int sub_channel; - int rc; - - blocks = 1; - sector_type = 5; /* mode2/form2 */ - sync = 0; - header_code = 0; - user_data = 1; - edc_ecc = 0; - error_field = 0; - sub_channel = 0; - - memset(&sc, 0, sizeof(sc)); - sc.cmd[0] = 0xBE; - sc.cmd[1] = (sector_type) << 2; - sc.cmd[2] = (lba >> 24) & 0xff; - sc.cmd[3] = (lba >> 16) & 0xff; - sc.cmd[4] = (lba >> 8) & 0xff; - sc.cmd[5] = lba & 0xff; - sc.cmd[6] = (blocks >> 16) & 0xff; - sc.cmd[7] = (blocks >> 8) & 0xff; - sc.cmd[8] = blocks & 0xff; - sc.cmd[9] = (sync << 7) | (header_code << 5) | (user_data << 4) | - (edc_ecc << 3) | (error_field << 1); - sc.cmd[10] = sub_channel; - sc.cmdlen = 12; - sc.databuf = (caddr_t) mem; - sc.datalen = 2328; - sc.senselen = sizeof(sc.sense); - sc.flags = SCCMD_READ; - sc.timeout = 10000; - rc = ioctl(fd, SCIOCCOMMAND, &sc); - if (rc == -1) { - perror("SCIOCCOMMAND"); - return -1; - } - if (sc.retsts || sc.error) { - fprintf(stderr, "scsi command failed: status %d error %d\n", sc.retsts, - sc.error); - return -1; - } - vcd_inc_msf(); - return VCD_SECTOR_DATA; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |