initialize wav structure enough, for wav_close() to work

This commit is contained in:
Alexandre Ratchov 2012-11-02 12:05:56 +01:00
parent 718a891d31
commit 3f1b2007ce
1 changed files with 9 additions and 7 deletions

View File

@ -796,7 +796,11 @@ wav_new_in(struct fileops *ops, struct dev *dev,
close(fd); close(fd);
return NULL; return NULL;
} }
f->mode = mode;
f->pstate = WAV_CFG; f->pstate = WAV_CFG;
f->endpos = f->startpos = 0;
f->next = wav_list;
wav_list = f;
if (hdr == HDR_WAV) { if (hdr == HDR_WAV) {
if (!wav_readhdr(f->pipe.fd, par, if (!wav_readhdr(f->pipe.fd, par,
&f->startpos, &f->rbytes, &f->map)) { &f->startpos, &f->rbytes, &f->map)) {
@ -805,7 +809,6 @@ wav_new_in(struct fileops *ops, struct dev *dev,
} }
f->endpos = f->startpos + f->rbytes; f->endpos = f->startpos + f->rbytes;
} else { } else {
f->startpos = 0;
f->endpos = pipe_endpos(&f->pipe.file); f->endpos = pipe_endpos(&f->pipe.file);
if (f->endpos > 0) { if (f->endpos > 0) {
if (!pipe_seek(&f->pipe.file, 0)) { if (!pipe_seek(&f->pipe.file, 0)) {
@ -846,8 +849,6 @@ wav_new_in(struct fileops *ops, struct dev *dev,
dbg_puts("\n"); dbg_puts("\n");
} }
#endif #endif
f->next = wav_list;
wav_list = f;
return f; return f;
} }
@ -881,7 +882,11 @@ wav_new_out(struct fileops *ops, struct dev *dev,
close(fd); close(fd);
return NULL; return NULL;
} }
f->mode = mode;
f->pstate = WAV_CFG; f->pstate = WAV_CFG;
f->endpos = f->startpos = 0;
f->next = wav_list;
wav_list = f;
if (hdr == HDR_WAV) { if (hdr == HDR_WAV) {
par->le = 1; par->le = 1;
par->sig = (par->bits <= 8) ? 0 : 1; par->sig = (par->bits <= 8) ? 0 : 1;
@ -892,14 +897,11 @@ wav_new_out(struct fileops *ops, struct dev *dev,
} }
f->wbytes = WAV_DATAMAX; f->wbytes = WAV_DATAMAX;
f->endpos = f->startpos; f->endpos = f->startpos;
} else { } else
f->wbytes = -1; f->wbytes = -1;
f->startpos = f->endpos = 0;
}
f->dev = dev; f->dev = dev;
f->mmc = mmc; f->mmc = mmc;
f->join = join; f->join = join;
f->mode = mode;
f->hpar = *par; f->hpar = *par;
f->hdr = hdr; f->hdr = hdr;
f->xrun = xrun; f->xrun = xrun;