From: Rocky B. <ro...@us...> - 2003-08-26 11:58:22
|
Update of /cvsroot/xine/xine-vcdnav/input In directory sc8-pr-cvs1:/tmp/cvs-serv2080 Modified Files: xineplug_inp_cd.c Log Message: Bug fixes: was freeing cdio before parsing mrl so using afterwards caused a segfault. Encountered when giving an initial MRL with a track. Was playing 2 seconds into cut because using lba's rather than lsn's. Feature: allow 'T' or 't' before track number e.g. cdda:///dev/cdrom@T1. Old forms, e.g. without 'T' still work. Index: xineplug_inp_cd.c =================================================================== RCS file: /cvsroot/xine/xine-vcdnav/input/xineplug_inp_cd.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- xineplug_inp_cd.c 25 Aug 2003 13:34:22 -0000 1.29 +++ xineplug_inp_cd.c 26 Aug 2003 11:57:55 -0000 1.30 @@ -421,9 +421,11 @@ char *mrl; CdIo *cdio; + bool destroy_cdio = false; track_t first_track, i; track_t num_tracks; unsigned int size; + bool mrl_list_success = false; dbg_print((INPUT_DBG_CALL), "called\n"); @@ -432,18 +434,21 @@ return false; } - cdda_close (class); - - cdio = cdio_open(class->cdda_device, DRIVER_UNKNOWN); - if (NULL == cdio) { - LOG_MSG("%s", _("cdio open failed")); - return false; + if (class->cdio) { + cdio = class->cdio; + } else { + cdio = cdio_open(class->cdda_device, DRIVER_UNKNOWN); + if (NULL == cdio) { + LOG_MSG("%s", _("cdio open failed")); + return false; + } + destroy_cdio = true; } num_tracks = cdio_get_num_tracks(cdio); if (CDIO_INVALID_TRACK == num_tracks) { LOG_MSG("%s", _("error retrieving number of tracks")); - return false; + goto mrl_list_exit; } xine_free_mrls(&(class->num_mrls), class->mrls); @@ -454,19 +459,19 @@ if (NULL == class->mrls) { LOG_ERR("Can't calloc %d MRL entries", class->num_mrls); class->num_mrls = 0; - return false; + goto mrl_list_exit; } - size = MRL_PREFIX_LEN+strlen(class->cdda_device)+6; - mrl = (char *) malloc(size); - if (NULL==mrl) { + size = MRL_PREFIX_LEN+strlen(class->cdda_device)+strlen("@Txxxx"); + mrl = (char *) malloc(size); + if ( NULL==mrl ) { LOG_ERR("Can't malloc %d bytes for MRL", size); - return false; + goto mrl_list_exit; } /* Record MRL's for tracks */ first_track = cdio_get_first_track_num(cdio); - for ( i= 0; i < class->num_mrls; i++) { + for ( i= 0; i < class->num_mrls; i++ ) { memset(mrl, 0, sizeof (mrl)); MRL_FORMAT(mrl, class->cdda_device, first_track+i); cdda_add_mrl_slot(class, mrl, @@ -474,14 +479,16 @@ } free(mrl); - cdio_destroy(cdio); - - return true; + mrl_list_success = true; + mrl_list_exit: + + if (destroy_cdio) cdio_destroy(cdio); + return mrl_list_success; } /*! parses a MRL which has the format - cdda://[cd_path][@number]? + cdda://[cd_path][@[Tt]?number]? Parameters: mrl the MRL we need to parse @@ -498,14 +505,17 @@ cdda:///dev/cdrom - probably same as above cdda:///dev/cdrom2 - track 1 of /dev/cdrom2 cdda:///dev/cdrom2@ - same as above - cdda://dev/cdrom2@5 - track 5 from /dev/cdrom2 + cdda://dev/cdrom2@53 - track 53 from /dev/cdrom2 + cdda://dev/cdrom2@T53 - Same as above + cdda://dev/cdrom2@t53 - Same as above cdda://@2 - track 2 from default device cdda://3 - track 3 from default device - cdda:///dev/cdrom2@4 - track 4 from /dev/cdrom2 cdda:///tmp/ntsc.cue - track 1 from /tmp/ntsc.bin, (a bin/cue disk image) cdda:///tmp/ntsc.cue@ - same as above - cdda:/ntsc.nrg - track 1 of ntsc.nrg (a nero disk image) + cdda://tmp/ntsc.cue@ - track 1 of tmp/ntsc.bin. NOT the + the same as above unless the cwd is /. + cdda://ntsc.nrg - track 1 of ntsc.nrg (a nero disk image) cdda://tmp/ntsc.nrg@5 - track 5 of /tmp/ntsc.nrg Bad MRL's @@ -550,6 +560,7 @@ int len_p = strlen(p); int len_d = strlen(device_str); + char type_str[2]; /* If there was a @ but more stuff after that, then fail. A single @ at the end is okay though. @@ -557,21 +568,20 @@ if ((len_p==len_d+1) && ('@' != p[len_d])) return false; - if (len_p != len_d && len_p != len_d+1) - return false; - - /* See if we have old-style MRL, e.g. cdda@n */ - count = sscanf (device_str, "%u", &num); - if (1==count) { + /* See if we have old-style MRL, e.g. cdda://1 */ + if (1==sscanf (p, "%u", &num)) { *track_num = num; strcpy(device_str, default_device); return true; - } else if (0==count) { - /* Have device, so just take default track 1. */ - *track_num = 1; - return true; - } else - return false; + } else { + /* Check for form device_str@Tnnn */ + if ( 3 == sscanf (p, "%[^@]@%1[Tt]%u", device_str, type_str, &num) ) { + /* Got both device and track. device was set above. */ + *track_num = num; + return true; + } else + return false; + } } case 0: @@ -871,7 +881,7 @@ cdda_update_title(this); return true; } - last_lsn = cdio_get_track_lba(this->class->cdio, t+this->first_track); + last_lsn = cdio_get_track_lsn(this->class->cdio, t+this->first_track); } return false; @@ -1262,8 +1272,8 @@ /* set up the frame boundaries for this particular track */ this->first_frame = this->current_frame = - cdio_get_track_lba(this->class->cdio, track_num); - this->last_frame = cdio_get_track_lba(this->class->cdio, track_num+1) - 1; + cdio_get_track_lsn(this->class->cdio, track_num); + this->last_frame = cdio_get_track_lsn(this->class->cdio, track_num+1) - 1; this->jumped = true; /*xine_demux_flush_engine (this->stream);*/ @@ -1279,12 +1289,15 @@ */ static int cdda_plugin_open (input_plugin_t *this_gen ) { + cdda_input_plugin_t *this = (cdda_input_plugin_t *) this_gen; dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); gl_default_cdio_log_handler = cdio_log_set_handler (cdio_log_handler); #ifdef HAVE_CDDB gl_default_cddb_log_handler = cddb_log_set_handler (cddb_log_handler); #endif + if (this->class->ip != this) + LOG_MSG("WARN: this->class->ip != this"); return 1; } @@ -1327,9 +1340,9 @@ this->event_queue = xine_event_new_queue (stream); this->num_tracks = cdio_get_num_tracks(cdio); this->first_track = cdio_get_first_track_num(cdio); - this->disk_size = cdio_get_track_lba(cdio, CDIO_CDROM_LEADOUT_TRACK) + this->disk_size = cdio_get_track_lsn(cdio, CDIO_CDROM_LEADOUT_TRACK) * CDIO_CD_FRAMESIZE_RAW; - this->last_disk_frame= cdio_get_track_lba(cdio, CDIO_CDROM_LEADOUT_TRACK); + this->last_disk_frame= cdio_get_track_lsn(cdio, CDIO_CDROM_LEADOUT_TRACK); class->ip = this; this->class = class; @@ -1544,9 +1557,11 @@ #endif if (NULL != class->mrls) xine_free_mrls(&(class->num_mrls), class->mrls); - if (NULL != class->cdio) cdio_destroy(class->cdio); if (NULL != class->ip) class->ip = NULL; - + if (NULL != class->cdio) { + cdio_destroy(class->cdio); + class->cdio = NULL; + } } |