This is a patch file for "alsaplayer" 0.99.81. These changes are dis- tro-specific. They modify things so that "alsaplayer" locates audio CDs automatically. Note: These changes depend on an external distro-specific utility nam- ed "cdlist". --- alsaplayer-0.99.81.old/input/cdda/cdda_engine.c +++ alsaplayer-0.99.81/input/cdda/cdda_engine.c @@ -1036,6 +1036,54 @@ } else { strcpy(device_name, DEFAULT_DEVICE); } + +//-------------------------------------------------------------------- +// Locate audio CD automatically, if possible. + +#define XBUFSIZE 512 + + if (1) + { + char *cp; + FILE *ifp; + struct stat sbuf; + char tfname [XBUFSIZE]; + char xbuf [XBUFSIZE]; + + sprintf (tfname, "/tmp/alsaplayer-cdda-temp.%d-%d", + getuid(), getpid()); + sprintf (xbuf, + "/laclin/lacutil/cdlist --audio > %s", tfname); + unlink (tfname); + system (xbuf); + + if ((ifp = fopen (tfname, "r")) != NULL) + { + *xbuf = '\0'; + + if ((fgets (xbuf, sizeof (xbuf), ifp) != NULL) && + (*xbuf != '\0') && + !strncmp (xbuf, "/dev/", 5)) + { + for (cp = xbuf; *cp; cp++) + { + if (*cp <= ' ') { *cp = '\0'; break; } + } + + if (!stat (xbuf, &sbuf)) + { + strcpy (device_name, xbuf); + } + } + + fclose (ifp); + } + + unlink (tfname); + } + +//-------------------------------------------------------------------- + #ifdef DEBUG alsaplayer_error("device = %s, name = %s\n", device_name, fname); #endif