[Mplayer-cvslog] CVS: main/libmpdemux vcd_read.h,1.12,1.13 vcd_read_nbsd.h,1.3,1.4 vcd_read_fbsd.h,1.5,1.6
Alban Bedel CVS
albeu at mplayerhq.hu
Wed Apr 9 09:34:23 CEST 2003
- Previous message: [Mplayer-cvslog] CVS: main/libmpdemux stream_vcd.c,NONE,1.1 open.c,1.77,1.78 stream.h,1.62,1.63 stream.c,1.61,1.62 Makefile,1.56,1.57
- Next message: [Mplayer-cvslog] CVS: main subreader.c,1.102,1.103
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv5776/libmpdemux
Modified Files:
vcd_read.h vcd_read_nbsd.h vcd_read_fbsd.h
Log Message:
Make the vcd API fully reentrant.
Move perror and co to mp_msg.
Hope there is no big 10L as i couldn't test sun,fbsd and nbsd :(
Index: vcd_read.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/vcd_read.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- vcd_read.h 15 Sep 2002 18:48:16 -0000 1.12
+++ vcd_read.h 9 Apr 2003 07:33:59 -0000 1.13
@@ -1,68 +1,80 @@
//=================== VideoCD ==========================
#if defined(linux) || defined(sun) || defined(__bsdi__)
+typedef struct mp_vcd_priv_st mp_vcd_priv_t;
+
#if defined(linux)
#include <linux/cdrom.h>
#elif defined(sun)
#include <sys/cdio.h>
-static int sun_vcd_read(int, int*);
+static int sun_vcd_read(mp_vcd_priv_t*, int*);
#elif defined(__bsdi__)
#include <dvd.h>
#endif
+struct mp_vcd_priv_st {
+ int fd;
+ struct cdrom_tocentry entry;
+ char buf[VCD_SECTOR_SIZE];
+};
-static struct cdrom_tocentry vcd_entry;
-
-static inline void vcd_set_msf(unsigned int sect){
- vcd_entry.cdte_addr.msf.frame=sect%75;
+static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){
+ vcd->entry.cdte_addr.msf.frame=sect%75;
sect=sect/75;
- vcd_entry.cdte_addr.msf.second=sect%60;
+ vcd->entry.cdte_addr.msf.second=sect%60;
sect=sect/60;
- vcd_entry.cdte_addr.msf.minute=sect;
+ 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 inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){
+ return vcd->entry.cdte_addr.msf.frame +
+ (vcd->entry.cdte_addr.msf.second+
+ vcd->entry.cdte_addr.msf.minute*60)*75;
}
-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");
+int vcd_seek_to_track(mp_vcd_priv_t* vcd,int track){
+ vcd->entry.cdte_format = CDROM_MSF;
+ vcd->entry.cdte_track = track;
+ if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA*vcd_get_msf();
+ return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-int vcd_get_track_end(int fd,int track){
+int vcd_get_track_end(mp_vcd_priv_t* vcd,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");
+ if (ioctl(vcd->fd,CDROMREADTOCHDR,&tochdr)==-1) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ return -1;
+ }
+ vcd->entry.cdte_format = CDROM_MSF;
+ vcd->entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
+ if (ioctl(vcd->fd, CDROMREADTOCENTRY, &vcd->entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA*vcd_get_msf();
+ return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-void vcd_read_toc(int fd){
+mp_vcd_priv_t* vcd_read_toc(int fd){
struct cdrom_tochdr tochdr;
+ mp_vcd_priv_t* vcd;
int i;
- if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1)
- { perror("read CDROM toc header: "); return; }
+ if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) {
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ return NULL;
+ }
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; }
+ if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1) {
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
+ return NULL;
+ }
mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
(int)tocentry.cdte_track,
@@ -75,31 +87,31 @@
(int)tocentry.cdte_datamode
);
}
+ vcd = malloc(sizeof(mp_vcd_priv_t));
+ vcd->fd = fd;
+ return vcd;
}
-
-static char vcd_buf[VCD_SECTOR_SIZE];
-
-static int vcd_read(int fd,char *mem){
+static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
#if defined(linux) || defined(__bsdi__)
- memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf));
- if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF?
- memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
+ memcpy(vcd->buf,&vcd->entry.cdte_addr.msf,sizeof(struct cdrom_msf));
+ if(ioctl(vcd->fd,CDROMREADRAW,vcd->buf)==-1) return 0; // EOF?
+ memcpy(mem,&vcd->buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
#elif defined(sun)
{
int offset;
- if (sun_vcd_read(fd, &offset) <= 0) return 0;
- memcpy(mem,&vcd_buf[offset],VCD_SECTOR_DATA);
+ if (sun_vcd_read(vcd->fd, &offset) <= 0) return 0;
+ memcpy(mem,&vcd->buf[offset],VCD_SECTOR_DATA);
}
#endif
- 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++;
+ 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++;
}
}
@@ -116,35 +128,35 @@
#define SUN_SCSIREAD 3
#define SUN_VCDREAD SUN_SCSIREAD
-static int sun_vcd_read(int fd, int *offset)
+static int sun_vcd_read(mp_vcd_priv_t* vcd, int *offset)
{
#if SUN_VCDREAD == SUN_XAREAD
struct cdrom_cdxa cdxa;
- cdxa.cdxa_addr = vcd_get_msf();
+ cdxa.cdxa_addr = vcd_get_msf(vcd);
cdxa.cdxa_length = 1;
- cdxa.cdxa_data = vcd_buf;
+ cdxa.cdxa_data = vcd->buf;
cdxa.cdxa_format = CDROM_XA_SECTOR_DATA;
if(ioctl(fd,CDROMCDXA,&cdxa)==-1) {
- perror("CDROMCDXA");
+ mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMCDXA: %s\n",strerror(errno));
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_lba = 4*vcd_get_msf(vcd);
+ cdread.cdread_bufaddr = vcd->buf;
cdread.cdread_buflen = 2336;
if(ioctl(fd,CDROMREADMODE2,&cdread)==-1) {
- perror("CDROMREADMODE2");
+ mp_msg(MSGT_STREAM,MSGL_ERR,"CDROMREADMODE2: %s\n",strerror(errno));
return 0;
}
*offset = 8;
#elif SUN_VCDREAD == SUN_SCSIREAD
struct uscsi_cmd sc;
union scsi_cdb cdb;
- int lba = vcd_get_msf();
+ int lba = vcd_get_msf(vcd);
int blocks = 1;
int sector_type;
int sync, header_code, user_data, edc_ecc, error_field;
@@ -179,16 +191,16 @@
sc.uscsi_cdb = (caddr_t)&cdb;
sc.uscsi_cdblen = 12;
- sc.uscsi_bufaddr = vcd_buf;
+ 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)) {
- perror("USCSICMD: READ CD");
+ mp_msg(MSGT_STREAM,MSGL_ERR,"USCSICMD: READ CD: %s\n",strerror(errno));
return -1;
}
if (sc.uscsi_status) {
- fprintf(stderr, "scsi command failed with status %d\n", sc.uscsi_status);
+ mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed with status %d\n", sc.uscsi_status);
return -1;
}
*offset = 0;
Index: vcd_read_nbsd.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/vcd_read_nbsd.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vcd_read_nbsd.h 23 Dec 2002 00:40:15 -0000 1.3
+++ vcd_read_nbsd.h 9 Apr 2003 07:33:59 -0000 1.4
@@ -6,83 +6,85 @@
#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];
+typedef struct mp_vcd_priv_st {
+ int fd;
+ struct ioc_read_toc_entry entry;
+ struct cd_toc_entry entry_data;
+} mp_vcd_priv_t;
static inline void
-vcd_set_msf(unsigned int sect)
+vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
{
- unsigned int s = sect;
- vcd_entry_data.addr.msf.frame = sect % 75;
+ vcd->entry_data.addr.msf.frame = sect % 75;
sect = sect / 75;
- vcd_entry_data.addr.msf.second = sect % 60;
+ vcd->entry_data.addr.msf.second = sect % 60;
sect = sect / 60;
- vcd_entry_data.addr.msf.minute = sect;
+ vcd->entry_data.addr.msf.minute = sect;
}
static inline void
-vcd_inc_msf(void)
+vcd_inc_msf(mp_vcd_priv_t* vcd)
{
- 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++;
+ 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()
+vcd_get_msf(mp_vcd_priv_t* vcd)
{
- return vcd_entry_data.addr.msf.frame +
- (vcd_entry_data.addr.msf.second +
- vcd_entry_data.addr.msf.minute * 60) * 75;
+ 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_seek_to_track(mp_vcd_priv_t* vcd, 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");
+ 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(vcd->fd, CDIOREADTOCENTRIES, &vcd->entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA * vcd_get_msf();
+ return VCD_SECTOR_DATA * vcd_get_msf(vcd);
}
int
-vcd_get_track_end(int fd, int track)
+vcd_get_track_end(mp_vcd_priv_t* vcd, int track)
{
struct ioc_toc_header tochdr;
- if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) {
- perror("read CDROM toc header: ");
+ if (ioctl(vcd->fd, CDIOREADTOCHEADER, &tochdr) == -1) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
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");
+ 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(vcd->fd, CDIOREADTOCENTRYS, &vcd->entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA * vcd_get_msf();
+ return VCD_SECTOR_DATA * vcd_get_msf(vcd);
}
-void
+mp_vcd_priv_t*
vcd_read_toc(int fd)
{
struct ioc_toc_header tochdr;
+ mp_vcd_priv_t* vcd;
int i;
if (ioctl(fd, CDIOREADTOCHEADER, &tochdr) == -1) {
- perror("read CDROM toc header: ");
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
return;
}
for (i = tochdr.starting_track; i <= tochdr.ending_track; i++) {
@@ -95,10 +97,10 @@
tocentry.data = &tocentry_data;
if (ioctl(fd, CDIOREADTOCENTRYS, &tocentry) == -1) {
- perror("read CDROM toc entry: ");
- return;
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
+ return NULL;
}
- printf("track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
+ mp_msg(MSGT_OPEN,MSGL_INFO,"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,
@@ -108,13 +110,16 @@
(int) tocentry.data->addr.msf.frame
);
}
+ vcd = malloc(sizeof(mp_vcd_priv_t));
+ vcd->fd = fd;
+ return vcd;
}
static int
-vcd_read(int fd, char *mem)
+vcd_read(mp_vcd_priv_t* vcd, char *mem)
{
struct scsireq sc;
- int lba = vcd_get_msf();
+ int lba = vcd_get_msf(vcd);
int blocks;
int sector_type;
int sync, header_code, user_data, edc_ecc, error_field;
@@ -149,17 +154,17 @@
sc.senselen = sizeof(sc.sense);
sc.flags = SCCMD_READ;
sc.timeout = 10000;
- rc = ioctl(fd, SCIOCCOMMAND, &sc);
+ rc = ioctl(vcd->fd, SCIOCCOMMAND, &sc);
if (rc == -1) {
- perror("SCIOCCOMMAND");
+ mp_msg(MSGT_STREAM,MSGL_ERR,"SCIOCCOMMAND: %s\n",strerror(errno));
return -1;
}
if (sc.retsts || sc.error) {
- fprintf(stderr, "scsi command failed: status %d error %d\n", sc.retsts,
- sc.error);
+ mp_msg(MSGT_STREAM,MSGL_ERR,"scsi command failed: status %d error %d\n",
+ sc.retsts,sc.error);
return -1;
}
- vcd_inc_msf();
+ vcd_inc_msf(vcd);
return VCD_SECTOR_DATA;
}
Index: vcd_read_fbsd.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/vcd_read_fbsd.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vcd_read_fbsd.h 15 Sep 2002 18:48:16 -0000 1.5
+++ vcd_read_fbsd.h 9 Apr 2003 07:33:59 -0000 1.6
@@ -12,61 +12,71 @@
uint8_t spare [4];
} cdsector_t;
-static cdsector_t vcd_buf;
-static struct ioc_read_toc_single_entry vcd_entry;
+typedef struct mp_vcd_priv_st {
+ int fd;
+ struct ioc_read_toc_single_entry entry;
+ cdsector_t buf;
+} mp_vcd_priv_t;
-static inline void vcd_set_msf(unsigned int sect){
- vcd_entry.entry.addr.msf.frame=sect%75;
+static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){
+ vcd->entry.entry.addr.msf.frame=sect%75;
sect=sect/75;
- vcd_entry.entry.addr.msf.second=sect%60;
+ vcd->entry.entry.addr.msf.second=sect%60;
sect=sect/60;
- vcd_entry.entry.addr.msf.minute=sect;
+ 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;
+static inline unsigned int vcd_get_msf(mp_vcd_priv_t* vcd){
+ 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");
+int vcd_seek_to_track(mp_vcd_priv_t* vcd, int track){
+ vcd->entry.address_format = CD_MSF_FORMAT;
+ vcd->entry.track = track;
+ if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd_entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif1: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA*vcd_get_msf();
+ return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-int vcd_get_track_end(int fd,int track){
+int vcd_get_track_end(mp_vcd_priv_t* vcd, 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");
+ if (ioctl(vcd->fd,CDIOREADTOCHEADER,&tochdr)==-1) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
return -1;
}
- return VCD_SECTOR_DATA*vcd_get_msf();
+ vcd->entry.address_format = CD_MSF_FORMAT;
+ vcd->entry.track = track<tochdr.ending_track?(track+1):CDROM_LEADOUT;
+ if (ioctl(vcd->fd, CDIOREADTOCENTRY, &vcd_entry)) {
+ mp_msg(MSGT_STREAM,MSGL_ERR,"ioctl dif2: %s\n",strerror(errno));
+ return -1;
+ }
+ return VCD_SECTOR_DATA*vcd_get_msf(vcd);
}
-void vcd_read_toc(int fd){
+mp_vcd_priv_t* vcd_read_toc(int fd){
struct ioc_toc_header tochdr;
+ mp_vcd_priv_t* vcd;
int i;
- if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1)
- { perror("read CDROM toc header: "); return; }
+ if (ioctl(fd,CDIOREADTOCHEADER,&tochdr)==-1) {
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc header: %s\n",strerror(errno));
+ return NULL;
+ }
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)
- { perror("read CDROM toc entry: "); return; }
+ if (ioctl(fd,CDIOREADTOCENTRY,&tocentry)==-1) {
+ mp_msg(MSGT_OPEN,MSGL_ERR,"read CDROM toc entry: %s\n",strerror(errno));
+ return NULL;
+ }
- printf("track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
+ mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d\n",
(int)tocentry.track,
(int)tocentry.entry.addr_type,
(int)tocentry.entry.control,
@@ -76,20 +86,23 @@
(int)tocentry.entry.addr.msf.frame
);
}
+ vcd = malloc(sizeof(mp_vcd_priv_t));
+ vcd->fd = fd;
+ return vcd;
}
-static int vcd_read(int fd,char *mem){
+static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
- if (pread(fd,&vcd_buf,VCD_SECTOR_SIZE,vcd_get_msf()*VCD_SECTOR_SIZE)
+ if (pread(vcd->fd,vcd->buf,VCD_SECTOR_SIZE,vcd_get_msf(vcd)*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++;
+ 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);
- Previous message: [Mplayer-cvslog] CVS: main/libmpdemux stream_vcd.c,NONE,1.1 open.c,1.77,1.78 stream.h,1.62,1.63 stream.c,1.61,1.62 Makefile,1.56,1.57
- Next message: [Mplayer-cvslog] CVS: main subreader.c,1.102,1.103
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list