Subject: CD changer support for cdplay(1)
To: None <current-users@netbsd.org>
From: Andreas Wiese <bzimage@gmx.net>
List: current-users
Date: 10/25/2005 00:12:45
--CdrF4e02JqNVZeln
Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO"
Content-Disposition: inline


--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello.

I've got an old CD-C68E CD changer with six slots and was a little bit
frustrated that there doesn't seem to exist any tool I could use to
change the slots, so I wrote this little patch for cdplay(1). =20

Is anybody besides me interested in seeing something like this in the
CVS?

HAND & LG -- aw
np: Kettcar (Von Spatzen und Tauben, D=E4chern und H=E4nden) -- 01. Deiche
--=20
Unn=FCtzes Wissen (=BBneon=AB, 06/05):
  2. Die venezolanische Nationalmannschaft ist das einzige s=FCdamerikanisc=
he
     Team, das nie an einer Fu=DFball-WM teilgenommen hat.  Ihr Trainer war
     fr=FCher als Traumatologe t=E4tig.

--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="cdplay.diff"
Content-Transfer-Encoding: quoted-printable

Common subdirectories: cdplay.o/CVS and cdplay/CVS
diff -u cdplay.o/cdplay.1 cdplay/cdplay.1
--- cdplay.o/cdplay.1	2005-10-25 00:00:09.000000000 +0200
+++ cdplay/cdplay.1	2005-10-24 23:58:36.000000000 +0200
@@ -129,6 +129,10 @@
 Eject the disc.
 .It Cm close
 Inject the disc.
+.It Cm slot Ar slotno
+Change CD changer slot to slot number
+.Ar slotno .
+Slot numbers begin at 0.
 .It Cm volume Ar left_channel Ar right_channel
 Set the volume of left channel to
 .Ar left_channel
@@ -182,5 +186,4 @@
 .An Andrey A.\ Chernov ,
 .An Serge V.\ Vakulenko ,
 .An Andrew Doran ,
-.An Sergey Svishchev ,
-.An Andreas Wiese .
+.An Sergey Svishchev .
diff -u cdplay.o/cdplay.c cdplay/cdplay.c
--- cdplay.o/cdplay.c	2005-10-25 00:00:09.000000000 +0200
+++ cdplay/cdplay.c	2005-10-24 23:50:58.000000000 +0200
@@ -79,6 +79,7 @@
 	CMD_SET,
 	CMD_SHUFFLE,
 	CMD_SKIP,
+	CMD_SLOT,
 	CMD_STATUS,
 	CMD_STOP,
 	CMD_VOLUME,
@@ -108,6 +109,7 @@
 	{ CMD_SET,	"set",     2, "msf | lba" },
 	{ CMD_SHUFFLE,	"shuffle", 2, NULL },
 	{ CMD_SKIP,	"skip",    2, NULL },
+	{ CMD_SLOT,	"slot",    2, "slotno" },
 	{ CMD_STATUS,	"status",  3, NULL },
 	{ CMD_STOP,	"stop",    3, NULL },
 	{ CMD_VOLUME,	"volume",  1, "<l> <r>|left|right|mute|mono|stereo" },
@@ -149,6 +151,7 @@
 int	setvol(int, int);
 void	sig_timer(int);
 int	skip(int, int);
+int	slot(int);
 const char	*strstatus(int);
 void 	usage(void);
=20
@@ -300,7 +303,7 @@
 int
 run(int cmd, const char *arg)
 {
-	int l, r, rv;
+	int l, r, s, rv;
=20
 	rv =3D 0;
 	if (cmd =3D=3D CMD_QUIT) {
@@ -422,6 +425,14 @@
 			warnx("invalid command arguments");
 		break;
=20
+	case CMD_SLOT:
+		if (sscanf(arg, "%d", &s) !=3D 1) {
+			warnx("invalid command arguments");
+			break;
+		}
+		rv =3D slot(s);
+		break;
+
 	case CMD_VOLUME:
 		if (strncasecmp(arg, "left", strlen(arg)) =3D=3D 0)
 			rv =3D ioctl(fd, CDIOCSETLEFT);
@@ -940,6 +951,20 @@
 }
=20
 int
+slot(int no)
+{
+	int rv;
+	struct ioc_load_unload lu;
+
+	lu.options =3D CD_LU_LOAD;
+	lu.slot    =3D no;
+
+	if((rv =3D ioctl(fd, CDIOCLOADUNLOAD, &lu)) < 0)
+		warn("ioctl(CDIOCLOADUNLOAD)");
+	return (rv);
+}
+
+int
 read_toc_entrys(int len)
 {
 	struct ioc_read_toc_entry t;

--M9NhX3UHpAaciwkO--

--CdrF4e02JqNVZeln
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)

iD8DBQFDXVxdpxHyXmET8T8RAqQ6AJ90QBNKmsXOghW1P5jAAhbP+mVoyACePATL
8giHedKP79gmjiQtkYUzIw0=
=ZuFN
-----END PGP SIGNATURE-----

--CdrF4e02JqNVZeln--