]> hackdaworld.org Git - sound-tools/hdrec.git/commitdiff
added print info option (still in dev)
authorhackbard <hackbard>
Sun, 6 Jul 2003 20:39:35 +0000 (20:39 +0000)
committerhackbard <hackbard>
Sun, 6 Jul 2003 20:39:35 +0000 (20:39 +0000)
hdrec
hdrec.c

diff --git a/hdrec b/hdrec
index bb3f97a260ab910c3ec184a3caf3213df9ed9305..9bfc05fed12ef339e20968c70b4effc07a6d787b 100755 (executable)
Binary files a/hdrec and b/hdrec differ
diff --git a/hdrec.c b/hdrec.c
index ac6348e73a1cca281df413e1883ec23f710f8674..58cb67074b5c6276f3718e5a5095c452ca3e5f89 100644 (file)
--- a/hdrec.c
+++ b/hdrec.c
@@ -22,6 +22,7 @@
 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");
@@ -45,6 +46,9 @@ int main(int argc,char **argv) {
        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,"");
@@ -59,6 +63,9 @@ int main(int argc,char **argv) {
                                case 'h':
                                        usage();
                                        return 1;
+                               case 'i':
+                                       print_info=1;
+                                       break;
                                case 'r':
                                        mode=RECORD;
                                        strcpy(record_file,argv[++i]);
@@ -119,6 +126,33 @@ int main(int argc,char **argv) {
                }
        }
 
+       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");
@@ -135,7 +169,7 @@ int main(int argc,char **argv) {
                perror("malloc");
                return -1;
        }
-       
+
        if(mode&PLAY) {
                printf("playing file %s ...\n",play_file);
                rw=1;