- struct check_wav_task *cwt = container_of(t, struct check_wav_task, task);
- struct btr_node *btrn = cwt->btrn;
- unsigned char *a;
- size_t sz;
- int ret;
-
- t->error = 0;
- ret = btr_node_status(btrn, cwt->min_iqs, BTR_NT_INTERNAL);
- if (ret <= 0)
- goto out;
- if (cwt->state != CWS_NEED_HEADER)
- goto pushdown;
- btr_merge(btrn, cwt->min_iqs);
- sz = btr_next_buffer(btrn, (char **)&a);
- if (sz < cwt->min_iqs) /* file size less than WAV_HEADER_SIZE */
- goto pushdown;
- cwt->min_iqs = 0;
- cwt->channels = 2;
- cwt->sample_rate = 44100;
- if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F') {
- PARA_NOTICE_LOG("wav header not found\n");
- cwt->state = CWS_NO_HEADER;
- sprintf(t->status, "check wav: no header");
- goto out;
- }
- PARA_INFO_LOG("found wav header\n");
- cwt->state = CWS_HAVE_HEADER;
- sprintf(t->status, "check wav: have header");
- cwt->channels = (unsigned) a[22];
- cwt->sample_rate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->sample_rate);
- btr_consume(btrn, WAV_HEADER_LEN);
-pushdown:
- btr_pushdown(btrn);
-out:
- t->error = ret;
- if (ret < 0)
- btr_remove_node(btrn);
-}
-
-static int loglevel;
-INIT_STDERR_LOGGING(loglevel)
-
-__noreturn static void print_help_and_die(void)
-{
- int d = conf.detailed_help_given;
- const char **p = d? write_args_info_detailed_help
- : write_args_info_help;
-
- printf_or_die("%s\n\n", WRITE_CMDLINE_PARSER_PACKAGE "-"
- WRITE_CMDLINE_PARSER_VERSION);
- printf_or_die("%s\n\n", write_args_info_usage);
- for (; *p; p++)
- printf_or_die("%s\n", *p);
- print_writer_helps(d);
- exit(0);