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

- old
+ new

@@ -6,53 +6,24 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "CdIo.h" -/** -* Funci?n extraida de cd-info.c -*/ - - VALUE -rb_cdio_track_new(VALUE cd, int track) -{ - VALUE argv[2]; - argv[0] = cd; - argv[1] = INT2FIX(track); - return rb_class_new_instance(2, argv, cCdIoTrack); -} - -int -rb_cdio_track_number(VALUE obj) -{ - return FIX2INT(rb_iv_get(obj, "@number")); -} - -VALUE -rb_cdio_track_green(VALUE obj) -{ - 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. + // Verificacion 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); + // printf("En init:%d\n",i_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; @@ -77,13 +48,13 @@ char *msf_s; if (cdio_get_track_msf(p_cdio, i_track, &msf)) { msf_s = cdio_msf_to_str(&msf); // printf("C->%d:%d:%d\n",(int)msf.m,(int)msf.s,(int)msf.f); - rb_iv_set(obj, "@min", INT2FIX(from_bcd8(msf.m))); - rb_iv_set(obj, "@sec", INT2FIX(from_bcd8(msf.s))); - rb_iv_set(obj, "@frames", INT2FIX(from_bcd8(msf.f))); + rb_iv_set(obj, "@min", INT2FIX(cdio_from_bcd8(msf.m))); + rb_iv_set(obj, "@sec", INT2FIX(cdio_from_bcd8(msf.s))); + rb_iv_set(obj, "@frames", INT2FIX(cdio_from_bcd8(msf.f))); rb_iv_set(obj, "@msf", rb_str_new2(msf_s)); free(msf_s); } rb_iv_set(obj, "@sec_count", @@ -94,9 +65,26 @@ 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; +} + +int +rb_cdio_track_number(VALUE obj) +{ + return FIX2INT(rb_iv_get(obj, "@number")); +} + +VALUE +rb_cdio_track_green(VALUE obj) +{ + 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_get_cdtext(VALUE obj) {