ext/CdIo_Track.c in rb_cdio-0.1.0 vs ext/CdIo_Track.c in rb_cdio-0.1.1

- old
+ new

@@ -7,11 +7,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "CdIo.h" /** -* Función extraida de cd-info.c +* Funci?n extraida de cd-info.c */ VALUE rb_cdio_track_new(VALUE cd, int track) @@ -29,29 +29,42 @@ } VALUE rb_cdio_track_green(VALUE obj) { - GET_CDIO(rb_iv_get(obj, "@cd"),p_cdio); + GET_CDIO(rb_iv_get(obj, "@cd"), p_cdio); if (cdio_get_track_green(p_cdio, rb_cdio_track_number(obj))) { return Qtrue; } else { return Qfalse; } } + VALUE rb_cdio_track_init(VALUE obj, VALUE cd, VALUE track) { - // Verificación de tipos. + // Verificaci?n de tipos. lsn_t lsn; int i_track; FIXNUM_P(track); if (Qtrue != rb_obj_is_instance_of(cd, cCdIoCd)) { rb_raise(rb_eArgError, "Arg 1 must be a CdIo::Cd"); } GET_CDIO(cd, p_cdio); i_track = FIX2INT(track); + // Verify track number + track_t min, + max; + min = cdio_get_first_track_num(p_cdio); + max = min + cdio_get_num_tracks(p_cdio) - 1; + if (i_track != CDIO_CDROM_LEADOUT_TRACK + && (i_track < min || i_track > max)) { + char buffer[64]; + sprintf(buffer, "The track %d doesn't exists", i_track); + rb_raise(rb_eException, buffer); + } + /** :cd :number :format, :green, :lba,:lsn,:msf,:sec_count*/ rb_iv_set(obj, "@cd", cd); rb_iv_set(obj, "@number", track); rb_iv_set(obj, "@format", INT2FIX(cdio_get_track_format(p_cdio, i_track))); @@ -78,14 +91,18 @@ // vemos el tipo cdio_fs_anal_t fs; cdio_iso_analysis_t iso_analysis; fs = cdio_guess_cd_type(p_cdio, 0, i_track, &iso_analysis); rb_iv_set(obj, "@track_type", INT2FIX(fs)); - + rb_iv_set(obj, "@leadout", + (i_track == CDIO_CDROM_LEADOUT_TRACK) ? Qtrue : Qfalse); return obj; } -VALUE rb_cdio_track_get_cdtext(VALUE obj) { - GET_CDIO(rb_iv_get(obj, "@cd"),p_cdio); - const cdtext_t *cdtext = cdio_get_cdtext(p_cdio, rb_cdio_track_number(obj)); +VALUE +rb_cdio_track_get_cdtext(VALUE obj) +{ + GET_CDIO(rb_iv_get(obj, "@cd"), p_cdio); + const cdtext_t *cdtext = + cdio_get_cdtext(p_cdio, rb_cdio_track_number(obj)); return get_cdtext(cdtext); }