int usage(void) {
printf("usage:\n\n");
printf("-h \t\t print this help\n");
+ printf("-i \t\t use/print file info\n");
printf("-r <file> \t record to <file>\n");
printf("-p <file> \t play from <file>\n");
printf("-s \t\t stereo\n");
char play_file[MAX_C_FILE];
dsp_set set;
unsigned char *buf;
+ unsigned char print_info=0;
+ unsigned char info[8];
+ int info_int;
/* defaults */
strcpy(device,"");
case 'h':
usage();
return 1;
+ case 'i':
+ print_info=1;
+ break;
case 'r':
mode=RECORD;
strcpy(record_file,argv[++i]);
}
}
+ if(print_info) {
+ if(mode&PLAY) {
+ printf("file info:\n");
+ lseek(pfile_fd,4,SEEK_SET);
+ read(pfile_fd,&info_int,4);
+ printf("file size: %d\n",info_int);
+ lseek(pfile_fd,8,SEEK_CUR);
+ read(pfile_fd,&info_int,4);
+ printf("fmtsize: %d\n",info_int);
+ read(pfile_fd,&info_int,4);
+ printf("format tag: %d\n",(info_int>>16)&1<<16);
+ printf("channels: %d\n",info_int&1<<16);
+ read(pfile_fd,&info_int,4);
+ printf("samples/sec: %d\n",info_int);
+ read(pfile_fd,&info_int,4);
+ printf("bytes/sec: %d\n",info_int);
+ read(pfile_fd,&info_int,4);
+ printf("block allign: %d\n",(info_int>>16)&1<<16);
+ printf("bits/sample: %d\n",info_int&1<<16);
+ lseek(pfile_fd,4,SEEK_CUR);
+ read(pfile_fd,&info_int,4);
+ printf("datasize: %d\n\n",info_int);
+ /* return to start */
+ lseek(pfile_fd,0,SEEK_SET);
+ }
+ }
+
/* set dsp and get capabilities */
if(get_dsp_cap(audio_fd,&set,1)==-1) {
printf("unable to get capabilities :(\n");
perror("malloc");
return -1;
}
-
+
if(mode&PLAY) {
printf("playing file %s ...\n",play_file);
rw=1;