From: Rocky B. <ro...@us...> - 2002-12-28 13:41:03
|
Update of /cvsroot/xine/xine-vcdnav/input In directory sc8-pr-cvs1:/tmp/cvs-serv15236 Modified Files: vcdio.c vcdio.h vcdplayer.c vcdplayer.h xineplug_inp_vcd.c Log Message: Remove all I/O from player portion. Some slider position stuff is broken (for entries and track within entries), but that's a result xine-lib changes. Index: vcdio.c =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/vcdio.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- vcdio.c 27 Dec 2002 23:14:17 -0000 1.18 +++ vcdio.c 28 Dec 2002 13:40:59 -0000 1.19 @@ -41,21 +41,10 @@ #include <sys/ioctl.h> -#ifdef HAVE_LINUX_CDROM_H -# include <linux/cdrom.h> -#endif -#ifdef HAVE_SYS_CDIO_H -# include <sys/cdio.h> /* CDIOCALLOW etc... */ -/* TODO: not clean yet */ -# if defined (__FreeBSD__) -# include <sys/cdrio.h> -# endif -#endif -#if ! defined (HAVE_LINUX_CDROM_H) && ! defined (HAVE_SYS_CDIO_H) -#error "you need to add CDROM support for your platform to input_xvcd and configure.in" -#endif - -/* Xine includes */ +/* Xine includes + FIXME: remove xine include We need + to fix up the MRLtype definition in vcdplayer.h first. +*/ #include <xine/xine_internal.h> /* libvcd includes */ @@ -76,136 +65,32 @@ if (this != NULL && this->log_err != NULL) \ this->log_err("%s: "s, __func__ , ##args) -#if defined (__linux__) || defined(__sun) -struct cdrom_tochdr tochdr; -struct cdrom_tocentry tocent[100]; -#elif defined (__FreeBSD__) -struct ioc_toc_header tochdr; -struct cd_toc_entry *tocent; -off_t cur_sector; -#endif - -static int -vcdio_read_toc (vcdplayer_input_t *this) -{ -#if defined (__linux__) || defined(__sun__) - int i; - - /* read TOC header */ - if ( ioctl(this->fd, CDROMREADTOCHDR, &tochdr) == -1 ) { - LOG_ERR(this, "%s: %s\n", - _("error in ioctl CDROMREADTOCHDR"), strerror(errno)); - return -1; - } - - /* read individual tracks */ - for (i=tochdr.cdth_trk0; i<=tochdr.cdth_trk1; i++) { - tocent[i-1].cdte_track = i; - tocent[i-1].cdte_format = CDROM_MSF; - if ( ioctl(this->fd, CDROMREADTOCENTRY, &tocent[i-1]) == -1 ) { - LOG_ERR(this, "%s %d: %s\n", - _("error in ioctl CDROMREADTOCENTRY for track"), - i, strerror(errno)); - return -1; - } - } - - /* read the lead-out track */ - tocent[tochdr.cdth_trk1].cdte_track = CDROM_LEADOUT; - tocent[tochdr.cdth_trk1].cdte_format = CDROM_MSF; - - if (ioctl(this->fd, CDROMREADTOCENTRY, - &tocent[tochdr.cdth_trk1]) == -1 ) { - LOG_ERR(this, "%s: %s\n", - _("error in ioctl CDROMREADTOCENTRY for lead-out"), - strerror(errno)); - return -1; - } - - this->total_tracks = tochdr.cdth_trk1; -#elif defined (__FreeBSD__) - struct ioc_read_toc_entry te; - int ntracks; - - /* read TOC header */ - if ( ioctl(this->fd, CDIOREADTOCHEADER, &tochdr) == -1 ) { - LOG_ERR(this, "%s: %s\n", _("error in ioctl CDROMREADTOCHDR"), - strerror(errno)); - return -1; - } - - ntracks = tochdr.ending_track - tochdr.starting_track + 2; - this->tocent = (struct cd_toc_entry *) - _malloc_and_zero(sizeof(*tocent) * ntracks); - - te.address_format = CD_LBA_FORMAT; - te.starting_track = 0; - te.data_len = ntracks * sizeof(struct cd_toc_entry); - te.data = tocent; - - if ( ioctl(this->fd, CDIOREADTOCENTRYS, &te) == -1 ){ - LOG_ERR(this, "%s: %s\n", _("error in ioctl CDROMREADTOCENTRY"), - strerror(errno)); - return -1; - } - - this->total_tracks = this->tochdr.ending_track - - this->tochdr.starting_track +1; -#endif - - if (!vcdinfo_open(&(this->vcd), this->current_vcd_device, - VCDINFO_SOURCE_DEVICE)) { - return -1; - } - - - if (vcdinfo_read_psd (&(this->vcd))) { - - /* FIXME: Below handles only vcd.lot - and.lot_x correctly. - */ - vcdinfo_visit_lot (&(this->vcd), false); - } - - - return 0; -} - /*! Closes VCD device specified via "this", and also wipes memory of it from it inside "this". */ int vcdio_close(vcdplayer_input_t *this) { - int ret; - - if (-1 != this->fd) { - ret = close (this->fd); - if (-1 == ret) { - LOG_ERR(this, "%s\n", strerror(errno)); - } - this->fd = -1; - } - - ret = vcdinfo_close(&(this->vcd)); - return ret; + this->opened = false; + free(this->current_vcd_device); + return vcdinfo_close(&(this->vcd)); } -/*! Opens VCD device and reads TOC, with some checking and status - recording: +/*! Opens VCD device and initializes things. - do nothing if the device had already been open and is the same device. - if the device had been open and is a different, close it before trying to open new device. */ -/* FIXME Move player stuff to player. */ bool vcdio_open(vcdplayer_input_t *this, char *intended_vcd_device) { + vcdinfo_obj_t *obj = &this->vcd; - bool ret = true; - if ( -1 != this->fd ) { - if ( intended_vcd_device==this->current_vcd_device ) { + dbg_print(INPUT_DBG_CALL, "called with %s\n", intended_vcd_device); + + if ( this->opened ) { + if ( strcmp(intended_vcd_device, this->current_vcd_device)==0 ) { /* Already open and the same device, so do nothing */ return true; } else { @@ -214,24 +99,23 @@ } } - dbg_print(INPUT_DBG_CALL, "called with %s\n", intended_vcd_device); - this->fd = open (intended_vcd_device, O_RDONLY); - if (this->fd == -1) { - LOG_ERR(this, "%s %s: %s.\n", _("Error opening CDROM device"), - intended_vcd_device, strerror(errno)); + if (!vcdinfo_open(obj, intended_vcd_device, VCDINFO_SOURCE_DEVICE)) { return false; } - vcdinfo_open (&(this->vcd), intended_vcd_device, VCDINFO_SOURCE_DEVICE); - this->current_vcd_device=intended_vcd_device; - if (0 != vcdio_read_toc (this)) { - vcdio_close(this); - /* vcdio_read_toc should have logged an error. If not: - LOG_ERR(this, "%s\n", _("vcdio_read_toc failed")); + + this->current_vcd_device=strdup(intended_vcd_device); + this->opened = true; + this->total_tracks = vcdinfo_get_track_count(obj); + + if (vcdinfo_read_psd (obj)) { + + /* FIXME: Below handles only vcd.lot + and.lot_x correctly. */ - return false; + vcdinfo_visit_lot (obj, false); } - - return ret; + + return true; } /*! @@ -275,7 +159,7 @@ vcdinfo_lba2msf (lba, &(this->cur_msf.min), &(this->cur_msf.sec), &(this->cur_msf.frame)); - dbg_print(INPUT_DBG_SEEK, + dbg_print(INPUT_DBG_SEEK_SET, "seek_set to %lld => %02d:%02d:%02d " "(start is %02d:%02d:%02d)\n", offset, @@ -298,7 +182,7 @@ case SEEK_CUR: { off_t lba; - unsigned int start_min, start_sec, start_frame; + uint8_t start_min, start_sec, start_frame; if (offset) { LOG_ERR(this, "%s: %d\n", _("SEEK_CUR not implemented for nozero offset"), @@ -309,9 +193,8 @@ if (this->slider_length == VCDPLAYER_SLIDER_LENGTH_TRACK) { int track = this->cur_msf.track; - start_min = tocent[track].cdte_addr.msf.minute; - start_sec = tocent[track].cdte_addr.msf.second; - start_frame = tocent[track].cdte_addr.msf.frame; + vcdinfo_get_track_msf(obj, track, + &start_min, &start_sec, &start_frame); } else { start_min = start_msf->min; start_sec = start_msf->sec; @@ -319,7 +202,7 @@ } - dbg_print(INPUT_DBG_SEEK, + dbg_print(INPUT_DBG_SEEK_CUR, "current pos: %02d:%02d:%02d\n", this->cur_msf.min, this->cur_msf.sec, this->cur_msf.frame); Index: vcdio.h =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/vcdio.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- vcdio.h 22 Dec 2002 17:17:07 -0000 1.5 +++ vcdio.h 28 Dec 2002 13:41:00 -0000 1.6 @@ -22,17 +22,6 @@ #ifndef _VCDIO_H_ #define _VCDIO_H_ -/* This should get moved into vcdinfo. */ -void -vcd_lba2msf (off_t offset, uint8_t *min, uint8_t *sec, - uint8_t *frame) ; - -/* - return the size in bytes of the track that starts at "track" - */ -off_t -vcdio_get_track_length (vcdplayer_input_t *this, int track); - /*! From xine plugin spec: @@ -41,14 +30,12 @@ off_t vcdio_read (vcdplayer_input_t *this, char *buf, const off_t nlen); -/*! Opens VCD device and reads TOC, with some checking and status - recording: +/*! Opens VCD device and initializes things. - do nothing if the device had already been open and is the same device. - if the device had been open and is a different, close it before trying to open new device. */ -/* FIXME Move player stuff to player. */ bool vcdio_open(vcdplayer_input_t *this, char *intended_vcd_device); Index: vcdplayer.c =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/vcdplayer.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- vcdplayer.c 27 Dec 2002 23:11:52 -0000 1.28 +++ vcdplayer.c 28 Dec 2002 13:41:00 -0000 1.29 @@ -426,13 +426,13 @@ vcdplayer_build_mrl_list(vcdplayer_input_t *this, char *vcd_device) { - unsigned int j; + unsigned int n; char mrl[1024]; unsigned int num_entries; vcdinfo_obj_t *obj; /* skip VCD if already open */ - if (-1 != this->fd) return true; + if (this->opened) return true; if (!vcdio_open(this, vcd_device)) { /* Error should have been logged in vcdio_open. If not do the below: @@ -449,31 +449,31 @@ this->mrl_track_offset = -1; /* Record MRL's for tracks */ - for (j=0; j<this->total_tracks-1; j++) { + for (n=1; n<=this->total_tracks; n++) { /* FIXME: check if track 0 contains valid data */ memset(&mrl, 0, sizeof (mrl)); - sprintf(mrl, "%s:T%u", MRL_PREFIX, j+1); + sprintf(mrl, "%s:T%u", MRL_PREFIX, n); /* printf("new size: %d, old size: %u\n", - vcdinfo_get_track_size(obj, j+1), - vcdio_get_track_length(this, j+1)); + vcdinfo_get_track_size(obj, n), + vcdio_get_track_length(this, n)); */ - add_mrl_slot(this, mrl, vcdinfo_get_track_size(obj, j+1)); + add_mrl_slot(this, mrl, vcdinfo_get_track_size(obj, n)); } - this->mrl_entry_offset = this->total_tracks - 1; + this->mrl_entry_offset = this->total_tracks; this->mrl_play_offset = this->mrl_entry_offset + num_entries - 1; /* Record MRL's for entries */ if (num_entries > 0) { - for (j=0; j<num_entries; j++) { - uint32_t size = vcdinfo_get_entry_size(obj, j); + for (n=0; n<num_entries; n++) { + uint32_t size = vcdinfo_get_entry_size(obj, n); memset(&mrl, 0, sizeof (mrl)); - sprintf(mrl, "%s:E%u", MRL_PREFIX, j); + sprintf(mrl, "%s:E%u", MRL_PREFIX, n); add_mrl_slot(this, mrl, size * VCDINFO_M2F2_SECTOR_SIZE); } } @@ -482,11 +482,11 @@ this->mrl_segment_offset = this->mrl_play_offset; if (this->vcd.lot) { const uint16_t max_lid = vcdinfo_get_max_lid(obj); - for (j=0; j<max_lid; j++) { - uint16_t ofs = uint16_from_be (this->vcd.lot->offset[j]); + for (n=0; n<max_lid; n++) { + uint16_t ofs = uint16_from_be (this->vcd.lot->offset[n]); if (ofs != PSD_OFS_DISABLED || this->show_rejected) { memset(&mrl, 0, sizeof (mrl)); - sprintf(mrl, "%s:P%u%s", MRL_PREFIX, j+1, + sprintf(mrl, "%s:P%u%s", MRL_PREFIX, n+1, ofs == PSD_OFS_DISABLED ? "*" : ""); add_mrl_slot(this, mrl, 0); this->mrl_segment_offset++; @@ -495,19 +495,19 @@ } /* Record MRL's for segments */ - { - unsigned int num_segments = vcdinfo_get_num_segments(&(this->vcd)); - for (j=0; j<num_segments; j++) { - size_t seg_size; - memset(&mrl, 0, sizeof (mrl)); - sprintf(mrl, "%s:S%u", MRL_PREFIX, j+1); - seg_size = vcdinfo_get_seg_size(&(this->vcd), j); - add_mrl_slot(this, mrl, seg_size); - } - } - + { + unsigned int num_segments = vcdinfo_get_num_segments(&(this->vcd)); + for (n=0; n<num_segments; n++) { + size_t seg_size; + memset(&mrl, 0, sizeof (mrl)); + sprintf(mrl, "%s:S%u", MRL_PREFIX, n+1); + seg_size = vcdinfo_get_seg_size(&(this->vcd), n); + add_mrl_slot(this, mrl, seg_size); + } + } - dbg_print(INPUT_DBG_MRL, "track: %d, entry: %d, play: %d seg: %d\n", + dbg_print(INPUT_DBG_MRL, + "offsets are track: %d, entry: %d, play: %d seg: %d\n", this->mrl_track_offset, this->mrl_entry_offset, this->mrl_play_offset, this->mrl_segment_offset); @@ -534,7 +534,7 @@ return; } - loc->track = vcdinfo_get_track(obj, entry_num) - 1; + loc->track = vcdinfo_get_track(obj, entry_num); loc->min = from_bcd8(msf->m); loc->sec = from_bcd8(msf->s); loc->frame = from_bcd8(msf->f); @@ -677,18 +677,15 @@ else { vcdinfo_obj_t *obj = &this->vcd; vcdinfo_itemid_t itemid; - msf_t msf; this->cur_msf.track = track_num; itemid.num = track_num; itemid.type = VCDINFO_ITEM_TYPE_TRACK; - vcdinfo_get_track_msf(obj, track_num, &msf); - - this->cur_msf.min = from_bcd8(msf.m); - this->cur_msf.sec = from_bcd8(msf.s); - this->cur_msf.frame = from_bcd8(msf.f); + vcdinfo_get_track_msf(obj, track_num, &(this->cur_msf.min), + &(this->cur_msf.sec), &(this->cur_msf.frame)); + _vcdplayer_set_origin(this, _vcdplayer_get_item_size(this, itemid)); /* Playing seems not to continue without break to the next track. @@ -1063,9 +1060,9 @@ vcdplayer_update_nav(this); dbg_print(INPUT_DBG_MSF, - "next reached. cur: %02d:%02d:%02d end: %02d:%02d:%02d\n", - this->cur_msf.min, this->cur_msf.sec, this->cur_msf.frame, - this->end_msf.min, this->end_msf.sec, this->end_msf.frame); + "next reached. cur: %02d:%02d:%02d next: %02d:%02d:%02d\n", + this->cur_msf.min, this->cur_msf.sec, this->cur_msf.frame, + this->next_msf.min, this->next_msf.sec, this->next_msf.frame); } /* Read the next block. And just when you thought we'd never get around Index: vcdplayer.h =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/vcdplayer.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- vcdplayer.h 27 Dec 2002 23:54:58 -0000 1.25 +++ vcdplayer.h 28 Dec 2002 13:41:00 -0000 1.26 @@ -27,14 +27,15 @@ /* Debugging facility */ -#define INPUT_DBG 1 -#define INPUT_DBG_TRACE 2 -#define INPUT_DBG_MRL 4 -#define INPUT_DBG_CALL 8 -#define INPUT_DBG_MSF 16 -#define INPUT_DBG_PBC 32 -#define INPUT_DBG_SEEK 64 -#define INPUT_DBG_VCDINFO 128 +#define INPUT_DBG 1 +#define INPUT_DBG_TRACE 2 +#define INPUT_DBG_MRL 4 +#define INPUT_DBG_CALL 8 +#define INPUT_DBG_MSF 16 +#define INPUT_DBG_PBC 32 +#define INPUT_DBG_SEEK_SET 64 +#define INPUT_DBG_SEEK_CUR 128 +#define INPUT_DBG_VCDINFO 256 extern unsigned long int vcdplayer_debug; @@ -143,8 +144,7 @@ char *current_vcd_device; /* VCD device currently open */ char *default_vcd_device; /* Use this if none given in mrl */ vcdplayer_autoplay_t default_autoplay; /* What type to use on autoplay */ - int fd; /* file decriptor for open device - -1 if nothing is opened. */ + bool opened; /* true if initialized */ /*-------------------------------------------------------------- Configuration variables Index: xineplug_inp_vcd.c =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/xineplug_inp_vcd.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- xineplug_inp_vcd.c 27 Dec 2002 23:41:16 -0000 1.36 +++ xineplug_inp_vcd.c 28 Dec 2002 13:41:00 -0000 1.37 @@ -299,7 +299,7 @@ n += this->mrl_entry_offset; break; case VCDPLAYER_SLIDER_LENGTH_TRACK: - n += this->mrl_track_offset; + n = vcdinfo_get_track(&(this->vcd), n) + this->mrl_track_offset; break; default: /* FIXME? */ @@ -325,7 +325,9 @@ if (n >= 0 && n < this->num_mrls) { old_get_length = this->mrls[n]->size; - dbg_print(INPUT_DBG_TRACE, "size %u\n", (unsigned int) old_get_length); + dbg_print(INPUT_DBG_MRL, "item: %u, slot %u, size %u\n", + this->play_item.num, + (unsigned int) n, (unsigned int) old_get_length); } return old_get_length; } @@ -1105,7 +1107,7 @@ my_vcdx.v.buttonN = 0; my_vcdx.v.current_vcd_device = NULL; - my_vcdx.v.fd = -1; + my_vcdx.v.opened = false; my_vcdx.v.play_item.num = VCDPLAYER_BAD_ENTRY; my_vcdx.v.play_item.type = VCDINFO_ITEM_TYPE_ENTRY; |