- struct check_wav_task *cwt = container_of(t, struct check_wav_task, task);
- unsigned char *a;
- int ret;
-
- if (*cwt->loaded < WAV_HEADER_LEN) {
- if (*cwt->input_error < 0)
- t->error = *cwt->input_error;
- return;
- }
- cwt->channels = 2;
- cwt->samplerate = 44100;
- a = (unsigned char*)cwt->buf;
- if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F') {
- PARA_NOTICE_LOG("wav header not found\n");
- t->error = -E_NO_WAV_HEADER;
- goto out;
- }
- cwt->channels = (unsigned) a[22];
- cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- *cwt->loaded -= WAV_HEADER_LEN;
- memmove(cwt->buf, cwt->buf + WAV_HEADER_LEN, *cwt->loaded);
- t->error = -E_WAV_HEADER_SUCCESS;
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
-out:
- wng->channels = &cwt->channels;
- wng->samplerate = &cwt->samplerate;
- ret = wng_open(wng);
- if (ret < 0)
- t->error = ret;
- s->timeout.tv_sec = 0;
- s->timeout.tv_usec = 1;
+ wn->conf = check_writer_arg_or_die(arg, &wn->writer_num);
+ register_writer_node(wn, parent, s);