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

- old
+ new

@@ -32,22 +32,22 @@ rb_define_module_function(mCdIo, "is_binfile", rb_cdio_is_binfile, 1); rb_define_module_function(mCdIo, "is_cuefile", rb_cdio_is_cuefile, 1); rb_define_module_function(mCdIo, "is_nrg", rb_cdio_is_nrg, 1); rb_define_module_function(mCdIo, "is_tocfile", rb_cdio_is_tocfile, 1); rb_define_module_function(mCdIo, "is_device", rb_cdio_is_device, -1); - + rb_define_module_function(mCdIo, "close_tray", rb_cdio_close_tray, 1); /** * class CdIo::Cd */ cCdIoCd = rb_define_class_under(mCdIo, "Cd", rb_cObject); rb_define_singleton_method(cCdIoCd, "new", rb_cdio_cd_new, -1); rb_define_method(cCdIoCd, "initialize", rb_cdio_cd_init, 2); int i; #define CDIO_ATTR 9 const char *attr[CDIO_ATTR] = { "device", "mcn", "driver_name", "driver_id", "first_track_num", - "discmode", "num_tracks", "stat_size", "cddb_id" + "discmode", "num_tracks", "last_lsn", "joliet_level" }; for (i = 0; i < CDIO_ATTR; i++) { rb_define_attr(cCdIoCd, attr[i], 1, 0); } rb_define_method(cCdIoCd, "tracks", rb_cdio_cd_get_tracks, 0); @@ -61,19 +61,40 @@ rb_define_method(cCdIoCd, "cdtext", rb_cdio_cd_get_cdtext, 0); // device methods rb_define_method(cCdIoCd, "drive_cap", rb_cdio_cd_get_drive_cap, 0); rb_define_method(cCdIoCd, "hwinfo", rb_cdio_cd_get_hwinfo, 0); rb_define_method(cCdIoCd, "close", rb_cdio_cd_close, 0); + rb_define_method(cCdIoCd, "eject", rb_cdio_cd_eject, 0); + // CdIo::CdDa module + mCdIoCdda = rb_define_module_under(mCdIo, "Cdda"); + rb_define_method(mCdIoCdda, "volume", rb_cdio_cdda_get_volume, 0); + rb_define_method(mCdIoCdda, "volume=", rb_cdio_cdda_set_volume, 1); + rb_define_method(mCdIoCdda, "play", rb_cdio_cdda_play, -1); + rb_define_method(mCdIoCdda, "pause", rb_cdio_cdda_pause, 0); + rb_define_method(mCdIoCdda, "resume", rb_cdio_cdda_resume, 0); + rb_define_method(mCdIoCdda, "stop", rb_cdio_cdda_stop, 0); + rb_define_method(mCdIoCdda, "subchannel", rb_cdio_cdda_subchannel, 0); + rb_define_method(mCdIoCdda, "cddb_id", rb_cdio_cdda_cddb_id, 0); + rb_define_method(mCdIoCdda, "cddb_matches",rb_cdio_cdda_cddb_matches,0); + rb_define_method(mCdIoCdda, "cddb_fetch",rb_cdio_cdda_cddb_fetch,1); + + rb_define_method(mCdIoCdda,"artist",rb_cdio_cdda_artist,0); + rb_define_method(mCdIoCdda,"title",rb_cdio_cdda_title,0); + rb_define_method(mCdIoCdda,"year",rb_cdio_cdda_year,0); + rb_define_method(mCdIoCdda,"length",rb_cdio_cdda_length,0); + rb_define_method(mCdIoCdda,"genre",rb_cdio_cdda_genre,0); + rb_define_method(mCdIoCdda,"category",rb_cdio_cdda_category,0); + rb_define_method(mCdIoCdda,"extra_data",rb_cdio_cdda_extra_data,0); + /** class CdIo::Tracks */ cCdIoTracks = rb_define_class_under(mCdIo, "Tracks", rb_cObject); rb_include_module(cCdIoTracks, rb_mEnumerable); rb_define_method(cCdIoTracks, "initialize", rb_cdio_tracks_init, 1); rb_define_method(cCdIoTracks, "each", rb_cdio_tracks_each, -1); rb_define_method(cCdIoTracks, "<=>", rb_cdio_tracks_diff, 2); rb_define_method(cCdIoTracks, "[]", rb_cdio_tracks_index, 1); rb_define_attr(cCdIoTracks, "cd", 1, 0); - rb_define_attr(cCdIoTracks, "tracks", 1, 0); /** class CdIo::Track */ cCdIoTrack = rb_define_class_under(mCdIo, "Track", rb_cObject); rb_define_method(cCdIoTrack, "initialize", rb_cdio_track_init, 2); rb_define_method(cCdIoTrack, "green?", rb_cdio_track_green, 0); rb_define_method(cCdIoTrack, "cdtext", rb_cdio_track_get_cdtext, 0); @@ -97,10 +118,37 @@ for (i = 0; i < 6; i++) { rb_define_attr(cCdIoTrackIso9660, attr3[i], 1, 0); } rb_define_method(cCdIoTrackIso9660, "initialize", rb_cdio_trackiso9660_init, 2); + // class CdIo::TrackCdda + cCdIoTrackCdda = rb_define_class_under(mCdIo, "TrackCdda", cCdIoTrack); + // rb_define_method(cCdIoTrackCdda, "initialize", + // rb_cdio_trackcdda_init, 2); + rb_define_method(cCdIoTrackCdda, "play", rb_cdio_trackcdda_play, 0); + rb_define_attr(cCdIoTrackCdda,"title",1,0); + rb_define_attr(cCdIoTrackCdda,"artist",1,0); + rb_define_attr(cCdIoTrackCdda,"extra_data",1,0); + + // exceptions + mCdIoException = rb_define_module_under(mCdIo, "Exception"); + eCdIoError = + rb_define_class_under(mCdIoException, "Error", rb_eIOError); + eCdIoUnsupported = + rb_define_class_under(mCdIoException, "Unsupported", rb_eIOError); + eCdIoUnitit = + rb_define_class_under(mCdIoException, "Unitit", rb_eIOError); + eCdIoNotPermitted = + rb_define_class_under(mCdIoException, "NotPermitted", rb_eIOError); + eCdIoBadParameter = + rb_define_class_under(mCdIoException, "BadParameter", rb_eIOError); + eCdIoBadPointer = + rb_define_class_under(mCdIoException, "BadPointer", rb_eNoMemError); + eCdIoNoDriver = + rb_define_class_under(mCdIoException, "NoDriver", rb_eIOError); + eCdIoCddbError = rb_define_class_under(mCdIoException, "CddbError",rb_eException); + eCdIoCddbConn = rb_define_class_under(mCdIoException, "CddbConn", rb_eIOError); // const for DRIVER rb_define_const(mCdIo, "DRIVER_UNKNOWN", INT2FIX(DRIVER_UNKNOWN)); rb_define_const(mCdIo, "DRIVER_FREEBSD", INT2FIX(DRIVER_FREEBSD)); rb_define_const(mCdIo, "DRIVER_LINUX", INT2FIX(DRIVER_LINUX)); rb_define_const(mCdIo, "DRIVER_SOLARIS", INT2FIX(DRIVER_SOLARIS)); @@ -148,6 +196,13 @@ /**< Mode1 of some sort */ rb_define_const(mCdIo, "TRACK_FORMAT_PSX", INT2FIX(TRACK_FORMAT_PSX)); rb_define_const(mCdIo, "TRACK_FORMAT_ERROR", INT2FIX(TRACK_FORMAT_ERROR)); /**< Dunno what is, or some other error. */ rb_define_const(mCdIo, "CDIO_CDROM_LEADOUT_TRACK", INT2FIX(CDIO_CDROM_LEADOUT_TRACK)); + rb_define_const(mCdIoCdda,"SUB_ST_INVALID",INT2FIX(CDIO_MMC_READ_SUB_ST_INVALID)); + rb_define_const(mCdIoCdda,"SUB_ST_PLAY",INT2FIX(CDIO_MMC_READ_SUB_ST_PLAY)); + rb_define_const(mCdIoCdda,"SUB_ST_PAUSED",INT2FIX(CDIO_MMC_READ_SUB_ST_PAUSED)); + rb_define_const(mCdIoCdda,"SUB_ST_COMPLETED",INT2FIX(CDIO_MMC_READ_SUB_ST_COMPLETED)); + rb_define_const(mCdIoCdda,"SUB_ST_ERROR",INT2FIX(CDIO_MMC_READ_SUB_ST_ERROR)); + rb_define_const(mCdIoCdda,"SUB_ST_NO_STATUS",INT2FIX(CDIO_MMC_READ_SUB_ST_NO_STATUS)); + }