diff -urN mcd-0.2a/Makefile mcd-0.2b/Makefile --- mcd-0.2a/Makefile Thu Jul 12 00:49:51 2001 +++ mcd-0.2b/Makefile Sun Jul 22 19:53:41 2001 @@ -7,7 +7,7 @@ #CC = gcc CC = diet gcc -CFLAGS = -O2 -Wall -pipe -fomit-frame-pointer +CFLAGS = -Os -Wall -pipe -fomit-frame-pointer LDFLAGS = S_FLAGS = -R .note -R .comment diff -urN mcd-0.2a/cddev.c mcd-0.2b/cddev.c --- mcd-0.2a/cddev.c Sun Jul 22 02:52:23 2001 +++ mcd-0.2b/cddev.c Sun Jul 22 19:51:43 2001 @@ -20,18 +20,21 @@ /* GLOBAL */ +/* open device or exit ! */ int cd_init(const char *cdpath, struct mcd *cd) { cd->fd=open(cdpath,O_RDONLY|O_NONBLOCK); - if (cd->fd<0) return -1; - if ((cd->status=ioctl(cd->fd,CDROM_DISC_STATUS,NULL)<0)) return -1; - if (cd->status==(100||105)) return -2; + if ((cd->fd<0) || (cd->status=ioctl(cd->fd,CDROM_DISC_STATUS,NULL)<0)) { + _printf("Sorry, can't open cd-device: \"%s\" !\n",cdpath); + exit(1); + } + if (cd->status==(100||105)) return -1; return 0; } -/* needs correct cd->fd; seems efficient to me :) */ +/* needs correct cd->fd; seems very efficient (no division qnd such) */ int cd_readtracks(struct mcd *cd) { - struct cdrom_tochdr cdth; /* TocHdr Stuff */ - int i, sec; + struct cdrom_tochdr cdth; /* TocHdr Stuff */ + register int i; if (ioctl(cd->fd, CDROMREADTOCHDR, &cdth)<0) { draw_status("can't read disc",1); @@ -45,14 +48,13 @@ draw_status("can't read disc",1); return -1; } else { - cd->t[i].nr=i; /* for reordering after shuffle */ - cd->t[i].audio = cd->cdte[i].cdte_ctrl & CDROM_DATA_TRACK; - cd->t[i-1].min=cd->cdte[i].cdte_addr.msf.minute- - cd->cdte[i-1].cdte_addr.msf.minute; - sec=(cd->t[i-1].sec=cd->t[i].sec - cd->t[i-1].sec); - if (cd->cdte[i].cdte_addr.msf.frame>37) cd->t[i-1].sec++; /* rounding a bit :) */ - if (sec<0) { - cd->t[i-1].min--;cd->t[i-1].sec+=60; + cd->t[i].audio=cd->cdte[i].cdte_ctrl & CDROM_DATA_TRACK; + cd->t[i].min=cd->cdte[i].cdte_addr.msf.minute; + cd->t[i].sec=cd->cdte[i].cdte_addr.msf.second; + cd->t[i-1].min=cd->t[i].min-cd->t[i-1].min; + if ((cd->cdte[i].cdte_addr.msf.frame)>37) cd->t[i-1].sec++; /* rounding a bit :) */ + if ((cd->t[i-1].sec=cd->t[i].sec-cd->t[i-1].sec)<0) { + cd->t[i-1].min--;cd->t[i-1].sec+=60; /* adjust minutes */ } } } @@ -63,21 +65,20 @@ draw_status("can't read disc",1); return -1; } else { - cd->t[i].nr=i; - cd->t[0].audio = cd->cdte[0].cdte_ctrl & CDROM_DATA_TRACK; - cd->t[0].min = cd->cdte[0].cdte_addr.msf.minute; - cd->t[0].sec = cd->cdte[0].cdte_addr.msf.second; - cd->t[i-1].min=cd->t[0].min - cd->t[i-1].min; - sec=(cd->t[i-1].sec=cd->t[0].sec - cd->t[i-1].sec); - if (cd->cdte[0].cdte_addr.msf.frame>37) cd->t[i-1].sec++; /* rounding a bit :) */ - if (sec<0) { - cd->t[i-1].min--;cd->t[i-1].sec+=60; + cd->t[0].audio=cd->cdte[0].cdte_ctrl & CDROM_DATA_TRACK; + cd->t[0].min=cd->cdte[0].cdte_addr.msf.minute; + cd->t[0].sec=cd->cdte[0].cdte_addr.msf.second; + cd->t[i-1].min=cd->t[0].min-cd->t[i-1].min; + if ((cd->cdte[i].cdte_addr.msf.frame)>37) cd->t[i-1].sec++; /* rounding a bit :) */ + if ((cd->t[i-1].sec=cd->t[0].sec-cd->t[i-1].sec)<0) { + cd->t[i-1].min--;cd->t[i-1].sec+=60; /* adjust minutes */ } } updates[U_TRACKS]=1; return cd->title[1]=cdth.cdth_trk1; /* init all these stuff */ } + int cd_readsubchannel(struct mcd *cd) { struct cdrom_volctrl cdv; /* Volume Stuff */ @@ -181,7 +182,7 @@ void cd_stop(struct mcd *cd) { if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY) if (ioctl(cd->fd,CDROMSTOP,NULL)<0) - draw_status("error, while stopping",1); + draw_status("error: stopping",1); return; } diff -urN mcd-0.2a/doc/CHANGES mcd-0.2b/doc/CHANGES --- mcd-0.2a/doc/CHANGES Thu Jan 1 01:00:00 1970 +++ mcd-0.2b/doc/CHANGES Sun Jul 22 19:56:42 2001 @@ -0,0 +1,6 @@ +0.2b: + added this file (doc/CHANGES) + removed shuffle completly, it will be included if it is stable + made cd_readtracks() more efficient + many ugly bugs removed :) + \ No newline at end of file diff -urN mcd-0.2a/doc/README mcd-0.2b/doc/README --- mcd-0.2a/doc/README Sun Jul 22 04:19:38 2001 +++ mcd-0.2b/doc/README Sun Jul 22 18:59:16 2001 @@ -2,10 +2,10 @@ WHAT IS IT =========== -- mcd (0.2a) is a small (maybe the smallest) cd-player for _linux_ +- mcd is a small (maybe the smallest) cd-player for _linux_ - it should compile/run out off the box -- it compiles against dietlibc (12kb static!) -- working play methods: reapeat cd, repeat track and intro (@ some time shuffle) +- it compiles against dietlibc (~11kb static!) +- working play methods: reapeat cd, repeat track and intro @@ -46,8 +46,8 @@ - term resizing stuff works correct, if not started from mc, because mc seems to catch the SIGWINCH signal !!! (btw: a new rewrite of the midnight commander will be my next project ...) -- maybe some things of the wishlist... if someone ask me, i will do it, but for - now, this (mcd-0.2a) is the stable release of mcd ! +- maybe some things of the wishlist... (if someone ask me, i will do it) +- for now, this is the stable release of mcd ! diff -urN mcd-0.2a/draw.c mcd-0.2b/draw.c --- mcd-0.2a/draw.c Sun Jul 22 02:54:19 2001 +++ mcd-0.2b/draw.c Sun Jul 22 20:09:55 2001 @@ -78,9 +78,6 @@ gotoxyw(3,6, "Volume:"); gotoxyw(3,7, "Track:"); gotoxyw(3,8, "CD:"); - show1(C_NORMAL); - - /* draw_box(30,2,maxx-1,8); for titel etc.. reseved */ return; } @@ -89,7 +86,7 @@ _printf(C_STATUS "%-23s" C_NORMAL, msg); if (again) { updates[U_STATUS]=1; - sleep(1); + sleep(again); } return; } @@ -150,15 +147,13 @@ /* always */ gotoxy(11,7); - _printf("%02d:%02d (%2d/%2d)", + _printf("%02d:%02d", cd->cds.cdsc_reladdr.msf.minute, - cd->cds.cdsc_reladdr.msf.second, - cd->title[0], cd->title[1]); + cd->cds.cdsc_reladdr.msf.second); gotoxy(11,8); - _printf("%02d:%02d (%2d/%2d)", + _printf("%02d:%02d", cd->cds.cdsc_absaddr.msf.minute, - cd->cds.cdsc_absaddr.msf.second, - 1, 1); /* maybe more then one cd l8er */ - gotoxy(2,2); + cd->cds.cdsc_absaddr.msf.second); + show1(T_HOME); return; } diff -urN mcd-0.2a/mcd.1 mcd-0.2b/mcd.1 --- mcd-0.2a/mcd.1 Sun Jul 22 03:00:26 2001 +++ mcd-0.2b/mcd.1 Sun Jul 22 19:36:57 2001 @@ -1,9 +1,11 @@ .\" Tino Reichardt -.TH MCD 1 "2001-07-22" "mcd-0.2a" "User commands" +.TH MCD 1 "2001-07-22" "mcd-0.2b" "User commands" .SH "NAME" mcd \- a small cdplayer for linux .SH "SYNOPSIS" \fBmcd\fR [\fI/dev/some-cdrom-device\fR] +.SH "OPTIONS" +There is simple only one (optional) option: a cd device (e.g. /dev/cdrom2) ! .SH "DESCRIPTION" The command \fBmcd\fR is used for playing AudioCD's. It has a curses like userinterface and is fairly simple to use. @@ -30,12 +32,19 @@ @change audio volume of cdrom device (-/+) Q/q@quit mcd .TE -.SH "RETURN VALUE" +.SH "ENVIRONMENT VARIABLES" .TS tab (@); l l. -\fB0\fP @if no errors occured -\fB1\fP @if some error occured +MCD_CDROM@try this cdrom as default, rather then CDROM_DEFAULT from params.h (compile time). +.TE +.SH "RETURN VALUES" +.TS +tab (@); +l l. +\fB0\fP @no errors occured / normal quit +\fB1\fP @the given cd-device isn't a cd-device +\fB2\fP @your cd seems to be sth else then CD-Audio or CD-Mixed .TE .SH "NOTES" Some terminals don't like the default escape-sequences from params.h ... if diff -urN mcd-0.2a/mcd.c mcd-0.2b/mcd.c --- mcd-0.2a/mcd.c Sun Jul 22 02:43:44 2001 +++ mcd-0.2b/mcd.c Sun Jul 22 20:10:58 2001 @@ -7,7 +7,7 @@ #include "mcd.h" short pluskey=0; /* 0..9|X is played */ -short updates[5]; /* see mcd.h */ +short updates[4]; /* see mcd.h */ int main(int argc, char **argv, char **environ) { struct mcd *cd=malloc(sizeof(struct mcd)); @@ -15,15 +15,16 @@ char ch; if (argc>1) quit=cd_init(argv[1],&cd[0]); - else quit=cd_init(CDROM_DEFAULT,&cd[0]); - switch (quit) { - case -2: - _printf("Sorry, your disc in %s isn't a Mixed-CD or Audio-CD !\n",CDROM_DEFAULT); - exit(1); - break; - case -1: - _printf("Sorry, can't open cd-device: \"%s\" !\n",(argc>1)?argv[1]:CDROM_DEFAULT); - exit(1); + else { /* try default stuff */ + if ((argv[1]=getenv("MCD_CDROM"))!=NULL) { /* env */ + quit=cd_init(argv[1],&cd[0]); + } else { + quit=cd_init(CDROM_DEFAULT,&cd[0]); /* params.h */ + } + } + if (quit<0) { + mesg(1,"Sorry, your disc isn't a Mixed-CD or Audio-CD !\n"); + exit(2); } tty_mode(TERM_INIT); signal(SIGINT,mcd_quit); diff -urN mcd-0.2a/mcd.h mcd-0.2b/mcd.h --- mcd-0.2a/mcd.h Sun Jul 22 04:22:59 2001 +++ mcd-0.2b/mcd.h Sun Jul 22 20:11:14 2001 @@ -24,7 +24,7 @@ #include "params.h" -#define MCD_VERSION "0.2a" +#define MCD_VERSION "0.2b" /* METHODS (don't change!) */ #define M_PLAY_CD 0 /* play whole cd and stop */ @@ -42,7 +42,6 @@ /* ***** */ /* mcd.c */ struct track { - int nr; /* title number */ int audio; /* current track is audio */ int sec; /* seconds of current title */ int min; /* minutes of current title */ @@ -56,10 +55,10 @@ struct track t[MCD_CDAUDIO_MAX+1]; /* calculated times of all tracks */ struct cdrom_volctrl vol; /* current channel0..3 (0..255) */ struct cdrom_subchnl cds; /* tmp subchannelinfos */ - struct cdrom_tocentry cdte[MCD_CDAUDIO_MAX+1]; /* for playmsf */ + struct cdrom_tocentry cdte[MCD_CDAUDIO_MAX+1]; /* mainly for playmsf */ }; -extern short maxx,maxy,pluskey,updates[5]; +extern short maxx,maxy,pluskey,updates[4]; extern void mcd_quit(int); /* cleanups + quit */ /* ***** */ diff -urN mcd-0.2a/params.h mcd-0.2b/params.h --- mcd-0.2a/params.h Sun Jul 22 04:18:35 2001 +++ mcd-0.2b/params.h Sun Jul 22 19:59:12 2001 @@ -7,18 +7,13 @@ #define CDROM_DEFAULT "/dev/cdrom" -/* seconds for the intro */ -#define MCD_INTRO_TIME 10 - -/* maxtracks of the cd (RedBook) */ -#define MCD_CDAUDIO_MAX 99 - -/* Edit it to your needs */ -#define FW_FAST 30 /* FF (sec. ffast forward) */ -#define FW_SLOW 6 /* FW (sec. fslow forward) */ -#define RW_FAST 30 /* RF (sec. rfast rewind) */ -#define RW_SLOW 6 /* RW (sec. rslow rewind) */ +#define MCD_INTRO_TIME 2 /* seconds for the intro */ +#define MCD_CDAUDIO_MAX 99 /* maxtracks of the cd (RedBook) */ +#define FW_FAST 30 /* FF (sec. ffast forward) */ +#define FW_SLOW 6 /* FW (sec. fslow forward) */ +#define RW_FAST 30 /* RF (sec. rfast rewind) */ +#define RW_SLOW 6 /* RW (sec. rslow rewind) */ /* * ESC seqences, you may change some of them ... diff -urN mcd-0.2a/tty.c mcd-0.2b/tty.c --- mcd-0.2a/tty.c Thu Jul 12 02:14:44 2001 +++ mcd-0.2b/tty.c Sun Jul 22 19:23:17 2001 @@ -32,7 +32,6 @@ } exit(0); } - return; } void tty_resize(int i) {