- wt->channels = 2;
- wt->samplerate = 44100;
- a = (unsigned char*)wt->buf;
- t->ret = -E_NO_WAV_HEADER;
- if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F')
- return;
- wt->channels = (unsigned) a[22];
- wt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- *wt->loaded -= WAV_HEADER_LEN;
- memmove(wt->buf, wt->buf + WAV_HEADER_LEN, *wt->loaded);
- t->ret = -E_WAV_HEADER_SUCCESS;
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", wt->channels, wt->samplerate);
+ 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;