home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
cdrom
/
atapi_pnp300
/
developer_kit
/
playtrack.c
< prev
next >
Wrap
C/C++ Source or Header
|
1977-12-31
|
2KB
|
86 lines
/****************************************************************************
*
*
* $VER: PlayTrack.c 1.0 (22 Jan 1996) by M_Campinoti CD++
*
* $HISTORY:
*
* 22 Jan 1996 : 001.000 : First and Last release of an example that show
* how to play audio tracks by means of
* CD_PLAYTRACK command.
* Didactical use, so CLI only :)
*
****************************************************************************/
#include <proto/exec.h>
#include <exec/devices.h>
#include <exec/io.h>
#include <stdio.h>
#include <stdlib.h>
#include "atapi_cd.h"
#define START_TRACK 0x01
#define TRACKS_TO_PLAY 0x01
main (UBYTE argc,UBYTE** argv)
{
struct IOStdReq *ioreq ;
struct MsgPort *reply ;
UBYTE tracknumber;
UBYTE howmanytracks;
tracknumber=START_TRACK;
howmanytracks=TRACKS_TO_PLAY;
switch(argc)
{
case 0:
return; /* it came from workbench .... */
break;
default:
case 1:
printf("USAGE: PlayTrack <tracknumber> <tracks to play>\n");
return; /* Yes, this isn't a cool template, but is quickly ! (i'm lazy) */
break;
case 3:
howmanytracks=atoi(argv[2]);
case 2:
tracknumber=atoi(argv[1]);
}
if (tracknumber==0) tracknumber = 1; /* tracknumber MUST be not zero ! */
if (howmanytracks==0) howmanytracks = 1; /* (EX)Commodore Rules ! */
if( reply = CreateMsgPort() )
{
if( ioreq = (struct IOStdReq *)
CreateIORequest(reply ,sizeof(struct IOStdReq)) )
{
if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
{
ioreq->io_Command = CD_PLAYTRACK;
ioreq->io_Offset = tracknumber;
ioreq->io_Length = howmanytracks;
printf("Start Playing at TRACK N. %d\n",tracknumber);
DoIO((struct IORequest*)ioreq);
if (ioreq->io_Error)
printf("I/O error !\n"); /* analyze ioreq->io_Error to know what kind ... */
/* ... see atapi_cd.h for #defines of it ! */
CloseDevice((struct IORequest *)ioreq) ;
}
DeleteIORequest(ioreq) ;
}
DeleteMsgPort(reply);
}
}