⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aztcd

📁 《嵌入式系统设计与实例开发实验教材二源码》Linux内核移植与编译实验
💻
📖 第 1 页 / 共 3 页
字号:
          V0.3  W.Zimmermann: Additional functions. Nov. 28, 1994                    V0.4  W.Zimmermann: fixed some bugs. Dec. 17, 1994          V0.5  W.Zimmermann: clean 'scanf' commands without compiler warnings                              Jan. 6, 1995          V0.6  W.Zimmermann: volume control (still experimental). Jan. 24, 1995          V0.7  W.Zimmermann: read raw modified. July 26, 95*/#include <stdio.h>#include <ctype.h>#include <sys/ioctl.h>#include <sys/types.h>#include <fcntl.h>#include <unistd.h>#include <linux/cdrom.h>#include <linux/../../drivers/cdrom/aztcd.h>void help(void){ printf("Available Commands:  STOP         s      EJECT/CLOSE  e       QUIT         q\n");  printf("                     PLAY TRACK   t      PAUSE        p       RESUME       r\n");  printf("                     NEXT TRACK   n      REPEAT LAST  l       HELP         h\n");  printf("                     SUB CHANNEL  c      TRACK INFO   i       PLAY AT      a\n");  printf("                     READ         d      READ RAW     w       VOLUME       v\n");}int main(void){ int handle;  unsigned char command=' ', ini=0, first=1, last=1;  unsigned int cmd, i,j,k, arg1,arg2,arg3;  struct cdrom_ti       ti;  struct cdrom_tochdr   tocHdr;  struct cdrom_subchnl  subchnl;  struct cdrom_tocentry entry;  struct cdrom_msf      msf;  union  { struct cdrom_msf msf;           unsigned char buf[CD_FRAMESIZE_RAW];         } azt;  struct cdrom_volctrl  volctrl;  printf("\nMini-Audio CD-Player V0.72   (C) 1994,1995,1996  W.Zimmermann\n");  handle=open("/dev/cdrom",O_RDWR);  ioctl(handle,CDROMRESUME);    if (handle<=0)     { printf("Drive Error: already playing, no audio disk, door open\n");      printf("             or no permission (you must be ROOT in order to use this program)\n");    }  else    { help();      while (1)        { printf("Type command (h = help):  ");          scanf("%s",&command);           switch (command)            { case 'e':   cmd=CDROMEJECT;                          ioctl(handle,cmd);                          break;                case 'p':   if (!ini)                             { printf("Command not allowed - play track first\n");                             }                          else                             { cmd=CDROMPAUSE;                               if (ioctl(handle,cmd)) printf("Drive Error\n");                             }                          break;              case 'r':   if (!ini)                             { printf("Command not allowed - play track first\n");                             }                          else                             { cmd=CDROMRESUME;                               if (ioctl(handle,cmd)) printf("Drive Error\n");                             }                          break;              case 's':   cmd=CDROMPAUSE;                          if (ioctl(handle,cmd)) printf("Drive error or already stopped\n");                          cmd=CDROMSTOP;                          if (ioctl(handle,cmd)) printf("Drive error\n");                          break;              case 't':   cmd=CDROMREADTOCHDR;                          if (ioctl(handle,cmd,&tocHdr)) printf("Drive Error\n");                          first=tocHdr.cdth_trk0;                          last= tocHdr.cdth_trk1;                          if ((first==0)||(first>last))                            { printf ("--could not read TOC\n");                            }                          else                            { printf("--first track: %d   --last track: %d   --enter track number: ",first,last);                              cmd=CDROMPLAYTRKIND;                              scanf("%i",&arg1);                              ti.cdti_trk0=arg1;                              if (ti.cdti_trk0<first) ti.cdti_trk0=first;                              if (ti.cdti_trk0>last)  ti.cdti_trk0=last;                              ti.cdti_ind0=0;                              ti.cdti_trk1=last;                              ti.cdti_ind1=0;                              if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");                              ini=1;                            }                           break;              case 'n':   if (!ini++)                             { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");                              first=tocHdr.cdth_trk0;                              last= tocHdr.cdth_trk1;                              ti.cdti_trk0=first-1;                            }                          if ((first==0)||(first>last))                            { printf ("--could not read TOC\n");                            }                          else                            { cmd=CDROMPLAYTRKIND;                              if (++ti.cdti_trk0 > last)  ti.cdti_trk0=last;                              ti.cdti_ind0=0;                              ti.cdti_trk1=last;                              ti.cdti_ind1=0;                              if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");                              ini=1;                            }                          break;              case 'l':   if (!ini++)                            { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");                              first=tocHdr.cdth_trk0;                              last= tocHdr.cdth_trk1;                              ti.cdti_trk0=first+1;                            }                          if ((first==0)||(first>last))                            { printf ("--could not read TOC\n");                            }                          else                            { cmd=CDROMPLAYTRKIND;                              if (--ti.cdti_trk0 < first) ti.cdti_trk0=first;                              ti.cdti_ind0=0;                              ti.cdti_trk1=last;                              ti.cdti_ind1=0;                              if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");                              ini=1;                            }                            break;              case 'c':   subchnl.cdsc_format=CDROM_MSF;                          if (ioctl(handle,CDROMSUBCHNL,&subchnl))                             printf("Drive Error\n");                          else                            { printf("AudioStatus:%s   Track:%d  Mode:%d   MSF=%d:%d:%d\n", \                              subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",\                              subchnl.cdsc_trk,subchnl.cdsc_adr, \                              subchnl.cdsc_absaddr.msf.minute, subchnl.cdsc_absaddr.msf.second, \                              subchnl.cdsc_absaddr.msf.frame);                            }                          break;                            case 'i':   if (!ini)                            { printf("Command not allowed - play track first\n");                            }                          else                            { cmd=CDROMREADTOCENTRY;                              printf("Track No.: ");                              scanf("%d",&arg1);                              entry.cdte_track=arg1;                              if (entry.cdte_track<first) entry.cdte_track=first;                              if (entry.cdte_track>last)  entry.cdte_track=last;			      entry.cdte_format=CDROM_MSF;                              if (ioctl(handle,cmd,&entry))                                { printf("Drive error or invalid track no.\n");                               }                              else                               { printf("Mode %d Track, starts at %d:%d:%d\n", \                               entry.cdte_adr,entry.cdte_addr.msf.minute, \                               entry.cdte_addr.msf.second,entry.cdte_addr.msf.frame);                               }                            }                          break;              case 'a':   cmd=CDROMPLAYMSF;                          printf("Address (min:sec:frame)  ");                          scanf("%d:%d:%d",&arg1,&arg2,&arg3);                          msf.cdmsf_min0  =arg1;                          msf.cdmsf_sec0  =arg2;                          msf.cdmsf_frame0=arg3;                          if (msf.cdmsf_sec0  > 59) msf.cdmsf_sec0  =59;                          if (msf.cdmsf_frame0> 74) msf.cdmsf_frame0=74;                          msf.cdmsf_min1=60;                          msf.cdmsf_sec1=00;                          msf.cdmsf_frame1=00;                          if (ioctl(handle,cmd,&msf))                            { printf("Drive error or invalid address\n");                           }                          break;#ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/              case 'd':   cmd=CDROMREADCOOKED;                          printf("Address (min:sec:frame)  ");                          scanf("%d:%d:%d",&arg1,&arg2,&arg3);                          azt.msf.cdmsf_min0  =arg1;                          azt.msf.cdmsf_sec0  =arg2;                          azt.msf.cdmsf_frame0=arg3;                          if (azt.msf.cdmsf_sec0  > 59) azt.msf.cdmsf_sec0  =59;                          if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;                          if (ioctl(handle,cmd,&azt.msf))                            { printf("Drive error, invalid address or unsupported command\n");                           }                          k=0;                          getchar();                          for (i=0;i<128;i++)                           { printf("%4d:",i*16);                             for (j=0;j<16;j++)                               { printf("%2x ",azt.buf[i*16+j]);                               }                             for (j=0;j<16;j++)                               { if (isalnum(azt.buf[i*16+j]))                                    printf("%c",azt.buf[i*16+j]);                                 else                                   printf(".");                               }                             printf("\n");                              k++;                             if (k>=20)                              { printf("press ENTER to continue\n");                                getchar();                                k=0;                              }                           }                           break;              case 'w':   cmd=CDROMREADRAW;                          printf("Address (min:sec:frame)  ");                          scanf("%d:%d:%d",&arg1,&arg2,&arg3);                          azt.msf.cdmsf_min0  =arg1;                          azt.msf.cdmsf_sec0  =arg2;                          azt.msf.cdmsf_frame0=arg3;                                                    if (azt.msf.cdmsf_sec0  > 59) azt.msf.cdmsf_sec0  =59;                          if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;                          if (ioctl(handle,cmd,&azt))                            { printf("Drive error, invalid address or unsupported command\n");                           }                          k=0;                          for (i=0;i<147;i++)                           { printf("%4d:",i*16);                             for (j=0;j<16;j++)                               { printf("%2x ",azt.buf[i*16+j]);                               }                             for (j=0;j<16;j++)                               { if (isalnum(azt.buf[i*16+j]))                                    printf("%c",azt.buf[i*16+j]);                                 else                                   printf(".");                               }                             printf("\n");                              k++;                             if (k>=20)                              { getchar();                                k=0;                              }                           }                           break;#endif              case 'v':   cmd=CDROMVOLCTRL;                          printf("--Channel 0 Left  (0-255): ");                          scanf("%d",&arg1);                          printf("--Channel 1 Right (0-255): ");                          scanf("%d",&arg2);                          volctrl.channel0=arg1;                          volctrl.channel1=arg2;                          volctrl.channel2=0;                          volctrl.channel3=0;                          if (ioctl(handle,cmd,&volctrl))                            { printf("Drive error or unsupported command\n");                           }                          break;                case 'q':   if (close(handle)) printf("Drive Error: CLOSE\n");                          exit(0);              case 'h':   help();                          break;              default:    printf("unknown command\n");                          break;            }       }    }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -