> > > > Is there some documentation anywhere on how a program
> > > > can control playback of audio CD's?
> > > > When playing CD's on my computer I cannot hear if the
> > > > computer beeps, so instead I want to just rewind the
> > > > CD 1/3 second every time the computer beeps.
> > > > Now I want to know how to do that, the information in
> > > > the ioctl_list(2) man page is not particular helpful,
> > > > at least it is not possible from this information to
> > > > see how I can change the play position for a playing
> > > > CD? Is there any better doucmentation?
> > > The source code for your favorite cd player program :)
> > I was hoping something better existed.
> What about linux source code? Any well written code should be self
> documenting :-)
> I believe there is a cdrom.h file somewhere with all the ioctls in it.
> The ioctl_list man page doesn't seem to be very up to date.
I straced my favourite CD player to see which ioctl it did
use, I looked in the kernel source to see which structs they
used, and I looked in cdrom.h to find the fields, and I
could guess what most of them were used for. So I now came
up with this piece of code:
#include <linux/cdrom.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#define SKIPBACK 25
int main()
{
struct cdrom_msf ps;
struct cdrom_subchnl q;
int fd=open("/dev/cdrom",O_RDONLY);
q.cdsc_format=CDROM_MSF;
ioctl(fd,CDROMSUBCHNL,&q);
if (q.cdsc_absaddr.msf.frame<SKIPBACK) {
q.cdsc_absaddr.msf.frame+=(CD_FRAMES-SKIPBACK);
if (q.cdsc_absaddr.msf.second) {
q.cdsc_absaddr.msf.second--;
} else {
q.cdsc_absaddr.msf.second+=(CD_SECS-1);
q.cdsc_absaddr.msf.minute--;
}
} else {
q.cdsc_absaddr.msf.frame -= 25;
}
ps.cdmsf_min0=q.cdsc_absaddr.msf.minute; /* start minute */
ps.cdmsf_sec0=q.cdsc_absaddr.msf.second; /* start second */
ps.cdmsf_frame0=q.cdsc_absaddr.msf.frame; /* start frame */
ps.cdmsf_min1=99; /* end minute */
ps.cdmsf_sec1=0; /* end second */
ps.cdmsf_frame1=0; /* end frame */
ioctl(fd,CDROMPLAYMSF,&ps);
// ioctl(fd,CDROMSTART);
return 0;
Quote:}
And don't need to tell me this code needs a lot of
fixing, I know it. There are a few things I wonder
about:
1) Can I prevent the CD from being silent for 0.1
second while changing position? It sounds horrible.
2) Is there a way to read the current end location,
playlists seems to break when I change it.
3) Finally (not that it is something I need, just
wondering), can the end location be changed
without interfeering with the current playback?
(And can the CD be programmed to automatically
resume at another location when end is reached?)
--
Kasper Dupont -- der bruger for meget tid p? usenet.